|
php.net | support | documentation | report a bug | advanced search | search howto | statistics | random bug | login |
[2002-08-27 21:01 UTC] george dot travan at adelaide dot edu dot au
PHP Version 4.2.2 UCD-SNMP Version 4.2.1 Apache 1.3.2 OS Solaris 2.6 (with all current patches) I could configure and compile PHP with SNMP, however, when I try a simple snmpget retieval, the PHP error log reports that "Could not open snmp in /usr/local/apache/htdocs/snmptest.php line 10" Now the same command works on the command line. Anyone seen this behaviour? PatchesPull RequestsHistoryAllCommentsChangesGit/SVN commits
|
|||||||||||||||||||||||||||
Copyright © 2001-2025 The PHP GroupAll rights reserved. |
Last updated: Sun Oct 26 12:00:01 2025 UTC |
I think I know what could be happening. snippet of code: $workstations = file ("workstations.txt"); for ($i=0; $i < $number_of_workstations; $i++) { $status = snmpget($workstations[$i], $community, ".1.3.6", $timeout, $retries); The problem is with $workstations[$i]. When I replace this with the workstation ip address it works. So it seems the problem is with the construction of the argument.Seems more like some bug in your script.. Are you sure $workstations[$i] holds the IP ? Try adding this before the snmpget() call: echo "-{$workstations[$i]-"; so you'll see that there aren't any extra stuff in it..like \n or so. Each line in that array returned by file will hold the line ending..The $workstations array does report correctly the ip's on closer inspection. echo "-{$workstations[$i]-"; correctly identifies the array members. just seems to fail as an argument to snmpget.Sorry about the lack of detail :{ <?php $timeout= '300'; $retries= '10'; $community = "public"; $workstation = file("workstation.txt"); $num_workstation = count($workstation); for ( $i = 0 ; $i < $num_workstation; $i++) { print "Workstation: $workstation[$i] Community: $community Timeout: $timeout Retries: $retries"; //$sysname = snmpget( "localhost","public","system.sysName.0"); $status = snmpget($workstation[$i], $community, ".1.3.6.1.4.1.11.2.3.9.1.1.3.0", $timeout, $retries); echo $status; } ?> workstation.txt is a plain file with workstation addresses, ie dominator.adelaide.edu.au my-pc-room3.adelaide.edu.au Regards.