php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #65422 Error when calling multiple snmp3 functions
Submitted: 2013-08-08 20:42 UTC Modified: 2013-08-31 06:53 UTC
Votes:1
Avg. Score:5.0 ± 0.0
Reproduced:1 of 1 (100.0%)
Same Version:0 (0.0%)
Same OS:1 (100.0%)
From: pkryon at yahoo dot com Assigned: lytboris (profile)
Status: Not a bug Package: SNMP related
PHP Version: 5.5.1 OS: Debian Wheezy
Private report: No CVE-ID: None
 [2013-08-08 20:42 UTC] pkryon at yahoo dot com
Description:
------------
Test script below returns only the first snmp3_get.  The next two fail with a PHP Warning.  

This appears to be a problem in all snmp3 functions but seems to work as expected with the snmp/snmp2 functions.

Test script:
---------------
<?php

echo snmp3_get('device1','snmpuser','authNoPriv','sha','snmppass','','','SNMPv2-MIB::sysLocation.0')."\n";

echo snmp3_get('device2','snmpuser','authNoPriv','sha','snmppass','','','SNMPv2-MIB::sysLocation.0')."\n";

echo snmp3_get('device3','snmpuser','authNoPriv','sha','snmppass','','','SNMPv2-MIB::sysLocation.0')."\n";

?>

Expected result:
----------------
STRING: Location 1
STRING: Location 2
STRING: Location 3

Actual result:
--------------
STRING: Location 1
PHP Warning:  snmp3_get(): No response from 192.168.0.2 in /var/www/test4.php on line 5

PHP Warning:  snmp3_get(): No response from 192.168.0.3 in /var/www/test4.php on line 7

Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2013-08-30 06:09 UTC] lytboris@php.net
-Status: Open +Status: Feedback -Assigned To: +Assigned To: lytboris
 [2013-08-30 06:09 UTC] lytboris@php.net
Not enough information was provided for us to be able
to handle this bug. Please re-read the instructions at
http://bugs.php.net/how-to-report.php

If you can provide more information, feel free to add it
to this bug and change the status back to "Open".

Thank you for your interest in PHP.


I can not reproduce this bug in my test environment.
Please post Net-SNMP snmpget commands with their results prooving that your 2nd & 3rd hosts are configured to work with SNMPv3 the same way that your 1st host.
 [2013-08-30 15:31 UTC] pkryon at yahoo dot com
Were you by chance polling a single host multiple time to test?  Because that seems to work.  More tests below...


bugtest1.php:

<?php

// bugtest1.php - Test using built-in snmp3_get to multiple hosts
// result: fail

echo snmp3_get('cseoc1260','[REMOVED]','authNoPriv','sha','[REMOVED]','','','SNMPv2-MIB::sysLocation.0')."\n";

echo snmp3_get('cseoc1264','[REMOVED]','authNoPriv','sha','[REMOVED]','','','SNMPv2-MIB::sysLocation.0')."\n";

echo snmp3_get('cseoc2260','[REMOVED]','authNoPriv','sha','[REMOVED]','','','SNMPv2-MIB::sysLocation.0')."\n";

?>

Result:

[REMOVED]:/var/www/scripts$ php bugtest1.php
STRING: EOC Building 1 (Room 1260)
PHP Warning:  snmp3_get(): No response from 172.19.12.12 in /var/www/scripts/bugtest1.php on line 8

PHP Warning:  snmp3_get(): No response from 172.19.12.21 in /var/www/scripts/bugtest1.php on line 10


bugtest2.php:

<?php

// bugtest2.php - Test using built-in snmp3_get to same host
// result: pass

echo snmp3_get('cseoc1260','[REMOVED]','authNoPriv','sha','[REMOVED]','','','SNMPv2-MIB::sysLocation.0')."\n";

echo snmp3_get('cseoc1260','[REMOVED]','authNoPriv','sha','[REMOVED]','','','SNMPv2-MIB::sysLocation.0')."\n";

