def collect(self, config):
        """
        This method return a Twisted deferred. The deferred results will
        be sent to the onResult then either onSuccess or onError callbacks
        below.
        """
        results = self.new_data()
        res = ''

        ds0 = config.datasources[0]
        # Check the connection and collect data.
        url = hbase_rest_url(scheme=ds0.zHBaseScheme,
                             port=ds0.zHBaseRestPort,
                             host=ds0.manageIp,
                             endpoint=self.endpoint)
        headers = hbase_headers(accept='application/json',
                                username=ds0.zHBaseUsername,
                                passwd=ds0.zHBasePassword)
        try:
            res = yield getPage(url, headers=headers)
            if not res:
                raise HBaseException('No monitoring data')
        except (Exception, HBaseException), e:
            # Send connection error event for each component.
            for ds in config.datasources:
                e = check_error(e, ds.device) or e
                results['events'].append({
                    'component': ds.component,
                    'summary': str(e),
                    'eventKey': 'hbase_monitoring_error',
                    'eventClass': '/Status',
                    'severity': ZenEventClasses.Error,
                })
            defer.returnValue(results)
 def collect(self, config):
     """
     This method overrides the HBaseBasePlugin.collect method.
     """
     results = self.new_data()
     for ds in config.datasources:
         self.component = ds.component
         headers = hbase_headers(accept='application/json',
                                 username=ds.zHBaseUsername,
                                 passwd=ds.zHBasePassword)
         url = hbase_rest_url(scheme=ds.zHBaseScheme,
                              port=ds.zHBaseRegionServerPort,
                              host=get_host(ds),
                              endpoint='/jmx')
         try:
             res = yield getPage(url, headers=headers)
             if not res:
                 raise HBaseException('No monitoring data.')
             results['values'][ds.component] = self.form_values(res, ds)
         except (Exception, HBaseException), e:
             e = check_error(e, ds.device) or e
             msg = "No access to page '{}': {}".format(url, e)
             results['events'].append({
                 'component': self.component,
                 'summary': str(e),
                 'message': msg,
                 'eventKey': 'hbase_monitoring_error',
                 'eventClass': '/Status',
                 'severity': ZenEventClasses.Error,
             })
             log.error(msg)
 def collect(self, config):
     """
     This method overrides the HBaseBasePlugin.collect method.
     """
     results = self.new_data()
     for ds in config.datasources:
         self.component = ds.component
         headers = hbase_headers(
             accept='application/json',
             username=ds.zHBaseUsername,
             passwd=ds.zHBasePassword
         )
         url = hbase_rest_url(
             scheme=ds.zHBaseScheme,
             port=ds.zHBaseRegionServerPort,
             host=get_host(ds),
             endpoint='/jmx'
         )
         try:
             res = yield getPage(url, headers=headers)
             if not res:
                 raise HBaseException('No monitoring data.')
             results['values'][ds.component] = self.form_values(res, ds)
         except (Exception, HBaseException), e:
             e = check_error(e, ds.device) or e
             msg = "No access to page '{}': {}".format(url, e)
             results['events'].append({
                 'component': self.component,
                 'summary': str(e),
                 'message': msg,
                 'eventKey': 'hbase_monitoring_error',
                 'eventClass': '/Status',
                 'severity': ZenEventClasses.Error,
             })
             log.error(msg)
 def collect(self, config):
     """
     This method overrides the HBaseBasePlugin.collect method.
     """
     results = self.new_data()
     for ds in config.datasources:
         self.component = ds.component
         headers = hbase_headers(
             accept='application/json',
             username=ds.zHBaseUsername,
             passwd=ds.zHBasePassword
         )
         url = hbase_rest_url(
             scheme=ds.zHBaseScheme,
             port=ds.zHBaseRegionServerPort,
             host=get_host(ds),
             endpoint='/dump'
         )
         try:
             res = yield getPage(url, headers=headers)
             if not res:
                 raise HBaseException('No monitoring data')
             results['maps'].extend(self.add_maps(res, ds))
         except (Exception, HBaseException), e:
             e = check_error(e, ds.device) or e
             log.error("No access to page '{}': {}".format(url, e))
