Cacti cannot SNMP

Post support questions that directly relate to Linux/Unix operating systems.

Moderators: Developers, Moderators

Post Reply
Clocks
Posts: 14
Joined: Fri Nov 09, 2007 3:25 pm

Cacti cannot SNMP

Post by Clocks »

So I am building SNMP query templates for a device that only supports SNMP v3. In the process of working on that, I realized that my templates weren't incorrect, it simply wasn't making the connection properly. More troubleshooting later, it appears that I cant do anything that requires SNMP at all from cacti.

This is odd. I have checked all of the appropriate dependencies. I have net-snmp. I can execute SNMP commands all day long on the command line with perfect results. I have custom scripts which get SNMP data using PHP SNMP functionality and then do post processing on them and they work perfectly. Ditto PERL scripts doing similar work.

Yet, cacti does not want to SNMP, even version 1 with an unsecured public community to localhost!

Code: Select all

+ Running data query [10].
+ Found type = '3' [snmp query].
+ Found data query XML file at '/usr/share/cacti/resource/snmp_queries/SS4200-E_fans.xml'
+ XML file parsed ok.
+ Executing SNMP walk for list of indexes @ '.1.3.6.1.4.1.1139.10.6.1.1.1'
+ No SNMP data returned
+ Found data query XML file at '/usr/share/cacti/resource/snmp_queries/SS4200-E_fans.xml'
+ Found data query XML file at '/usr/share/cacti/resource/snmp_queries/SS4200-E_fans.xml'
+ Found data query XML file at '/usr/share/cacti/resource/snmp_queries/SS4200-E_fans.xml'
Running the included interfaces.xml file (and associated interfaces SNMP query) against devices yields identical results.

From the command line with identical configuration:

Code: Select all

snmpwalk -v 3 -a SHA -u cacti -A seekritSquirrelPassword -l noAuthNoPriv -x AES 192.168.3.93 .1.3.6.1.4.1.1139.10.6.1.1.1
SNMPv2-SMI::enterprises.1139.10.6.1.1.1.1 = INTEGER: 1
SNMPv2-SMI::enterprises.1139.10.6.1.1.1.2 = INTEGER: 2
SNMPv2-SMI::enterprises.1139.10.6.1.1.1.3 = INTEGER: 3
Thoughts on a debug approach would be highly appreciated. My script test harnesses are coming back fine and I dont see any data showing up in the cacti log even when set to be very chatty.

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

Post by gandalf »

NoAuthNoPriv ???
Does this make sense with SNMP V3???
R.
Clocks
Posts: 14
Joined: Fri Nov 09, 2007 3:25 pm

Post by Clocks »

No. Its irrelevent. The underlying issue is that the command line works but cacti will not return query results, no matter whether its v1 or v3 or what host I make the query against.



In a PM conversation, I was also asked for the following detail. Here is the XML file for the query I am writing (v3) and the associated command line data:

Code: Select all

<interface> 
<name>Get SNMP Fan Speed</name> 
<description>Queries an SS4200-E for a list of internal fans</description> 
<oid_index>.1.3.6.1.4.1.1139.10.6.1.1.1</oid_index> 
<oid_num_indexes>.1.3.6.1.4.1.1139.10.6.1.1.1.3</oid_num_indexes> 
<index_order_type>numeric</index_order_type> 

<fields> 
<fanIndex> 
<name>Index</name> 
<method>walk</method> 
<source>value</source> 
<direction>input</direction> 
<oid>.1.3.6.1.4.1.1139.10.6.1.1.1</oid> 
</fanIndex> 
<fanName> 
<name>Name</name> 
<method>walk</method> 
<source>value</source> 
<direction>input</direction> 
<oid>.1.3.6.1.4.1.1139.10.6.1.1.2</oid> 
</fanName> 
<fanSpeed> 
<name>Speed</name> 
<method>walk</method> 
<source>value</source> 
<direction>output</direction> 
<oid>.1.3.6.1.4.1.1139.10.6.1.1.3</oid> 
</fanSpeed> 
</fields> 
</interface> 
Also so you can see what the output would be expected to be:

Code: Select all

[dev@Falconnest snmp_queries]# snmpwalk -v 3 -a SHA -u cacti -A seekritSquirrelPassword -x AES 192.168.3.93 .1.3.6.1.4.1.1139.10.6.1.1.1 
SNMPv2-SMI::enterprises.1139.10.6.1.1.1.1 = INTEGER: 1 
SNMPv2-SMI::enterprises.1139.10.6.1.1.1.2 = INTEGER: 2 
SNMPv2-SMI::enterprises.1139.10.6.1.1.1.3 = INTEGER: 3 

