Linux Process Monitoring via UCD-SNMP-MIB

Please consider adding support for monitoring processes running on a Linux host using the UCD-SNMP-MIB. This is a widely accepted method to so this, and it part of the default build of the popular net-snmp package on most Linux operating systems.

The user must simply add process names to the snmpd.conf configuration on the Linux host, as such:

proc pacemakerd
proc drbd
proc nginx
proc master

NOTE: These names should be as reported by the ‘ps -e’ command - per SNMPD.CONF manual (reference: Manpage of SNMPD.CONF).

This will enable the snmpd daemon to check status of these processes and report it in the UCD-SNMP-MIB::prTable.

Once setup, walking that table is a simple matter and contains the relevant data for determining if a service is running or not:

[root@myhost snmp]# snmpwalk -v 3 -a SHA -A -u -x AES -X -l authPriv localhost UCD-SNMP-MIB::prTable
UCD-SNMP-MIB::prIndex.1 = INTEGER: 1
UCD-SNMP-MIB::prIndex.2 = INTEGER: 2
UCD-SNMP-MIB::prIndex.3 = INTEGER: 3
UCD-SNMP-MIB::prIndex.4 = INTEGER: 4
UCD-SNMP-MIB::prNames.1 = STRING: pacemakerd
UCD-SNMP-MIB::prNames.2 = STRING: drbd
UCD-SNMP-MIB::prNames.3 = STRING: nginx
UCD-SNMP-MIB::prNames.4 = STRING: master
UCD-SNMP-MIB::prMin.1 = INTEGER: 1
UCD-SNMP-MIB::prMin.2 = INTEGER: 1
UCD-SNMP-MIB::prMin.3 = INTEGER: 1
UCD-SNMP-MIB::prMin.4 = INTEGER: 1
UCD-SNMP-MIB::prMax.1 = INTEGER: 0
UCD-SNMP-MIB::prMax.2 = INTEGER: 0
UCD-SNMP-MIB::prMax.3 = INTEGER: 0
UCD-SNMP-MIB::prMax.4 = INTEGER: 0
UCD-SNMP-MIB::prCount.1 = INTEGER: 0
UCD-SNMP-MIB::prCount.2 = INTEGER: 0
UCD-SNMP-MIB::prCount.3 = INTEGER: 0
UCD-SNMP-MIB::prCount.4 = INTEGER: 1
UCD-SNMP-MIB::prErrorFlag.1 = INTEGER: error(1)
UCD-SNMP-MIB::prErrorFlag.2 = INTEGER: error(1)
UCD-SNMP-MIB::prErrorFlag.3 = INTEGER: error(1)
UCD-SNMP-MIB::prErrorFlag.4 = INTEGER: noError(0)
UCD-SNMP-MIB::prErrMessage.1 = STRING: No pacemakerd process running
UCD-SNMP-MIB::prErrMessage.2 = STRING: No drbd process running
UCD-SNMP-MIB::prErrMessage.3 = STRING: No nginx process running
UCD-SNMP-MIB::prErrMessage.4 = STRING:
UCD-SNMP-MIB::prErrFix.1 = INTEGER: noError(0)
UCD-SNMP-MIB::prErrFix.2 = INTEGER: noError(0)
UCD-SNMP-MIB::prErrFix.3 = INTEGER: noError(0)
UCD-SNMP-MIB::prErrFix.4 = INTEGER: noError(0)
UCD-SNMP-MIB::prErrFixCmd.1 = STRING:
UCD-SNMP-MIB::prErrFixCmd.2 = STRING:
UCD-SNMP-MIB::prErrFixCmd.3 = STRING:
UCD-SNMP-MIB::prErrFixCmd.4 = STRING:

In this example above, you can see that of the four (4) processes configured for monitoring, only the ‘master’ (postfix) process is actually running. LibreNMS could then alert on the ‘error’ status of the prErrorFlag OIDs to alert users that processes are failed on a host.

I know there are methods to do this with the LibreNMS agent or Nagios plugins, however, those are very heavy and configuration-intense methods to do simple process monitoring. For a system with distributed hosts across the globe, which are very numerous, adding an agent and additional firewall openings for new TCP ports is painful, especially when net-snmp has a super easy method to just do this directly over SNMP.

It would be wonderful if the processes configured for monitoring were ‘auto-discovered’. This could be done by simply walking the UCD-SNMP-MIB::prNames OID and discovering the names of the processes.