Ejemplo n.º 1
0
    def update_data(self):
        """
        Update redis (caches config)
        Pulls the table references for each interface.
        """
        self.oid_list = []
        self.oid_map = {}

        self.db_conn.connect(SNMP_OVERLAY_DB)
        keys = self.db_conn.keys(SNMP_OVERLAY_DB, self.prefix_str + '*')
        # TODO: fix db_conn.keys to return empty list instead of None if there is no match
        if keys is None:
            keys = []

        for key in keys:
            key = key.decode()
            oid = oid2tuple(key, dot_prefix=False)
            self.oid_list.append(oid)
            value = self.db_conn.get_all(SNMP_OVERLAY_DB, key)
            if value[b'type'] in [b'COUNTER_32', b'COUNTER_64']:
                self.oid_map[oid] = int(value[b'data'])
            else:
                raise ValueError("Invalid value type")

        self.oid_list.sort()
Ejemplo n.º 2
0
    def update_data(self):
        """
        Update redis (caches config)
        Pulls the table references for each interface.
        """
        self.oid_list = []
        self.oid_map = {}

        self.db_conn.connect(SNMP_OVERLAY_DB)
        keys = self.db_conn.keys(SNMP_OVERLAY_DB, self.prefix_str + '*')
        # TODO: fix db_conn.keys to return empty list instead of None if there is no match
        if keys is None:
            keys = []

        for key in keys:
            key = key.decode()
            oid = oid2tuple(key, dot_prefix=False)
            self.oid_list.append(oid)
            value = self.db_conn.get_all(SNMP_OVERLAY_DB, key)
            if value[b'type'] in [b'COUNTER_32', b'COUNTER_64']:
                self.oid_map[oid] = int(value[b'data'])
            else:
                raise ValueError("Invalid value type")

        self.oid_list.sort()