Exemplo n.º 1
0
 def test_config_definition(self):
     cfg = dict(name='test', type='gauge', unit='B', snmp_inspector={})
     definition = generic.MeterDefinition(cfg)
     self.assertEqual('test', definition.name)
     self.assertEqual('gauge', definition.type)
     self.assertEqual('B', definition.unit)
     self.assertEqual({}, definition.snmp_inspector)
Exemplo n.º 2
0
 def test_config_invalid_type_field(self):
     cfg = dict(name='test', type='invalid', unit='B', snmp_inspector={})
     try:
         generic.MeterDefinition(cfg)
     except declarative.MeterDefinitionException as e:
         self.assertEqual("Unrecognized type value invalid",
                          e.brief_message)
Exemplo n.º 3
0
 def test_config_invalid_field(self):
     cfg = dict(name='test',
                type='gauge',
                unit='B',
                invalid={})
     definition = generic.MeterDefinition(cfg)
     self.assertEqual("foobar", getattr(definition, 'invalid', 'foobar'))
Exemplo n.º 4
0
 def test_config_missing_unit_field(self):
     cfg = dict(name='hardware.cpu.user',
                snmp_inspector={
                    "matching_type": "type_exact",
                    "oid": "1.3.6.1.4.1.2021.11.50.0",
                    "type": "int"
                })
     try:
         generic.MeterDefinition(cfg)
     except declarative.MeterDefinitionException as e:
         self.assertEqual("Missing field unit", e.brief_message)
Exemplo n.º 5
0
 def test_get_samples(self):
     param = dict(matching_type='type_exact',
                  oid='1.3.6.1.4.1.2021.10.1.3.1',
                  type='lambda x: float(str(x))')
     meter_def = generic.MeterDefinition(dict(type='gauge',
                                              name='hardware.test1',
                                              unit='process',
                                              snmp_inspector=param))
     self._check_get_samples('hardware.test1',
                             meter_def,
                             0.99, sample.TYPE_GAUGE,
                             expected_unit='process')
Exemplo n.º 6
0
 def test_config_missing_field(self):
     cfg = dict(name='test', type='gauge')
     try:
         generic.MeterDefinition(cfg)
     except generic.MeterDefinitionException as e:
         self.assertEqual("Missing field unit", e.message)
Exemplo n.º 7
0
    def __init__(self):
        super(BaseNIOSPollster, self).__init__()

        meter = generic.MeterDefinition(self.meter_dict)
        self._update_meter_definition(meter)