Search code examples
phplinuxshellsnmp

SNMP Php no response, working within linux shell


I'm trying to get a value from a device by SNMP. It is currently working good with almost all the devices on my network, but there is one that simply don't answer snmp from PHP. But it does when i issue a "snmpget" command from my command line.

 snmpget -v2c -c public 10.XX.17.232 1.3.6.1.2.1.1.1.0

Is working great, but :

<?php echo snmpget("10.XX.17.232", "public", "1.3.6.1.2.1.1.1.0", 1000000, 1); ?>

Answer PHP Warning: snmpget(): No response from 10.31.17.232 in Command line code on line 1

On other devices, my snmp in php is working great, no problem. For example :

php -r 'echo snmpget("10.XX.21.230", "public", "1.3.6.1.2.1.1.1.0", 1000000, 1);

Returns me a good value. Only on some devices. I first though that it could be about the ACL, but i double-triple checked them and Command Line Snmp is working...

Do anybody has an answer for me ? Have a good day !


Solution

  • You are using SNMP v2c in the command line and version 1 in PHP. Have you tried with snmp2_get?

    string snmp2_get(string host, string community, string object_id [, int timeout [, int retries]]);