示例#5
0
 def collect(self, config):
     """
     This method overrides the HBaseBasePlugin.collect method.
     """
     results = self.new_data()
     for ds in config.datasources:
         self.component = ds.component
         headers = hbase_headers(
             accept='application/json',
             username=ds.zHBaseUsername,
             passwd=ds.zHBasePassword
         )
         # Get compaction and state of the table.
         url = hbase_rest_url(
             scheme=ds.zHBaseScheme,
             port=ds.zHBaseMasterPort,
             host=ds.manageIp,
             endpoint=self.endpoint.format(self.component)
         )
         # Get column family information.
         schema_url = hbase_rest_url(
             scheme=ds.zHBaseScheme,
             port=ds.zHBaseRestPort,
             host=ds.manageIp,
             endpoint='/{}/schema'.format(self.component)
         )
         try:
             # Check connection and collect data.
             res = yield getPage(url, headers=headers)
             schema = yield getPage(schema_url, headers=headers)
             if not res:
                 raise HBaseException('No monitoring data.')
             # Process data if was returned.
             results['maps'].extend(self.add_maps(res, schema, ds))
             results['events'].extend(self.get_events(res, ds))
         except (Exception, HBaseException), e:
             if any(code in str(e) for code in ('404', '500')):
                 summary = "The table '{0}' is broken or does not " \
                     "exist".format(ds.component)
             else:
                 summary = str(check_error(e, ds.device) or e)
             results['events'].append({
                 'component': ds.component,
                 'summary': summary,
                 'eventKey': 'hbase_monitoring_error',
                 'eventClass': '/Status',
                 'severity': ZenEventClasses.Error,
             })
    def collect(self, device, log):
        log.debug("Collecting data for device %s", device.id)

        url = hbase_rest_url(
            scheme=device.zHBaseScheme,
            port=device.zHBaseRestPort,
            host=device.manageIp,
            endpoint='/'
        )
        headers = hbase_headers(
            accept='application/json',
            username=device.zHBaseUsername,
            passwd=device.zHBasePassword
        )
        res = getPage(url, headers=headers)
        res.addCallbacks(
            lambda r: self.on_success(log, device, r),
            lambda f: self.on_error(log, device, f)
        )
        return res
 def collect(self, config):
     """
     This method overrides the HBaseBasePlugin.collect method.
     """
     results = self.new_data()
     for ds in config.datasources:
         self.component = ds.component
         headers = hbase_headers(accept='application/json',
                                 username=ds.zHBaseUsername,
                                 passwd=ds.zHBasePassword)
         url = hbase_rest_url(scheme=ds.zHBaseScheme,
                              port=ds.zHBaseRegionServerPort,
                              host=get_host(ds),
                              endpoint='/dump')
         try:
             res = yield getPage(url, headers=headers)
             if not res:
                 raise HBaseException('No monitoring data')
             results['maps'].extend(self.add_maps(res, ds))
         except (Exception, HBaseException), e:
             e = check_error(e, ds.device) or e
             log.error("No access to page '{}': {}".format(url, e))
    def collect(self, config):
        """
        This method return a Twisted deferred. The deferred results will
        be sent to the onResult then either onSuccess or onError callbacks
        below.
        """
        results = self.new_data()
        res = ''

        ds0 = config.datasources[0]
        # Check the connection and collect data.
        url = hbase_rest_url(
            scheme=ds0.zHBaseScheme,
            port=ds0.zHBaseRestPort,
            host=ds0.manageIp,
            endpoint=self.endpoint
        )
        headers = hbase_headers(
            accept='application/json',
            username=ds0.zHBaseUsername,
            passwd=ds0.zHBasePassword
        )
        try:
            res = yield getPage(url, headers=headers)
            if not res:
                raise HBaseException('No monitoring data')
        except (Exception, HBaseException), e:
            # Send connection error event for each component.
            for ds in config.datasources:
                e = check_error(e, ds.device) or e
                results['events'].append({
                    'component': ds.component,
                    'summary': str(e),
                    'eventKey': 'hbase_monitoring_error',
                    'eventClass': '/Status',
                    'severity': ZenEventClasses.Error,
                })
            defer.returnValue(results)