Nov 24th, 2020
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. # Extend SNMP
  2. extend script1 /etc/snmp/scripts/
  3. extend script2 /etc/snmp/scripts/
  4. 3. Restart SNMPD Service
  5. To apply configuration changes we need to restart “snmpd” service by running the following command:
  7. [mitch@node01 ~]$ sudo service snmpd restart
  8.  Stopping snmpd: [ OK ]
  9.  Starting snmpd: [ OK ]
  10. 4. Test it out
  11. After we’ve restarted SNMPD service we can proceed to run tests by manually triggering the scripts via “snmpget” command, where:
  13. “v2c” tells it to use Simple Network Management Protocol Version 2
  14. “geekpeek” is the configured community name (default is “public”) you can see in snmpd.conf file
  15. “localhost” is the host we are connecting to
  16. “script1” is the human readable name of the extended SNMP
  17. “STRING: X” tells us the output of the bash script which is X
  18. [mitch@node01 ~]$ snmpget -v2c -c geekpeek localhost 'NET-SNMP-EXTEND-MIB::nsExtendOutLine."script1".1'
  19. NET-SNMP-EXTEND-MIB::nsExtendOutLine."script1".1 = STRING: 1
  20. [mitch@node01 ~]$ snmpget -v2c -c geekpeek localhost 'NET-SNMP-EXTEND-MIB::nsExtendOutLine."script2".1'
  21. NET-SNMP-EXTEND-MIB::nsExtendOutLine."script2".1 = STRING: 2
  22. As we can see the “script1” output is “1” and the “script2” output is “2”, which in my case is ok and i confirmed normal operation of SNMP.
  24. 5. Get the OID
  25. There’s one more thing missing, to make this useful. To wrap things up we need to get the OID of these extended scripts and we can use this OID to make monitoring checks. To get the OIDs we need to run the “snmptranslate” command as you see below:
  27. [mitch@node01 ~]$ snmptranslate -On 'NET-SNMP-EXTEND-MIB::nsExtendOutput1Line."script1".1'
  28. .
  29. [mitch@node01 ~]$ snmptranslate -On 'NET-SNMP-EXTEND-MIB::nsExtendOutput1Line."script2".1'
  30. .
  31. Voila and we got the OIDs we can call via SNMP. What we get is the output of the scripts configured in snmpd.conf file. Told you it’s really easy to extend snmp.
RAW Paste Data