echo snmp3_get('cseoc1260','[REMOVED]','authNoPriv','sha','[REMOVED]','','','SNMPv2-MIB::sysLocation.0')."\n";

?>

Result:
[REMOVED]:/var/www/scripts$ php bugtest2.php
STRING: EOC Building 1 (Room 1260)
STRING: EOC Building 1 (Room 1260)
STRING: EOC Building 1 (Room 1260)


bugtest3.php:

<?php

// bugtest3.php - Test using NetSNMP snmpget on multiple hosts
// result: pass

echo shell_exec("snmpget -O v -v 3 -l AuthNoPriv -u [REMOVED] -a SHA -A [REMOVED] cseoc1260 SNMPv2-MIB::sysLocation.0");

echo shell_exec("snmpget -O v -v 3 -l AuthNoPriv -u [REMOVED] -a SHA -A [REMOVED] cseoc1264 SNMPv2-MIB::sysLocation.0");

echo shell_exec("snmpget -O v -v 3 -l AuthNoPriv -u [REMOVED] -a SHA -A [REMOVED] cseoc2260 SNMPv2-MIB::sysLocation.0");

?>

Result:
[REMOVED]:/var/www/scripts$ php bugtest3.php
STRING: EOC Building 1 (Room 1260)
STRING: EOC Building 1 (Room 1264)
STRING: EOC Building 2 (Room 2260)


bugtest4.php:

<?php

// bugtest4.php - Test using built-in snmpget on multiple hosts
// result: pass

echo snmpget('cseoc1260','[REMOVED]','SNMPv2-MIB::sysLocation.0')."\n";

echo snmpget('cseoc1264','[REMOVED]','SNMPv2-MIB::sysLocation.0')."\n";

echo snmpget('cseoc2260','[REMOVED]','SNMPv2-MIB::sysLocation.0')."\n";

?>

Result:

[REMOVED]:/var/www/scripts$ php bugtest4.php
STRING: EOC Building 1 (Room 1260)
STRING: EOC Building 1 (Room 1264)
STRING: EOC Building 2 (Room 2260)
 [2013-08-30 15:48 UTC] pkryon at yahoo dot com
-Status: Feedback +Status: Open
 [2013-08-30 15:48 UTC] pkryon at yahoo dot com
Reopen
 [2013-08-30 17:09 UTC] lytboris@php.net
-Status: Open +Status: Feedback
 [2013-08-30 17:11 UTC] lytboris@php.net
Please note that you have 'sha' written in low case chars. Try replacing them to SHA (the same way you use in snmpget).
 [2013-08-30 17:19 UTC] lytboris@php.net
Forget previous comment :)
 [2013-08-30 17:30 UTC] lytboris@php.net
I have re-checked my configuration and stiil unable to reproduce it:

======================
<?php
echo snmp3_get('127.0.0.1', 'adminSHA', 'authNoPriv', 'sha', 'test1234', '', '', 'SNMPv2-MIB::sysLocation.0') . "\n";
echo snmp3_get('77.[CUT]', 'adminSHA', 'authNoPriv', 'sha', 'test12345', '', '', 'SNMPv2-MIB::sysLocation.0') . "\n";
?>
======================
Works fine for me.
Do you have a possibility to run tests bundled with php-snmp source?
 [2013-08-30 20:00 UTC] pkryon at yahoo dot com
-Status: Feedback +Status: Assigned
 [2013-08-30 20:00 UTC] pkryon at yahoo dot com
Well, hm.  This got me thinking that all of the devices I've been testing have been Cisco WS-C4510R+E switches with 7-E supervisor engines.  So I tried the same thing on some older WS-C4506 switches with Sup II+ engines and it works just fine.  Not sure where to go from there...

I don't currently have the php-snmp source but could probably get that setup if it would still help.
 [2013-08-31 06:53 UTC] lytboris@php.net
-Status: Assigned +Status: Not a bug
 [2013-08-31 06:53 UTC] lytboris@php.net
>Not sure where to go from there...
use tcpdump to dig further. I will close the ticket.
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Fri Mar 29 15:01:28 2024 UTC