Replace the pyagentx threaded version with a much simpler, non-threaded version.

This commit is contained in:
Pim van Pelt
2021-09-11 12:19:38 +00:00
parent 842bce9d6e
commit 8c9c1e2b4a
13 changed files with 507 additions and 1089 deletions

57
agentx/dataset.py Normal file
View File

@ -0,0 +1,57 @@
#!/usr/bin/env python
# -*- coding: utf-8 -*-
from __future__ import (
absolute_import,
division,
print_function,
)
# --------------------------------------------
import logging
class NullHandler(logging.Handler):
def emit(self, record):
pass
logger = logging.getLogger('agentx.dataset')
logger.addHandler(NullHandler())
# --------------------------------------------
import time
import agentx
class DataSet():
def __init__(self):
self._data = {}
def set(self, oid, oid_type, value):
if oid_type.startswith('int'):
t = agentx.TYPE_INTEGER
elif oid_type.startswith('str'):
t = agentx.TYPE_OCTETSTRING
elif oid_type.startswith('oid'):
t = agentx.TYPE_OBJECTIDENTIFIER
elif oid_type.startswith('ip'):
t = agentx.TYPE_IPADDRESS
elif oid_type == 'counter32' or oid_type == 'uint32' or oid_type == 'u32':
t = agentx.TYPE_COUNTER32
elif oid_type == 'gauge32':
t = agentx.TYPE_GAUGE32
elif oid_type.startswith('time') or oid_type.startswith('tick'):
t = agentx.TYPE_TIMETICKS
elif oid_type.startswith('opaque'):
t = agentx.TYPE_OPAQUE
elif oid_type == 'counter64' or oid_type == 'uint64' or oid_type == 'u64':
t = agentx.TYPE_COUNTER64
else:
logger.error('Invalid oid_type: %s' % (oid_type))
return
self._data[oid] = {
'name': oid,
'type': t,
'value': value
}