php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #19135 Can't execute snmp functions
Submitted: 2002-08-27 21:01 UTC Modified: 2002-08-29 11:47 UTC
From: george dot travan at adelaide dot edu dot au Assigned:
Status: Not a bug Package: SNMP related
PHP Version: 4.2.2 OS: solaris 2.6
Private report: No CVE-ID: None
Welcome back! If you're the original bug submitter, here's where you can edit the bug or add additional notes.
If this is not your bug, you can add a comment by following this link.
If this is your bug, but you forgot your password, you can retrieve your password here.
Password:
Status:
Package:
Bug Type:
Summary:
From: george dot travan at adelaide dot edu dot au
New email:
PHP Version: OS:

 

 [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? 


Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2002-08-28 12:35 UTC] kalowsky@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.


Please post a sample script
 [2002-08-28 20:02 UTC] george dot travan at adelaide dot edu dot au
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.
 [2002-08-28 20:06 UTC] george dot travan at adelaide dot edu dot au
forgot to include that $number_of_workstations = count($workstations);


seems to be a problem with $workstations[$i] in the loop causing this.
 [2002-08-28 21:28 UTC] sniper@php.net
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..



 [2002-08-28 21:52 UTC] george dot travan at adelaide dot edu dot au
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.
 [2002-08-28 22:42 UTC] kalowsky@php.net
okay again, I ask for a simple sample script to reproduce this.  Mainly because the sample you gave me, assumes $community exists, and that the array you're creating ($workstations) is correct.  Sorry but more detail is needed.  
 [2002-08-29 00:55 UTC] george dot travan at adelaide dot edu dot au
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.
 [2002-08-29 11:47 UTC] sniper@php.net
Like I said in my previous comment, file() preserves any line ending characters in the array data..

Change the line to this:

$status =  snmpget(trim($workstation[$i]), $community, ".1.3.6.1.4.1.11.2.3.9.1.1.3.0", $timeout, $retries);

And it works. This is not any bug..


 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Thu Apr 25 08:01:28 2024 UTC