def test_add_maps(self):
     data = load_data("HBaseTableStatus.txt")
     schema = load_data("HBaseTableColumnFamily.json")
     self.plugin.component = sentinel.component
     result = self.plugin.add_maps(data, schema, sentinel.ds)
     om = result[0]
     self.assertEquals(om.compname, "hbase_tables/sentinel.component")
     self.assertEquals(om.modname, "HBase table state")
     self.assertEquals(om.enabled, "false")
     self.assertEquals(om.compaction, "")
     self.assertEquals(om.number_of_col_families, 2)
     self.assertEquals(om.col_family_block_size, "colfam1: 640.0KB; colfam2: 612.0B")
예제 #2
0
 def test_add_maps(self):
     data = load_data('HBaseTableStatus.txt')
     schema = load_data('HBaseTableColumnFamily.json')
     self.plugin.component = sentinel.component
     result = self.plugin.add_maps(data, schema, sentinel.ds)
     om = result[0]
     self.assertEquals(om.compname, 'hbase_tables/sentinel.component')
     self.assertEquals(om.modname, 'HBase table state')
     self.assertEquals(om.enabled, 'false')
     self.assertEquals(om.compaction, '')
     self.assertEquals(om.number_of_col_families, 2)
     self.assertEquals(
         om.col_family_block_size, 'colfam1: 640.0KB; colfam2: 612.0B')
 def test_get_events(self):
     data = load_data("HBaseCollector.json")
     self.plugin.component = "localhost_11111"
     ds = Mock()
     ds.component = sentinel.component
     ds.regionserver_ids = []
     result = self.plugin.get_events(data, ds)
     # Check event for dead server.
     self.assertIn(
         {
             "eventClass": "/Status",
             "component": "localhost_11111",
             "eventKey": "hbase_regionserver_monitoring_error",
             "severity": 4,
             "summary": "Region server 'localhost:11111' is dead",
         },
         result,
     )
     # Check clear event for dead server.
     self.plugin.component = "localhost_44451"
     self.assertIn(
         {
             "eventClass": "/Status",
             "component": "localhost_44451",
             "eventKey": "hbase_regionserver_monitoring_error",
             "severity": 0,
             "summary": "Region server 'localhost:44451' is dead",
         },
         self.plugin.get_events(data, ds),
     )
예제 #4
0
 def test_get_events(self):
     data = load_data('HBaseCollector.json')
     self.plugin.component = 'localhost_11111'
     ds = Mock()
     ds.component = sentinel.component
     ds.regionserver_ids = ['test']
     ds.region_ids = ['test']
     self.plugin.process(data)
     self.plugin.add_maps(data, ds)
     result = self.plugin.get_events(data, ds)
     # Check event for added server.
     self.assertIn({
         'eventClass': '/Status',
         # 'component': 'localhost_44451',
         'severity': 2,
         'summary': "Region server 'localhost:44451' is added"
     }, result)
     # Check event for removed server.
     ds.regionserver_ids = ['localhost_11111', 'test']
     self.plugin.add_maps(data, ds)
     self.assertIn({
         'eventClass': '/Status',
         'severity': 2,
         'summary': "Region server 'test' is removed"
     }, self.plugin.get_events(data, ds))
 def test_get_events(self):
     data = load_data("HBaseCollector.json")
     self.plugin.component = "localhost_11111"
     ds = Mock()
     ds.component = sentinel.component
     ds.regionserver_ids = ["test"]
     ds.region_ids = ["test"]
     self.plugin.process(data)
     self.plugin.add_maps(data, ds)
     result = self.plugin.get_events(data, ds)
     # Check event for added server.
     self.assertIn(
         {
             "eventClass": "/Status",
             # 'component': 'localhost_44451',
             "severity": 2,
             "summary": "Region server 'localhost:44451' is added",
         },
         result,
     )
     # Check event for removed server.
     ds.regionserver_ids = ["localhost_11111", "test"]
     self.plugin.add_maps(data, ds)
     self.assertIn(
         {"eventClass": "/Status", "severity": 2, "summary": "Region server 'test' is removed"},
         self.plugin.get_events(data, ds),
     )
