reorg of table format
This commit is contained in:
parent
9e8b4b097f
commit
0645e660b6
@ -17,6 +17,9 @@ import ipaddress
|
|||||||
BASE_OID_ENTERPRISE = '1.3.6.1.4.1'
|
BASE_OID_ENTERPRISE = '1.3.6.1.4.1'
|
||||||
BASE_OID_HOTTIS = BASE_OID_ENTERPRISE + '.9676'
|
BASE_OID_HOTTIS = BASE_OID_ENTERPRISE + '.9676'
|
||||||
BASE_OID_HOTTIS_NTPSEC = BASE_OID_HOTTIS + '.123'
|
BASE_OID_HOTTIS_NTPSEC = BASE_OID_HOTTIS + '.123'
|
||||||
|
LOCAL_PREFIX = '1'
|
||||||
|
PEERS_PREFIX = '2'
|
||||||
|
|
||||||
|
|
||||||
def int_scale1k(x):
|
def int_scale1k(x):
|
||||||
return int (x * 1000)
|
return int (x * 1000)
|
||||||
@ -159,33 +162,28 @@ class NtpsecDataUpdater(pyagentx3.Updater):
|
|||||||
with self.data_store as ds:
|
with self.data_store as ds:
|
||||||
if ds.data:
|
if ds.data:
|
||||||
try:
|
try:
|
||||||
for index, data_spec in enumerate(LOCAL_SERVER_KEYS):
|
|
||||||
|
for index, data_spec in enumerate(LOCAL_SERVER_KEYS, start=1):
|
||||||
logger.debug(f"local: {index=} {data_spec=}")
|
logger.debug(f"local: {index=} {data_spec=}")
|
||||||
CURRENT_NAME_OID_BASE = f"0.0.{index}"
|
oid_prefix = f"{LOCAL_PREFIX}.{index}"
|
||||||
CURRENT_VALUE_OID_BASE = f"0.1.{index}"
|
self._data[oid_prefix] = {
|
||||||
self._data[CURRENT_NAME_OID_BASE] = {
|
'name': oid_prefix,
|
||||||
'name': CURRENT_NAME_OID_BASE,
|
|
||||||
'type': pyagentx3.TYPE_OCTETSTRING,
|
|
||||||
'value': data_spec[0]
|
|
||||||
}
|
|
||||||
self._data[CURRENT_VALUE_OID_BASE] = {
|
|
||||||
'name': CURRENT_VALUE_OID_BASE,
|
|
||||||
'type': data_spec[1],
|
'type': data_spec[1],
|
||||||
'value': data_spec[2](ds.data['local'][data_spec[0]])
|
'value': data_spec[2](ds.data['local'][data_spec[0]])
|
||||||
}
|
}
|
||||||
for associd, peer in ds.data['peers'].items():
|
for peer_index, (associd, peer) in enumerate(ds.data['peers'].items(), start=1):
|
||||||
logger.debug(f"peer: {peer}")
|
logger.debug(f"peer: {peer}")
|
||||||
for index, data_spec in enumerate(PEER_KEYS):
|
index_oid_prefix = f"{PEERS_PREFIX}.1.{peer_index}"
|
||||||
logger.debug(f"peer: {associd=} {index=} {data_spec=}")
|
self._data[index_oid_prefix] = {
|
||||||
CURRENT_NAME_OID_BASE = str(associd) + '.' + str(index) + '.0'
|
'name': index_oid_prefix,
|
||||||
CURRENT_VALUE_OID_BASE = str(associd) + '.' + str(index) + '.1'
|
'type': pyagentx3.TYPE_INTEGER,
|
||||||
self._data[CURRENT_NAME_OID_BASE] = {
|
'value': associd
|
||||||
'name': CURRENT_NAME_OID_BASE,
|
|
||||||
'type': pyagentx3.TYPE_OCTETSTRING,
|
|
||||||
'value': data_spec[0]
|
|
||||||
}
|
}
|
||||||
self._data[CURRENT_VALUE_OID_BASE] = {
|
for key_index, data_spec in enumerate(PEER_KEYS, start=2):
|
||||||
'name': CURRENT_VALUE_OID_BASE,
|
logger.debug(f"peer: {associd=} {key_index=} {data_spec=}")
|
||||||
|
oid_prefix = f"{PEERS_PREFIX}.{key_index}.{peer_index}"
|
||||||
|
self._data[oid_prefix] = {
|
||||||
|
'name': oid_prefix,
|
||||||
'type': data_spec[1],
|
'type': data_spec[1],
|
||||||
'value': data_spec[2](peer[data_spec[0]])
|
'value': data_spec[2](peer[data_spec[0]])
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user