From f241128b429f725f4f4da893c7d2cb0e4373e77a Mon Sep 17 00:00:00 2001 From: Mattias Andrée Date: Mon, 3 Oct 2016 12:51:00 +0200 Subject: snmp, snmp6: add keys MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Mattias Andrée --- src/plugins/snmp.py | 7 ++++++- src/plugins/snmp6.py | 4 ++++ 2 files changed, 10 insertions(+), 1 deletion(-) diff --git a/src/plugins/snmp.py b/src/plugins/snmp.py index a52cb4e..90e7554 100644 --- a/src/plugins/snmp.py +++ b/src/plugins/snmp.py @@ -23,6 +23,8 @@ from util import * class SNMP: ''' IPv4 SNMP data + + @variable keys:list List of avaiable keys ''' @@ -44,10 +46,13 @@ class SNMP: snmp = zip(snmp_h, snmp_d) self.__info = {} + self.keys = [] for header_list, data_list in snmp: prefix = header_list[0][:-1] for suffix, value in zip(header_list[1:], data_list[1:]): - self.__info[prefix + suffix] = int(value) + key = prefix + suffix + self.__info[key] = int(value) + self.keys.append(key) def __contains__(self, key): diff --git a/src/plugins/snmp6.py b/src/plugins/snmp6.py index afe6de6..bd2ce1c 100644 --- a/src/plugins/snmp6.py +++ b/src/plugins/snmp6.py @@ -23,6 +23,8 @@ from util import * class SNMP6: ''' IPv6 SNMP data + + @variable keys:list List of avaiable keys ''' @@ -38,8 +40,10 @@ class SNMP6: snmp6 = map(lambda x : filter_(x.split(' ')), filter_(snmp6.split('\n'))) self.__info = {} + self.keys = [] for field, value in snmp6: self.__info[field] = int(value) + self.keys.append(field) def __contains__(self, key): -- cgit v1.2.3-70-g09d2