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