Difference between revisions of "snmp-extend to run custom script"

From cpwiki.net
Jump to: navigation, search
Check Point Profressional Services
(Created page with "1) Create a script/command that monitors something on your system and output the result to stdout. <br>example <br>script: /usr/local/bin/check_everything.sh <br>outputs eit...")
 
 
Line 7: Line 7:
 
<br>STATUS: NOT OK!
 
<br>STATUS: NOT OK!
  
2) Create entry in the SNMP config to monitor the script:
+
2) Create entry in the SNMP config to the monitor script:
 
  # vi /etc/snmp/userDefinedSettings.conf
 
  # vi /etc/snmp/userDefinedSettings.conf
  

Latest revision as of 02:31, 21 April 2021

1) Create a script/command that monitors something on your system and output the result to stdout.
example
script: /usr/local/bin/check_everything.sh
outputs either...
STATUS: OK - everything good
or
STATUS: NOT OK!

2) Create entry in the SNMP config to the monitor script:

# vi /etc/snmp/userDefinedSettings.conf

add a line...

extend everything_status /bin/sh /usr/local/bin/check_everything.sh

3) restart snmpd

from clish, run "set snmp agent off" then run "set snmp agent on"

4) test it

with a walk

$ snmpwalk -On -v2c -c mycomstring 192.168.1.1 NET-SNMP-EXTEND-MIB::nsExtendObjects
.1.3.6.1.4.1.8072.1.3.2.1.0 = INTEGER: 1
.1.3.6.1.4.1.8072.1.3.2.2.1.2.15.102.119.112.111.108.105.99.121.95.115.116.97.116.117.115 = STRING: /bin/sh
.1.3.6.1.4.1.8072.1.3.2.2.1.3.15.102.119.112.111.108.105.99.121.95.115.116.97.116.117.115 = STRING: 
/usr/local/bin/check_everything.sh
.1.3.6.1.4.1.8072.1.3.2.2.1.4.15.102.119.112.111.108.105.99.121.95.115.116.97.116.117.115 = STRING: 
.1.3.6.1.4.1.8072.1.3.2.2.1.5.15.102.119.112.111.108.105.99.121.95.115.116.97.116.117.115 = INTEGER: 5
.1.3.6.1.4.1.8072.1.3.2.2.1.6.15.102.119.112.111.108.105.99.121.95.115.116.97.116.117.115 = INTEGER: exec(1)
.1.3.6.1.4.1.8072.1.3.2.2.1.7.15.102.119.112.111.108.105.99.121.95.115.116.97.116.117.115 = INTEGER: run-on-read(1)
.1.3.6.1.4.1.8072.1.3.2.2.1.20.15.102.119.112.111.108.105.99.121.95.115.116.97.116.117.115 = INTEGER: permanent(4)
.1.3.6.1.4.1.8072.1.3.2.2.1.21.15.102.119.112.111.108.105.99.121.95.115.116.97.116.117.115 = INTEGER: active(1)
.1.3.6.1.4.1.8072.1.3.2.3.1.1.15.102.119.112.111.108.105.99.121.95.115.116.97.116.117.115 = STRING: STATUS: OK - everything good
.1.3.6.1.4.1.8072.1.3.2.3.1.2.15.102.119.112.111.108.105.99.121.95.115.116.97.116.117.115 = STRING: STATUS: OK - everything good
.1.3.6.1.4.1.8072.1.3.2.3.1.3.15.102.119.112.111.108.105.99.121.95.115.116.97.116.117.115 = INTEGER: 1
.1.3.6.1.4.1.8072.1.3.2.3.1.4.15.102.119.112.111.108.105.99.121.95.115.116.97.116.117.115 = INTEGER: 0
.1.3.6.1.4.1.8072.1.3.2.4.1.2.15.102.119.112.111.108.105.99.121.95.115.116.97.116.117.115.1 = STRING: STATUS: OK - everything good

with a get

$ snmpget -v 2c -c mycomstring 192.168.1.1 
.1.3.6.1.4.1.8072.1.3.2.4.1.2.15.102.119.112.111.108.105.99.121.95.115.116.97.116.117.115.1
NET-SNMP-EXTEND-MIB::nsExtendOutLine."fwpolicy_status".1 = STRING: STATUS: OK - everything good