예제 #6
0
 def test_process(self):
     data = load_data('HBaseCollector.json')
     result = self.plugin.process(data)
     self.assertEquals(result.get('average_load'), (2.0, 'N'))
     self.assertEquals(result.get('live_servers'), (1, 'N'))
     self.assertEquals(result.get('percent_dead_servers'), (50.0, 'N'))
     self.assertEquals(result.get('requests_per_second'), (0, 'N'))
     self.assertEquals(result.get('dead_servers'), (1, 'N'))
     self.assertEquals(result.get('regions'), (2, 'N'))
 def test_process(self):
     data = load_data("HBaseCollector.json")
     result = self.plugin.process(data)
     self.assertEquals(result.get("average_load"), (2.0, "N"))
     self.assertEquals(result.get("live_servers"), (1, "N"))
     self.assertEquals(result.get("percent_dead_servers"), (50.0, "N"))
     self.assertEquals(result.get("requests_per_second"), (0, "N"))
     self.assertEquals(result.get("dead_servers"), (1, "N"))
     self.assertEquals(result.get("regions"), (2, "N"))
    def _loadZenossData(self):
        if hasattr(self, '_loaded'):
            return

        modeler = HBaseCollector()
        modeler_results = dict(status=load_data('HBaseCollector.json'),
                               conf=None)

        for data_map in modeler.process(self.d, modeler_results, log):
            self.applyDataMap(self.d, data_map)

        tab_modeler = HBaseTableCollector()
        tab_modeler_results = load_data('HBaseTableCollector.json')

        for data_map in tab_modeler.process(self.d, tab_modeler_results, log):
            self.applyDataMap(self.d, data_map)

        self._loaded = True
    def _loadZenossData(self):
        if hasattr(self, '_loaded'):
            return

        modeler = HBaseCollector()
        modeler_results = dict(
            status=load_data('HBaseCollector.json'),
            conf=None
        )

        for data_map in modeler.process(self.d, modeler_results, log):
            self.applyDataMap(self.d, data_map)

        tab_modeler = HBaseTableCollector()
        tab_modeler_results = load_data('HBaseTableCollector.json')

        for data_map in tab_modeler.process(self.d, tab_modeler_results, log):
            self.applyDataMap(self.d, data_map)

        self._loaded = True
예제 #10
0
 def test_get_events_clear(self):
     data = load_data('HBaseTableEnabledStatus.txt')
     self.plugin.component = sentinel.component
     result = self.plugin.get_events(data, sentinel.ds)
     self.assertIn({
         'severity': 0,
         'eventClass': '/Status',
         'component': sentinel.component,
         'eventKey': 'hbase_table_monitoring_error',
         'summary': "Monitoring ok"
     }, result)
예제 #11
0
 def test_process(self):
     data = load_data("HBaseCollector.json")
     self.plugin.component = "{0}{1}{2}".format("localhost_44451", NAME_SPLITTER, "LVJPT1QtLCww")
     result = self.plugin.process(data)
     self.assertEquals(result.get("memstore_size_mb"), (0, "N"))
     self.assertEquals(result.get("number_of_store_files"), (1, "N"))
     self.assertEquals(result.get("read_requests"), (9, "N"))
     self.assertEquals(result.get("current_compacted_kv"), (8, "N"))
     self.assertEquals(result.get("total_compacting_kv"), (8, "N"))
     self.assertEquals(result.get("number_of_stores"), (1, "N"))
     self.assertEquals(result.get("store_file_index_size_mb"), (0, "N"))
     self.assertEquals(result.get("store_file_size_mb"), (0, "N"))
     self.assertEquals(result.get("write_requests"), (1, "N"))
예제 #12
0
 def test_process(self):
     data = load_data('HBaseCollector.json')
     self.plugin.component = '{0}{1}{2}'.format(
         'localhost_44451', NAME_SPLITTER, 'LVJPT1QtLCww')
     result = self.plugin.process(data)
     self.assertEquals(result.get('memstore_size_mb'), (0, 'N'))
     self.assertEquals(result.get('number_of_store_files'), (1, 'N'))
     self.assertEquals(result.get('read_requests'), (9, 'N'))
     self.assertEquals(result.get('current_compacted_kv'), (8, 'N'))
     self.assertEquals(result.get('total_compacting_kv'), (8, 'N'))
     self.assertEquals(result.get('number_of_stores'), (1, 'N'))
     self.assertEquals(result.get('store_file_index_size_mb'), (0, 'N'))
     self.assertEquals(result.get('store_file_size_mb'), (0, 'N'))
     self.assertEquals(result.get('write_requests'), (1, 'N'))
