Add interfaces

This commit is contained in:
Vitaliy Skrypnyk
2020-07-28 19:52:07 +03:00
committed by Vitaliy Skrypnyk
parent ab8426f893
commit 9f0a28896b
2 changed files with 23 additions and 3 deletions

View File

@@ -43,6 +43,23 @@
"speed": "$.speed" "speed": "$.speed"
} }
}, },
{
"command": "interface",
"root" : "$.*",
"tags" : {
"id": "$.id",
"type": "$.type",
"description": "$.description",
"interface-name": "$.interface-name",
"state": "$.state",
"address": "$.address"
},
"values" : {
"mtu": "$.mtu",
"uptime": "$.uptime",
"tx-queue": "$.tx-queue"
}
},
{ {
"command": "ip nat", "command": "ip nat",
"root" : "$.[*]", "root" : "$.[*]",

View File

@@ -44,12 +44,15 @@ class KeeneticCollector(object):
for tagName, tagPath in self._tags.items(): for tagName, tagPath in self._tags.items():
if tagPath == '~': if tagPath == '~':
tags[tagName] = str(root.path.fields[0]) tags[tagName] = root.path.fields[0]
else: else:
tags[tagName] = str(self.get_first_value(tagPath.find(root.value))) tags[tagName] = self.get_first_value(tagPath.find(root.value))
for valueName, valuePath in self._values.items(): for valueName, valuePath in self._values.items():
values[valueName] = normalize_value(self.get_first_value(valuePath.find(root.value))) value = self.get_first_value(valuePath.find(root.value))
if value is not None: values[valueName] = normalize_value(value)
if values.__len__() == 0: continue
metric = self.create_metric(self._command, tags, values) metric = self.create_metric(self._command, tags, values)
metrics.append(metric) metrics.append(metric)