mk23 / snmpy

Extensible net-snmp agentx system.
MIT License
9 stars 7 forks source link

Collect cache_catalog_status from puppet's last_run_report, modify syslog logging, and Continue updating item beyond first failure #94

Closed QuirkyMarc closed 6 years ago

QuirkyMarc commented 6 years ago

Collecting cache_catalog_status seems obvious from the title. :)


For "Add program / pid to logging fmt for syslog logging", from the commit msg:

Without this, it is hard to find snmpy logging. Logged lines look like:

May 15 13:41:33 ps0123 init:27 - Thread-2 - starting background task: start_fetch May 15 13:41:33 ps0123 server:34 - MainThread - starting http server

Python's logging module '%(processName)s' didn't work, reporting "MainProcess" or "Process-#", such that similar log lines looked like:

May 16 11:16:41 ps0123 MainProcess[49672]: init:27 - Thread-2 - starting background task: start_fetch May 16 11:16:41 ps0123 Process-1[49673]: server:34 - MainThread - starting http server

So fixed format to 'snmpy', so the same log lines will look like:

May 16 11:21:00 ps0123 snmpy[49866]: init:27 - Thread-2 - starting background task: start_fetch May 16 11:21:00 ps0123 snmpy[49867]: server:34 - MainThread - starting http server


For "continue updating item beyond first failure", from the commit msg:

When updating snmp with items collected from a module, if there is a failure with a particular item, further updates for item collected successfully are not attempted.

Logs for that look like:

init:39 - Thread-14 - string expected instead of NoneType instance init:42 - Thread-14 - Traceback (most recent call last): init:42 - Thread-14 - File "/usr/lib/python2.7/dist-packages/snmpy/server.py", line 50, in start_fetch init:42 - Thread-14 - self.commit_data(mod) init:42 - Thread-14 - File "/usr/lib/python2.7/dist-packages/snmpy/server.py", line 65, in commit_data init:42 - Thread-14 - self.snmp.replace_value(mod[item].oidstr, mod[item].value) init:42 - Thread-14 - File "/usr/lib/python2.7/dist-packages/snmpy/agentx.py", line 522, in replace_value init:42 - Thread-14 - self.data[oid].set_value(val) init:42 - Thread-14 - File "/usr/lib/python2.7/dist-packages/snmpy/agentx.py", line 367, in set_value init:42 - Thread-14 - self._data.value = data init:42 - Thread-14 - TypeError: string expected instead of NoneType instance

Change to code here tests if value is NoneType, and if so, logs a warning message like:

server:66 - Thread-14 - item 'cached_catalog_status' doesn't have a value, ignoring

and continues updating the rest of the items.