예제 #13
0
 def test_get_events_clear(self):
     data = load_data("HBaseTableEnabledStatus.txt")
     self.plugin.component = sentinel.component
     result = self.plugin.get_events(data, sentinel.ds)
     self.assertIn(
         {
             "severity": 0,
             "eventClass": "/Status",
             "component": sentinel.component,
             "eventKey": "hbase_table_monitoring_error",
             "summary": "Monitoring ok",
         },
         result,
     )
예제 #14
0
 def test_get_events(self):
     data = load_data("HBaseTableStatus.txt")
     self.plugin.component = sentinel.component
     result = self.plugin.get_events(data, sentinel.ds)
     self.assertIn(
         {
             "severity": 4,
             "eventClass": "/Status",
             "component": sentinel.component,
             "eventKey": "hbase_table_monitoring_error",
             "summary": "The table 'sentinel.component' is disabled",
         },
         result,
     )
예제 #15
0
 def test_process(self):
     data = load_data("HBaseCollector.json")
     self.plugin.component = "localhost_44451"
     result = self.plugin.process(data)
     self.assertEquals(result.get("max_heap_mb"), (997, "N"))
     self.assertEquals(result.get("memstore_size_mb"), (0, "N"))
     self.assertEquals(result.get("number_of_store_files"), (1, "N"))
     self.assertEquals(result.get("read_requests"), (9, "N"))
     self.assertEquals(result.get("current_compacted_kv"), (8, "N"))
     self.assertEquals(result.get("total_compacting_kv"), (8, "N"))
     self.assertEquals(result.get("used_heap_mb"), (26, "N"))
     self.assertEquals(result.get("number_of_stores"), (1, "N"))
     self.assertEquals(result.get("store_file_index_size_mb"), (0, "N"))
     self.assertEquals(result.get("store_file_size_mb"), (0, "N"))
     self.assertEquals(result.get("write_requests"), (1, "N"))
예제 #16
0
 def test_process(self):
     data = load_data('HBaseCollector.json')
     self.plugin.component = 'localhost_44451'
     result = self.plugin.process(data)
     self.assertEquals(result.get('max_heap_mb'), (997, 'N'))
     self.assertEquals(result.get('memstore_size_mb'), (0, 'N'))
     self.assertEquals(result.get('number_of_store_files'), (1, 'N'))
     self.assertEquals(result.get('read_requests'), (9, 'N'))
     self.assertEquals(result.get('current_compacted_kv'), (8, 'N'))
     self.assertEquals(result.get('total_compacting_kv'), (8, 'N'))
     self.assertEquals(result.get('used_heap_mb'), (26, 'N'))
     self.assertEquals(result.get('number_of_stores'), (1, 'N'))
     self.assertEquals(result.get('store_file_index_size_mb'), (0, 'N'))
     self.assertEquals(result.get('store_file_size_mb'), (0, 'N'))
     self.assertEquals(result.get('write_requests'), (1, 'N'))
예제 #17
0
 def test_get_events(self):
     data = load_data('HBaseCollector.json')
     self.plugin.component = 'localhost_11111'
     ds = Mock()
     ds.component = sentinel.component
     ds.regionserver_ids = []
     result = self.plugin.get_events(data, ds)
     # Check event for dead server.
     self.assertIn({
         'eventClass': '/Status',
         'component': 'localhost_11111',
         'eventKey': 'hbase_regionserver_monitoring_error',
         'severity': 4,
         'summary': "Region server 'localhost:11111' is dead"
     }, result)
     # Check clear event for dead server.
     self.plugin.component = 'localhost_44451'
     self.assertIn({
         'eventClass': '/Status',
         'component': 'localhost_44451',
         'eventKey': 'hbase_regionserver_monitoring_error',
         'severity': 0,
         'summary': "Region server 'localhost:44451' is dead"
     }, self.plugin.get_events(data, ds))
예제 #18
0
 def test_add_maps(self):
     data = load_data("HBaseCollector.json")
     result = self.plugin.add_maps(data, sentinel.ds)
     self.assertEquals(result, [])
예제 #19
0
 def test_add_maps(self):
     data = load_data('HBaseCollector.json')
     result = self.plugin.add_maps(data, sentinel.ds)
     self.assertEquals(result, [])