def report_stats(self, instance): for metric_item in self.get_metric_list(): boundary_name, oid, accumulate = metric_item[:3] value = self.snmp_get_first_row_value(instance, oid) if accumulate: value = self.accumulator.accumulate(boundary_name, value) boundary_plugin.boundary_report_metric(self.boundary_metric_prefix + boundary_name, value, source=instance['source_name'])
def handle_metrics(self, data): for metric_item in self.get_metric_list(): riak_name, boundary_name, scale = metric_item[:3] if not data.has_key(riak_name): # If certain Riak features are disabled (e.g. search), their data might # not be available - simply skip those metrics. continue if scale: data[riak_name] *= scale boundary_plugin.boundary_report_metric(self.boundary_metric_prefix + boundary_name, data[riak_name])
def handle_metrics(self, data): for metric_item in self.get_metric_list(): riak_name, boundary_name, scale = metric_item[:3] if not data.has_key(riak_name): # If certain Riak features are disabled (e.g. search), their data might # not be available - simply skip those metrics. continue if scale: data[riak_name] *= scale boundary_plugin.boundary_report_metric( self.boundary_metric_prefix + boundary_name, data[riak_name])
def handle_metrics(self, data): for metric_item in self.get_metric_list(): category_name, metric_name, boundary_name, accumulate = metric_item[:4] metric_data = data.get(category_name, {}).get(metric_name, None) if not metric_data or not metric_data.get('current'): # If certain metrics do not exist or have no value # (e.g. disabled in the CouchDB server or just inactive) - skip them. continue if accumulate: value = self.accumulator.accumulate((category_name, metric_name), metric_data['current']) else: value = metric_data['current'] boundary_plugin.boundary_report_metric(self.boundary_metric_prefix + boundary_name, value)
def handle_metrics(self, data, instance_name): for metric_item in self.get_metric_list(): metric_name, boundary_name, accumulate = metric_item[:3] metric_data = data.get(metric_name, {}).get('value', None) if not metric_data: # If certain metrics do not exist or have no value # (e.g. disabled in the server or just inactive) - skip them. continue if accumulate: value = self.accumulator.accumulate(metric_name, metric_data) else: value = metric_data boundary_plugin.boundary_report_metric(self.boundary_metric_prefix + boundary_name, value, source=instance_name)
def handle_metrics(self, data): for boundary_name, accumulate in METRICS: metric_name = boundary_name.lower() try: value = data[boundary_name.lower()].strip() except KeyError: value = None if not value: continue if accumulate: value = self.accumulator.accumulate(metric_name, int(value) ) boundary_plugin.boundary_report_metric(self.boundary_metric_prefix + boundary_name, value)
def handle_metrics(self, data, instance_name): for metric_item in self.get_metric_list(): metric_name, boundary_name, accumulate = metric_item[:3] metric_data = data.get(metric_name, {}).get('value', None) if not metric_data: # If certain metrics do not exist or have no value # (e.g. disabled in the server or just inactive) - skip them. continue if accumulate: value = self.accumulator.accumulate(metric_name, metric_data) else: value = metric_data boundary_plugin.boundary_report_metric( self.boundary_metric_prefix + boundary_name, value, source=instance_name)
def handle_metrics(self, data): for boundary_name, accumulate in METRICS: metric_name = boundary_name.lower() try: value = data[boundary_name.lower()].strip() except KeyError: value = None if not value: continue if accumulate: value = self.accumulator.accumulate(metric_name, int(value)) boundary_plugin.boundary_report_metric( self.boundary_metric_prefix + boundary_name, value)
def handle_metric_list(self, metric_list, data, source): for metric_item in metric_list: boundary_name, metric_name, accumulate = metric_item[:3] scale = metric_item[3] if len(metric_item) >= 4 else None metric_data = data.get(metric_name, None) if not metric_data: # If certain metrics do not exist or have no value # (e.g. disabled in the server or just inactive) - skip them. continue if scale: metric_data = float(metric_data) * scale if accumulate: value = self.accumulator.accumulate(source + '_' + metric_name, float(metric_data)) else: value = metric_data boundary_plugin.boundary_report_metric(self.boundary_metric_prefix + boundary_name, value, source)
def handle_metrics(self, data): for metric_item in self.get_metric_list(): category_name, metric_name, boundary_name, accumulate = metric_item[: 4] metric_data = data.get(category_name, {}).get(metric_name, None) if not metric_data or not metric_data.get('current'): # If certain metrics do not exist or have no value # (e.g. disabled in the CouchDB server or just inactive) - skip them. continue if accumulate: value = self.accumulator.accumulate( (category_name, metric_name), metric_data['current']) else: value = metric_data['current'] boundary_plugin.boundary_report_metric( self.boundary_metric_prefix + boundary_name, value)
def handle_metric_for_caches(self, data): for metric_path, boundary_name, accumulate in MBEANS_KEY_MAPPING: value = data try: for p in metric_path: value = value[p] except KeyError: value = None if not value: continue if accumulate: value = self.accumulator.accumulate(metric_path, value) boundary_plugin.boundary_report_metric(self.boundary_metric_prefix + boundary_name, value)
def handle_metric_for_caches(self, data): for metric_path, boundary_name, accumulate in MBEANS_KEY_MAPPING: value = data try: for p in metric_path: value = value[p] except KeyError: value = None if not value: continue if accumulate: value = self.accumulator.accumulate(metric_path, value) boundary_plugin.boundary_report_metric( self.boundary_metric_prefix + boundary_name, value)
def handle_metrics(self, data): for metric_path, boundary_name, accumulate in self.get_metric_list(): value = data try: for p in metric_path: value = value[p] except KeyError: value = None if not value: # If certain metrics do not exist or have no value # (e.g. disabled in the CouchDB server or just inactive) - skip them. continue if accumulate: value = self.accumulator.accumulate(metric_path, value) # Exception case for the 'status' metric, which is 'green' iff the cluster is in good shape. if metric_path == ['status']: value = 1 if value == 'green' else 0 boundary_plugin.boundary_report_metric(self.boundary_metric_prefix + boundary_name, value)
def handle_metrics(self, data): for metric_path, boundary_name, accumulate in self.get_metric_list(): value = data try: for p in metric_path: value = value[p] except KeyError: value = None if not value: # If certain metrics do not exist or have no value # (e.g. disabled in the CouchDB server or just inactive) - skip them. continue if accumulate: value = self.accumulator.accumulate(metric_path, value) # Exception case for the 'status' metric, which is 'green' iff the cluster is in good shape. if metric_path == ['status']: value = 1 if value == 'green' else 0 boundary_plugin.boundary_report_metric( self.boundary_metric_prefix + boundary_name, value)
except KeyError: old_value = new_value diff = new_value - old_value _accum[stat_name] = new_value return diff # List of values returned from Redis' info call to report to Boundary. # Each value has a boolean specifying whether to aggregate data (i.e. report # only delta from the previous value) or report the metric as-is. values_to_report = ( ('connected_clients', False), ('keyspace_hits', True), ('keyspace_misses', True), ('expired_keys', True), ('evicted_keys', True), ('total_commands_processed', True), ('total_connections_received', True), ('used_memory_rss', False), ) while True: info = r.info() for v, aggregate in values_to_report: val = accum(v, info[v]) if aggregate else info[v] boundary_plugin.boundary_report_metric('REDIS_' + v.upper(), val) boundary_plugin.sleep_interval()
except KeyError: old_value = new_value diff = new_value - old_value _accum[stat_name] = new_value return diff # List of values returned from Redis' info call to report to Boundary. # Each value has a boolean specifying whether to aggregate data (i.e. report # only delta from the previous value) or report the metric as-is. values_to_report = ( ('connected_clients', False), ('keyspace_hits', True), ('keyspace_misses', True), ('expired_keys', True), ('evicted_keys', True), ('total_commands_processed', True), ('total_connections_received', True), ('used_memory_rss', False), ) while True: info = r.info() for v,aggregate in values_to_report: val = accum(v, info[v]) if aggregate else info[v] boundary_plugin.boundary_report_metric('REDIS_' + v.upper(), val) boundary_plugin.sleep_interval()