much better now

This commit is contained in:
Wolfgang Hottgenroth 2025-02-20 22:54:08 +01:00
parent b3fdc82913
commit e660008d26

View File

@ -73,7 +73,7 @@ PEER_KEYS = [
['xmt', pyagentx3.TYPE_OCTETSTRING, pass_value],
['reach', pyagentx3.TYPE_INTEGER, pass_value],
['unreach', pyagentx3.TYPE_INTEGER, pass_value],
['delay-s', pyagentx3.TYPE_INTEGER, int_scale1k],
['delay-s', pyagentx3.TYPE_OCTETSTRING, pass_value],
['delay', pyagentx3.TYPE_INTEGER, int_scale1k],
['offset', pyagentx3.TYPE_INTEGER, int_scale1M],
['jitter', pyagentx3.TYPE_INTEGER, int_scale1M],
@ -155,10 +155,10 @@ class TestUpdater(pyagentx3.Updater):
class NtpsecDataUpdater(pyagentx3.Updater):
def update(self):
logger.warn('XXX')
with self.data_store as ds:
if ds.data:
try:
for index, data_spec in enumerate(LOCAL_SERVER_KEYS):
logger.debug(f"local: {index=}, {data_spec}")
CURRENT_NAME_OID_BASE = '0.' + str(index) + '.0'
CURRENT_VALUE_OID_BASE = '0.' + str(index) + '.1'
self._data[CURRENT_NAME_OID_BASE] = {
@ -172,9 +172,7 @@ class NtpsecDataUpdater(pyagentx3.Updater):
'value': data_spec[2](ds.data['local'][data_spec[0]])
}
for associd, peer in ds.data['peers'].items():
logger.debug(f"peer: {associd=}, {peer=}")
for index, data_spec in enumerate(PEER_KEYS):
logger.debug(f"peer: {associd=}, {index=}, {data_spec}")
CURRENT_NAME_OID_BASE = str(associd) + '.' + str(index) + '.0'
CURRENT_VALUE_OID_BASE = str(associd) + '.' + str(index) + '.1'
self._data[CURRENT_NAME_OID_BASE] = {
@ -185,9 +183,10 @@ class NtpsecDataUpdater(pyagentx3.Updater):
self._data[CURRENT_VALUE_OID_BASE] = {
'name': CURRENT_VALUE_OID_BASE,
'type': data_spec[1],
'value': data_spec[2](ds.data['local'][data_spec[0]])
'value': data_spec[2](peer[data_spec[0]])
}
logger.warn(f"YYY: {self._data=}")
except Exception as e:
logger.error(f"Failed to update: {type(e)} {e}")
@ -225,7 +224,7 @@ def daemonize(pid_filename):
os.dup2(log.fileno(), sys.stderr.fileno())
logger.removeHandler(stdout_handler)
pyagentx3.setup_logging(debug=True)
def set_user_group(user, group):
if group: