def add_maps(self, result, schema, ds): """ Return a list of ObjectMaps with properties updates for each table. """ schema = json.loads(schema) return [ObjectMap({ "compname": "hbase_tables/%s" % self.component, "modname": "HBase table state", "enabled": matcher(result, r'.+<td>Enabled</td><td>(\w+)</td>'), "compaction": matcher(result, r'.+<td>Compaction</td><td>(\w+)</td>'), "number_of_col_families": len(schema.get('ColumnSchema')), "col_family_block_size": _block_size(schema.get('ColumnSchema')), })]
def get_events(self, result, ds): """ Return a list of event dictionaries informing about the health of the table. """ enabled = matcher(result, r'.+<td>Enabled</td><td>(\w+)</td>') summary = 'Monitoring ok' if enabled != 'true': summary = "The table '{0}' is disabled".format(self.component) if not enabled: summary = "The table '{0}' is dropped".format(self.component) # Send error or clear event. severity = ((summary != 'Monitoring ok') and ZenEventClasses.Error or ZenEventClasses.Clear) return [{ 'component': self.component, 'summary': summary, 'eventKey': 'hbase_table_monitoring_error', 'eventClass': '/Status', 'severity': severity, }]