[dev@Falconnest snmp_queries]# snmpwalk -v 3 -a SHA -u cacti -A seekritSquirrelPassword -x AES 192.168.3.93 .1.3.6.1.4.1.1139.10.6.1.1.1.3 
SNMPv2-SMI::enterprises.1139.10.6.1.1.1.3 = INTEGER: 3 

[dev@Falconnest snmp_queries]# snmpwalk -v 3 -a SHA -u cacti -A seekritSquirrelPassword -x AES 192.168.3.93 .1.3.6.1.4.1.1139.10.6.1.1.2 
SNMPv2-SMI::enterprises.1139.10.6.1.1.2.1 = STRING: "CPU Fan" 
SNMPv2-SMI::enterprises.1139.10.6.1.1.2.2 = STRING: "Internal Fan 1" 
SNMPv2-SMI::enterprises.1139.10.6.1.1.2.3 = STRING: "Internal Fan 2" 

[dev@Falconnest snmp_queries]# snmpwalk -v 3 -a SHA -u cacti -A seekritSquirrelPassword -x AES 192.168.3.93 .1.3.6.1.4.1.1139.10.6.1.1.3 
SNMPv2-SMI::enterprises.1139.10.6.1.1.3.1 = Gauge32: 0 
SNMPv2-SMI::enterprises.1139.10.6.1.1.3.2 = Gauge32: 1562 
SNMPv2-SMI::enterprises.1139.10.6.1.1.3.3 = Gauge32: 1480

Here is essentially the same functionality, done as a PERL script invoking the command line net-smtp tools which does work. Beautifully, in fact.

Code: Select all

#!/usr/bin/perl -w
use strict;
use Getopt::Long;

##########################
#
#	SS4200-E_getFans.pl - Retrieve fan information using SMTP v3 from an Intel SS4200-E
#
#########################
#  SYNOPSIS
#
#  SS4200-E_getFans.pl -h <host> -u <user> -p <password> [-v]
#
#  SS4200-E_getFans.pl -h 192.168.3.93 -u admin -p secretSquirrel -v
#
#########################


############
# Setup key variables we are going to need to track globally.
#
# Host is a string FQDN or IP address that is the target of our query.
#
# User is a string for the username to authenticate against the SS4200-E SMTP.
#
# Password is a string for the password to authenticate against the SS4200-E SMTP.
#
# Verbose is a boolean/binary value of whether we are going to dump verbose error data. Defaults to off (0).
#
###

my ($host, $user, $password, $verbose, $output);

# Get the options from the command line.
GetOptions (
	"h=s"	=> \$host,
	"u=s"	=> \$user,
	"p=s"	=> \$password,
	"v!"	=> \$verbose,
);


# To be able to run at all, we need the host, user and password.
# Without any of the three, we need to terminate immediately.

if (!$host || !$user || !$password) {
	print "Not enough arguments.  Require at least host, user, and password specified. \n";
	exit(0);
}

# Set our default for the verbosity if it was not specified on the commandline.
if (!$verbose) {$verbose= 0;}

# Setup some temporary variable data.
my ($query, $fancpu, $fansysone, $fansystwo);


#################
# Get the fan data.
# This is based on the EMC SOHO MIB, which has an odd but known OID.
#
# Requires 5 values.  host, user, password, fanid, verbose
###

sub getFanData {

	#variables to hold our input
	my ($Hhost, $Huser, $Hpassword, $Hfanid, $Hverbose) = @_;

	#variable to return output
	my $fanspeed;
	my $query;

	$query = `snmpwalk -v 3 -a SHA -u $Huser -A $Hpassword -l noAuthNoPriv -x AES $Hhost .1.3.6.1.4.1.1139.10.6.1.1.3.$Hfanid`;


	# Check for a match against the regex for the end of an expected single line.
	if($query =~ m/Gauge32: (\d+)$/) {
	
		# We got a match against our check looking for the fan RPM value.
		$fanspeed = $1;

	} else {

		# We couldnt get our regex match, so if verbose is set, lets drop an error.
		$fanspeed = 0;

		if($Hverbose) {
			print "\n";
			print "CPU Fan SMTP Query failed.\n\n";
			print "$query\n";
			print "\n";
		}

	}


	return $fanspeed;
}

####
#
# End Sub for getting fan data.
#
###

$fancpu = &getFanData($host, $user, $password, 1, $verbose);
$fansysone = &getFanData($host, $user, $password, 2, $verbose);
$fansystwo = &getFanData($host, $user, $password, 3, $verbose);

