Bad SNMP query results

Post general support questions here that do not specifically fall into the Linux or Windows categories.

Moderators: Developers, Moderators

Post Reply
limuerti
Posts: 9
Joined: Wed Jan 28, 2009 9:20 am

Bad SNMP query results

Post by limuerti »

Hi Guys,
I'm able to add a device on cacti, but when I look at the SNMP Data Query Results, I am displayed something like this.

May you please help me in fixing the issue.
Graphs from these devices don't work. My previous graphs are working correctly.

Regards,
Attachments
cacti.JPG
cacti.JPG (104.49 KiB) Viewed 4324 times
limuerti
Posts: 9
Joined: Wed Jan 28, 2009 9:20 am

Help

Post by limuerti »

Dear Guys,

any idea? in the query results do you notice the simbol "=" ?

I upgraded to version 0.8.7c this morning

Thank you
User avatar
gandalf
Developer
Posts: 22383
Joined: Thu Dec 02, 2004 2:46 am
Location: Muenster, Germany
Contact:

Post by gandalf »

Please perform a "Verbose Query" of the related Data Query and post results
Reinhard
twitch757
Posts: 1
Joined: Tue Feb 03, 2009 3:27 pm

Post by twitch757 »

I am experiencing the exact same issue, attached is a text file with the Verbose query that you have asked for.
Attachments
verbose.txt
(141.43 KiB) Downloaded 171 times
aaronsegura
Posts: 25
Joined: Fri Jan 30, 2009 12:56 pm

Post by aaronsegura »

I was just researching this exact same behavior.

It seems to be due to a difference in lib/snmp.php between 0.8.7b and 0.8.7c:

Code: Select all

[asegura@host html]$ ls -alF; diff *-*/lib/snmp.php
total 24K
drwxr-xr-x  4 root      root   4.0K Feb  3 14:20 ./
drwxr-xr-x  7 root      root   4.0K Jan 15  2008 ../
lrwxrwxrwx  1 root      root     13 Feb  3 14:20 cacti -> cacti-0.8.7c//
drwxr-xr-x 12 cactiuser nagios 4.0K Feb  3 14:14 cacti-0.8.7b/
drwxr-xr-x 13 cactiuser users  4.0K Feb  3 14:00 cacti-0.8.7c/
225c225
< function cacti_snmp_walk($hostname, $community, $oid, $version, $username, $password, $auth_proto, $priv_pass, $priv_proto, $context, $port = 161, $timeout = 500, $retries = 0, $environ = SNMP_POLLER) {
---
> function cacti_snmp_walk($hostname, $community, $oid, $version, $username, $password, $auth_proto, $priv_pass, $priv_proto, $context, $port = 161, $timeout = 500, $retries = 0, $max_oids = 10, $environ = SNMP_POLLER) {
227a228
> 	$snmp_auth	= '';
314,315c315,316
< 			if (file_exists($path_snmpbulkwalk) && ($version > 1)) {
< 				$temp_array = exec_into_array($path_snmpbulkwalk . " -O Qn $snmp_auth -v $version -t $timeout -r $retries -Cr50 $hostname:$port $oid");
---
> 			if (file_exists($path_snmpbulkwalk) && ($version > 1) && ($max_oids > 1)) {
> 				$temp_array = exec_into_array($path_snmpbulkwalk . " -O Qn $snmp_auth -v $version -t $timeout -r $retries -Cr$max_oids $hostname:$port $oid");
341c342
< 	$string = trim(ereg_replace(".*= ?", "", $string));
---
> 	$string = trim(substr($string, strpos($string, " = ")));
348a350,351
> 	$string = str_replace("\n", " ", $string);
> 	$string = str_replace("\r", " ", $string);
If you edit snmp.php and undo the following change:

Code: Select all

341c342
< 	$string = trim(ereg_replace(".*= ?", "", $string));
---
> 	$string = trim(substr($string, strpos($string, " = ")));
it starts working again.
User avatar
gandalf
Developer
Posts: 22383
Joined: Thu Dec 02, 2004 2:46 am
Location: Muenster, Germany
Contact:

Post by gandalf »

Yep. This seems to be a valid workaround for _some_ snmp environments, but not for all :cry:
Please post your php and net-snmp versions
Reinhard
aaronsegura
Posts: 25
Joined: Fri Jan 30, 2009 12:56 pm

Post by aaronsegura »

Sure thing:

PHP 5.2.0 (cli) (built: May 10 2008 01:56:59)
Copyright (c) 1997-2006 The PHP Group
Zend Engine v2.2.0, Copyright (c) 1998-2006 Zend Technologies

and

NET-SNMP version: 5.4.1
User avatar
gandalf
Developer
Posts: 22383
Joined: Thu Dec 02, 2004 2:46 am
Location: Muenster, Germany
Contact:

Post by gandalf »

I'm at php 5.2.6 and it works. Any chance for a test with that version?
Reinhard
aaronsegura
Posts: 25
Joined: Fri Jan 30, 2009 12:56 pm

Post by aaronsegura »

Sorry, I can't go swapping around PHP versions on this box right now.
skullone
Posts: 11
Joined: Wed May 18, 2005 3:36 am

Post by skullone »

Confirming the bug, and the fix does resolve the issue for me.

Running OpenSolaris 2008.11 with the AMP suite installed.


PHP 5.2.6 (cli) (built: Oct 14 2008 02:53:59)
Copyright (c) 1997-2008 The PHP Group
Zend Engine v2.2.0, Copyright (c) 1998-2008 Zend Technologies


Net-SNMP
5.0.9

OpenSolaris still ships an old Net-SNMP, not sure why.
Tomsworld
Posts: 2
Joined: Sun May 20, 2007 9:37 am

Post by Tomsworld »

Other versions, same bug.

Ubuntu jeos - up to date 8.04

tom@kanga:/home/cacti/cacti-0.8.7c/lib$ snmpwalk -Version
NET-SNMP version: 5.4.1
tom@kanga:/home/cacti/cacti-0.8.7c/lib$ php -v
PHP 5.2.4-2ubuntu5.4 with Suhosin-Patch 0.9.6.2 (cli) (built: Nov 25 2008 22:10:31)
Copyright (c) 1997-2007 The PHP Group
Zend Engine v2.2.0, Copyright (c) 1998-2007 Zend Technologies
tom@kanga:/home/cacti/cacti-0.8.7c/lib$

following solution works:
If you edit snmp.php and undo the following change:

Code: Select all

341c342
< 	$string = trim(ereg_replace(".*= ?", "", $string));
---
> 	$string = trim(substr($string, strpos($string, " = ")));
User avatar
gandalf
Developer
Posts: 22383
Joined: Thu Dec 02, 2004 2:46 am
Location: Muenster, Germany
Contact:

Post by gandalf »

This bug was resolved in 087d. Thanks for reporting
Reinhard
Post Reply

Who is online

Users browsing this forum: No registered users and 2 guests