View Full Version : No output from SNMP
garnser
03-01-2010, 12:41 PM
Hi all,
I recently tried getting SNMP working with my Litespeed server but for some reason no data is presented when quering it with SNMP.
I followed this guide:
http://www.litespeedtech.com/support/wiki/doku.php?id=litespeed_wiki:snmp_cacti_monitoring
# apt-get install php5-cli php5-common php5-snmp
Added the following to /etc/snmp/snmpd.conf (There's preexisting configuration for other MIBs which works)
pass .1.3.6.1.4.1.22253 /usr/bin/php /usr/local/lsws/add-ons/snmp_monitoring/sample.php
Running it locally returns:
# php -q ./sample.php -n .1.3.6.1.4.1.22253.101
.1.3.6.1.4.1.22253.101.1
string
LiteSpeed Web Server
The SNMP log only shows that a SNMP query has been requested but not output was provided.
Please advice.
mistwang
03-01-2010, 12:45 PM
Maybe it is because snmp agent call an external application to serve the request.
You got the result from sample.php, right? it is working.
garnser
03-01-2010, 12:52 PM
Maybe it is because snmp agent call an external application to serve the request.
You got the result from sample.php, right? it is working.
Wouldn't the log return some kinds of errors if that was the case?
mistwang
03-01-2010, 01:18 PM
I think it is just the way it works.
You should ask net-snmp developers about this, it is not something develop by LiteSpeed.
garnser
03-01-2010, 02:33 PM
Quering the script with extend rather than pass gave this output:
SNMPv2-SMI::enterprises.22253.1.0 = INTEGER: 1
SNMPv2-SMI::enterprises.22253.2.1.2.12.47.117.115.114.47. 98.105.110.47.112.104.112 = STRING: "/usr/local/lsws/add-ons/snmp_monitoring/sample.php"
SNMPv2-SMI::enterprises.22253.2.1.3.12.47.117.115.114.47. 98.105.110.47.112.104.112 = ""
SNMPv2-SMI::enterprises.22253.2.1.4.12.47.117.115.114.47. 98.105.110.47.112.104.112 = ""
SNMPv2-SMI::enterprises.22253.2.1.5.12.47.117.115.114.47. 98.105.110.47.112.104.112 = INTEGER: 5
SNMPv2-SMI::enterprises.22253.2.1.6.12.47.117.115.114.47. 98.105.110.47.112.104.112 = INTEGER: 1
SNMPv2-SMI::enterprises.22253.2.1.7.12.47.117.115.114.47. 98.105.110.47.112.104.112 = INTEGER: 1
SNMPv2-SMI::enterprises.22253.2.1.20.12.47.117.115.114.47 .98.105.110.47.112.104.112 = INTEGER: 4
SNMPv2-SMI::enterprises.22253.2.1.21.12.47.117.115.114.47 .98.105.110.47.112.104.112 = INTEGER: 1
SNMPv2-SMI::enterprises.22253.3.1.1.12.47.117.115.114.47. 98.105.110.47.112.104.112 = STRING: "/usr/local/lsws/add-ons/snmp_monitoring/sample.php: Permission denied"
SNMPv2-SMI::enterprises.22253.3.1.2.12.47.117.115.114.47. 98.105.110.47.112.104.112 = STRING: "/usr/local/lsws/add-ons/snmp_monitoring/sample.php: Permission denied"
SNMPv2-SMI::enterprises.22253.3.1.3.12.47.117.115.114.47. 98.105.110.47.112.104.112 = INTEGER: 1
SNMPv2-SMI::enterprises.22253.3.1.4.12.47.117.115.114.47. 98.105.110.47.112.104.112 = INTEGER: 1
SNMPv2-SMI::enterprises.22253.4.1.2.12.47.117.115.114.47. 98.105.110.47.112.104.112.1 = STRING: "/usr/local/lsws/add-ons/snmp_monitoring/sample.php: Permission denied"
Gives you a bit more to work on.
mistwang
03-01-2010, 02:37 PM
chmod a+x /usr/local/lsws/add-ons/snmp_monitoring/sample.php
add
#!/usr/local/bin/php
at the beginning of sample.php if it is not there.
garnser
03-01-2010, 02:41 PM
Ok getting a bit closer however I'm still not getting the full output:
root@mon:~# snmpwalk -c public -v 1 10.254.11.101 .1.3.6.1.4.1.22253
SNMPv2-SMI::enterprises.22253.1.0 = INTEGER: 1
SNMPv2-SMI::enterprises.22253.2.1.2.12.47.117.115.114.47. 98.105.110.47.112.104.112 = STRING: "/var/lib/snmp/snmp_monitoring/sample.php"
SNMPv2-SMI::enterprises.22253.2.1.3.12.47.117.115.114.47. 98.105.110.47.112.104.112 = ""
SNMPv2-SMI::enterprises.22253.2.1.4.12.47.117.115.114.47. 98.105.110.47.112.104.112 = ""
SNMPv2-SMI::enterprises.22253.2.1.5.12.47.117.115.114.47. 98.105.110.47.112.104.112 = INTEGER: 5
SNMPv2-SMI::enterprises.22253.2.1.6.12.47.117.115.114.47. 98.105.110.47.112.104.112 = INTEGER: 1
SNMPv2-SMI::enterprises.22253.2.1.7.12.47.117.115.114.47. 98.105.110.47.112.104.112 = INTEGER: 1
SNMPv2-SMI::enterprises.22253.2.1.20.12.47.117.115.114.47 .98.105.110.47.112.104.112 = INTEGER: 4
SNMPv2-SMI::enterprises.22253.2.1.21.12.47.117.115.114.47 .98.105.110.47.112.104.112 = INTEGER: 1
SNMPv2-SMI::enterprises.22253.3.1.1.12.47.117.115.114.47. 98.105.110.47.112.104.112 = ""
SNMPv2-SMI::enterprises.22253.3.1.2.12.47.117.115.114.47. 98.105.110.47.112.104.112 = ""
SNMPv2-SMI::enterprises.22253.3.1.3.12.47.117.115.114.47. 98.105.110.47.112.104.112 = INTEGER: 1
SNMPv2-SMI::enterprises.22253.3.1.4.12.47.117.115.114.47. 98.105.110.47.112.104.112 = INTEGER: 0
SNMPv2-SMI::enterprises.22253.4.1.2.12.47.117.115.114.47. 98.105.110.47.112.104.112.1 = ""
mistwang
03-01-2010, 02:54 PM
Maybe you need to use
#!/usr/local/bin/php -q
to silence PHP header output.
garnser
03-01-2010, 03:01 PM
Hm, did seam to help, however as the file is executeble I configured snmpd to query the script directly instead extend .1.3.6.1.4.1.22253 /var/lib/snmp/snmp_monitoring/sample.php
Which gives me this:
root@mon:~# snmpwalk -c public -v 1 10.254.11.101 .1.3.6.1.4.1.22253
SNMPv2-SMI::enterprises.22253.1.0 = INTEGER: 1
SNMPv2-SMI::enterprises.22253.2.1.2.40.47.118.97.114.47.1 08.105.98.47.115.110.109.112.47.115.110.109.112.95 .109.111.110.105.116.111.114.105.110.103.47.115.97 .109.112.108.101.46.112.104.112 = STRING: "
"
SNMPv2-SMI::enterprises.22253.2.1.3.40.47.118.97.114.47.1 08.105.98.47.115.110.109.112.47.115.110.109.112.95 .109.111.110.105.116.111.114.105.110.103.47.115.97 .109.112.108.101.46.112.104.112 = ""
SNMPv2-SMI::enterprises.22253.2.1.4.40.47.118.97.114.47.1 08.105.98.47.115.110.109.112.47.115.110.109.112.95 .109.111.110.105.116.111.114.105.110.103.47.115.97 .109.112.108.101.46.112.104.112 = ""
SNMPv2-SMI::enterprises.22253.2.1.5.40.47.118.97.114.47.1 08.105.98.47.115.110.109.112.47.115.110.109.112.95 .109.111.110.105.116.111.114.105.110.103.47.115.97 .109.112.108.101.46.112.104.112 = INTEGER: 5
SNMPv2-SMI::enterprises.22253.2.1.6.40.47.118.97.114.47.1 08.105.98.47.115.110.109.112.47.115.110.109.112.95 .109.111.110.105.116.111.114.105.110.103.47.115.97 .109.112.108.101.46.112.104.112 = INTEGER: 1
SNMPv2-SMI::enterprises.22253.2.1.7.40.47.118.97.114.47.1 08.105.98.47.115.110.109.112.47.115.110.109.112.95 .109.111.110.105.116.111.114.105.110.103.47.115.97 .109.112.108.101.46.112.104.112 = INTEGER: 1
SNMPv2-SMI::enterprises.22253.2.1.20.40.47.118.97.114.47. 108.105.98.47.115.110.109.112.47.115.110.109.112.9 5.109.111.110.105.116.111.114.105.110.103.47.115.9 7.109.112.108.101.46.112.104.112 = INTEGER: 4
SNMPv2-SMI::enterprises.22253.2.1.21.40.47.118.97.114.47. 108.105.98.47.115.110.109.112.47.115.110.109.112.9 5.109.111.110.105.116.111.114.105.110.103.47.115.9 7.109.112.108.101.46.112.104.112 = INTEGER: 1
SNMPv2-SMI::enterprises.22253.3.1.1.40.47.118.97.114.47.1 08.105.98.47.115.110.109.112.47.115.110.109.112.95 .109.111.110.105.116.111.114.105.110.103.47.115.97 .109.112.108.101.46.112.104.112 = STRING: "No such file or directory"
SNMPv2-SMI::enterprises.22253.3.1.2.40.47.118.97.114.47.1 08.105.98.47.115.110.109.112.47.115.110.109.112.95 .109.111.110.105.116.111.114.105.110.103.47.115.97 .109.112.108.101.46.112.104.112 = STRING: "No such file or directory"
SNMPv2-SMI::enterprises.22253.3.1.3.40.47.118.97.114.47.1 08.105.98.47.115.110.109.112.47.115.110.109.112.95 .109.111.110.105.116.111.114.105.110.103.47.115.97 .109.112.108.101.46.112.104.112 = INTEGER: 1
SNMPv2-SMI::enterprises.22253.3.1.4.40.47.118.97.114.47.1 08.105.98.47.115.110.109.112.47.115.110.109.112.95 .109.111.110.105.116.111.114.105.110.103.47.115.97 .109.112.108.101.46.112.104.112 = INTEGER: 1
SNMPv2-SMI::enterprises.22253.4.1.2.40.47.118.97.114.47.1 08.105.98.47.115.110.109.112.47.115.110.109.112.95 .109.111.110.105.116.111.114.105.110.103.47.115.97 .109.112.108.101.46.112.104.112.1 = STRING: "No such file or directory"
Any idea what file that could be missing?
mistwang
03-02-2010, 11:29 AM
Maybe you should use
pass .1.3.6.1.4.1.22253 /usr/bin/php -q /litespeed_snmp_scripts/sample.php
remove "#!/usr/bin/php -q" from sample.php
garnser
03-02-2010, 11:39 AM
Back on square one using pass, with extend I get:
root@mon:~# snmpwalk -c public -v 1 10.254.11.101 .1.3.6.1.4.1.22253
SNMPv2-SMI::enterprises.22253.1.0 = INTEGER: 1
SNMPv2-SMI::enterprises.22253.2.1.2.12.47.117.115.114.47. 98.105.110.47.112.104.112 = STRING: "-q"
SNMPv2-SMI::enterprises.22253.2.1.3.12.47.117.115.114.47. 98.105.110.47.112.104.112 = STRING: "/var/lib/snmp/snmp_monitoring/sample.php"
SNMPv2-SMI::enterprises.22253.2.1.4.12.47.117.115.114.47. 98.105.110.47.112.104.112 = ""
SNMPv2-SMI::enterprises.22253.2.1.5.12.47.117.115.114.47. 98.105.110.47.112.104.112 = INTEGER: 5
SNMPv2-SMI::enterprises.22253.2.1.6.12.47.117.115.114.47. 98.105.110.47.112.104.112 = INTEGER: 1
SNMPv2-SMI::enterprises.22253.2.1.7.12.47.117.115.114.47. 98.105.110.47.112.104.112 = INTEGER: 1
SNMPv2-SMI::enterprises.22253.2.1.20.12.47.117.115.114.47 .98.105.110.47.112.104.112 = INTEGER: 4
SNMPv2-SMI::enterprises.22253.2.1.21.12.47.117.115.114.47 .98.105.110.47.112.104.112 = INTEGER: 1
SNMPv2-SMI::enterprises.22253.3.1.1.12.47.117.115.114.47. 98.105.110.47.112.104.112 = STRING: "-q: No such file or directory"
SNMPv2-SMI::enterprises.22253.3.1.2.12.47.117.115.114.47. 98.105.110.47.112.104.112 = STRING: "-q: No such file or directory"
SNMPv2-SMI::enterprises.22253.3.1.3.12.47.117.115.114.47. 98.105.110.47.112.104.112 = INTEGER: 1
SNMPv2-SMI::enterprises.22253.3.1.4.12.47.117.115.114.47. 98.105.110.47.112.104.112 = INTEGER: 1
SNMPv2-SMI::enterprises.22253.4.1.2.12.47.117.115.114.47. 98.105.110.47.112.104.112.1 = STRING: "-q: No such file or directory"
mistwang
03-02-2010, 11:45 AM
try quoting "/usr/bin/php -q"