# Lets drop the output line.
print "cpufan:$fancpu sysonefan:$fansysone systwofan:$fansystwo";
User avatar
TheWitness
Developer
Posts: 17007
Joined: Tue May 14, 2002 5:08 pm
Location: MI, USA
Contact:

Post by TheWitness »

Well, the command line syntax that your are using is not quite correct. You state with the -l that you are using noAuthNoPriv. But, then you provide a user and password, and an AES privacy protocol and no passphrase.

What net-snmp does is see's the "noAuthNoPriv" and ignores the rest. Cacti, on the other hand does "Not" support noAuthNoPriv. I figured when I wrote it that if you were going to use snmpv3, you would want the Data Encrypted.

So, I think you should "RTM". Then, no insult intended, try again.

TheWitness
True understanding begins only when we realize how little we truly understand...

Life is an adventure, let yours begin with Cacti!

Author of dozens of Cacti plugins and customization's. Advocate of LAMP, MariaDB, IBM Spectrum LSF and the world of batch. Creator of IBM Spectrum RTM, author of quite a bit of unpublished work and most of Cacti's bugs.
_________________
Official Cacti Documentation
GitHub Repository with Supported Plugins
Percona Device Packages (no support)
Interesting Device Packages


For those wondering, I'm still here, but lost in the shadows. Yearning for less bugs. Who want's a Cacti 1.3/2.0? Streams anyone?
Clocks
Posts: 14
Joined: Fri Nov 09, 2007 3:25 pm

Post by Clocks »

Thanks, The Witness. Gosh wish i had thought of reading the manual. Oh wait, I did.

I have read the manual, ad nauseum and added the l to my existing command line only after doing the full command setup and it worked every time, i started expirimenting with all of the command lines to try and find scenarios it wasnt working with on the command line in the hopes of finding combinations which maybe cacti was using.

Code: Select all

[dev@Falconnest ~]# snmpwalk -v 3 -a SHA -u cacti -A mypassword -x AES 192.168.3.93 .1.3.6.1.4.1.1139.10.6.1.1.1
SNMPv2-SMI::enterprises.1139.10.6.1.1.1.1 = INTEGER: 1
SNMPv2-SMI::enterprises.1139.10.6.1.1.1.2 = INTEGER: 2
SNMPv2-SMI::enterprises.1139.10.6.1.1.1.3 = INTEGER: 3
As you can see above, droping the argument works just like it did before i added it. The command line above matches my SNMP config in the host definition.

The troubleshooting key item here is that SNMP is not working, even to a v1 public localhost item. So putting the v3 config stuff aside for the moment, i need help debugging why SNMP is not working for SNMP queried sources.

I am having trouble getting debug info deep enough into cacti to find out why SNMP is not working from cacti but does work from the command line and does work in both my PERL and PHP test harnesses.
User avatar
TheWitness
Developer
Posts: 17007
Joined: Tue May 14, 2002 5:08 pm
Location: MI, USA
Contact:

Post by TheWitness »

So, the command from the command line works as well. I see the output from a snmpwalk, but not from the command itself. I'll take it that it's working though. So the next part is to walk through the process of debugging from Data Input Method to the actual output.

I will assume for now that this is not a data query, that you will provide certain input fields that will result in a fully functional item in the poller cache when instantiated against a device.

This is where things generally go wrong for some users. Bottom line, if you find the correct entry in the poller cache, there is a good chance that the polling should work.

Have you checked there? If it does not appear there, then there may be a problem with the template.

Lastly when using spine, we have gone back and forth, but most recently, we reverted to the data input method having to be something to the affect, in this case:

Code: Select all

/usr/bin/perl <myscript>.pl
Requiring the full path to the binary since we are not loading/passing the environment. However, before you go there, you should test with cmd.php.

TheWitness
True understanding begins only when we realize how little we truly understand...

Life is an adventure, let yours begin with Cacti!

Author of dozens of Cacti plugins and customization's. Advocate of LAMP, MariaDB, IBM Spectrum LSF and the world of batch. Creator of IBM Spectrum RTM, author of quite a bit of unpublished work and most of Cacti's bugs.
_________________
Official Cacti Documentation
GitHub Repository with Supported Plugins
Percona Device Packages (no support)
Interesting Device Packages


For those wondering, I'm still here, but lost in the shadows. Yearning for less bugs. Who want's a Cacti 1.3/2.0? Streams anyone?
Post Reply

Who is online

Users browsing this forum: No registered users and 5 guests