Unit field missing in snmp data

Unit field is missing in snmp.yaml for hardware.cpu.*
metrics as result it is throwing Missing field unit
in the log files. Added unit as tick from looking
at the telemetry-measurements doc upstream.

Story: #2006287
Task: #35996
Change-Id: Id50bf64e2a69f7d5152040a6784b914dadf8d8d6
This commit is contained in:
Vinay Kapalavai 2019-07-26 15:22:42 -04:00
parent 28f0a70da9
commit 815726623d
2 changed files with 18 additions and 0 deletions

View File

@ -38,36 +38,43 @@ metric:
type: "int"
- name: hardware.cpu.user
unit: tick
snmp_inspector:
matching_type: "type_exact"
oid: "1.3.6.1.4.1.2021.11.50.0"
type: "int"
- name: hardware.cpu.nice
unit: tick
snmp_inspector:
matching_type: "type_exact"
oid: "1.3.6.1.4.1.2021.11.51.0"
type: "int"
- name: hardware.cpu.system
unit: tick
snmp_inspector:
matching_type: "type_exact"
oid: "1.3.6.1.4.1.2021.11.52.0"
type: "int"
- name: hardware.cpu.idle
unit: tick
snmp_inspector:
matching_type: "type_exact"
oid: "1.3.6.1.4.1.2021.11.53.0"
type: "int"
- name: hardware.cpu.wait
unit: tick
snmp_inspector:
matching_type: "type_exact"
oid: "1.3.6.1.4.1.2021.11.54.0"
type: "int"
- name: hardware.cpu.kernel
unit: tick
snmp_inspector:
matching_type: "type_exact"
oid: "1.3.6.1.4.1.2021.11.55.0"
type: "int"
- name: hardware.cpu.interrupt
unit: tick
snmp_inspector:
matching_type: "type_exact"
oid: "1.3.6.1.4.1.2021.11.56.0"

View File

@ -66,6 +66,17 @@ class TestMeterDefinition(test_base.BaseTestCase):
self.assertEqual("Unrecognized type value invalid",
e.brief_message)
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)
@mock.patch('ceilometer.hardware.pollsters.generic.LOG')
def test_bad_metric_skip(self, LOG):
cfg = {'metric': [dict(name='test1',