1

Asked this already in server fault (https://serverfault.com/questions/934468/how-to-monitor-systemd-service-with-snmp) but got no answer so I'm trying it here since I want to retrieve the status with the pysnmp library in python.

So I have a Gunicorn service on my Ubuntu server.

First I added proc gunicorn to this file: /etc/snmp/snmpd.conf. But I'm not sure how to get the right values.

I've seen this question (How to monitor services with SNMP?) and tried this command snmpwalk -v 2c -c public localhost 1.3.6.1.2.1.25.4.2.1.2 to get the status of the service, but I got this message:

HOST-RESOURCES-MIB::hrSWRunName = No more variables left in this MIB View (It is past the end of the MIB tree)

So I guess the OID is wrong or I have other configurations.

But I also found this answer here (https://stackoverflow.com/a/44496076/5549711).
So I think all I need is the OID of the service and then it should get me the value.

from pysnmp.hlapi import *

for (errorIndication,
     errorStatus,
     errorIndex,
     varBinds) in nextCmd(SnmpEngine(),
                          CommunityData('public', mpModel=0),
                          UdpTransportTarget(('demo.snmplabs.com', 161)),
                          ContextData(),
                          ObjectType(ObjectIdentity('1.3.6.1.2.1.17.7.1.2.2.1.2'))):
    if errorIndication or errorStatus:
        print(errorIndication or errorStatus)
        break
    else:
        for varBind in varBinds:
            print(' = '.join([x.prettyPrint() for x in varBind]))  

How do I get the OID of my Gunicorn service?

Alex
  • 491
  • 2
  • 10
  • 25
  • 1
    It sounds like you first need to set up your snmpd in a way that it will keep an eye on the `gunicorn` process and report the outcome as a new OID (perhaps within some SNMP table). So I'd first focus on snmpd configuration for process monitoring. – Ilya Etingof Oct 09 '18 at 09:10
  • @IlyaEtingof And how do I create a new SNMP table and configure it so it will watch the `gunicorn` process? – Alex Oct 09 '18 at 12:17

1 Answers1

0

did you extend your snmp.conf file. for example;

pass .1.3.6.1.4.1.1023.1.2.1 /bin/bash /etc/snmp/exampleScript.sh

  • Your answer could be improved with additional supporting information. Please [edit] to add further details, such as citations or documentation, so that others can confirm that your answer is correct. You can find more information on how to write good answers [in the help center](/help/how-to-answer). – Community May 29 '23 at 14:08