Passing Argument to snmp extend script?

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

Moderators: Developers, Moderators

Post Reply
synappzz
Posts: 1
Joined: Wed Oct 26, 2011 12:17 pm

Passing Argument to snmp extend script?

Post by synappzz »

Hello,
I have been trying to configure cacti for a few days now, and reading through all the documentation I can get my hands on.

I have successfully been able to graph some custom scripts on a server, using both snmp extend and running the script directly inputting it as the Data Input Method and having ssh keys set up.

The last piece of the puzzle is that there are over 40 virtual network interfaces on this server, and I need to be able to pass the <hostname> as an argument to the script on the server. I believe that when running the script as the data input method, I can add the <hostname> at the end, then use $1 or $ARGV[0] in perl, such as:

Data Input Method: ssh cactiquery@<hostname> /home/cactiquery/port_state.pl <hostname>

And in my perl script: $data{'8009_established'} = `netstat -na | cut -c 21-44,69- | fgrep $ARGV[$0]`;

Then add hostname as an input field and voila.


I can't however figure out how to do the same using the SNMP extend method. Our leadhand is partial to using SNMP as we have a lot of servers. I have a line within snmpd.conf:

extend portstates /usr/local/bin/port_state.sh

And I set up the data template with the OID, and can graph it. Is there are way to pass the <hostname> argument to the script using this method?

Thanks for your time.
User avatar
TheWitness
Developer
Posts: 17007
Joined: Tue May 14, 2002 5:08 pm
Location: MI, USA
Contact:

Re: Passing Argument to snmp extend script?

Post by TheWitness »

Use the script server to handle this and simply have a function that maps the hostnames to an OID. You will have to maintain the index somewhere. So, maybe it's a data query.

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 3 guests