*Output From Scripts through SNMP?*

Templates, scripts for templates, scripts and requests for templates.

Moderators: Developers, Moderators

Post Reply
kruz
Posts: 23
Joined: Tue Sep 19, 2006 2:19 pm

*Output From Scripts through SNMP?*

Post by kruz »

hey guys, im not asking you to explain the whole thing

but rather point me in the right direction(you can explain if you want though :])

i have a script on Server1(SNMP Hosts) and Server2(Cacti server)

i need to have the output of a script(a number) send to the cacti server

for example

(On Server1, NOT CACTI)
#!/bin/bash
if [ `whoami` = "root" ]
then
echo "1"
else
echo "0"
fi


and i want to send this output to Cacti
for it to be graphed, to show on my tests if the user is root
or is not root


this of course is not a situation, but rather an example
on how to pass numbers to cacti from SNMP hosts


thank you for your time
`KruZ~

ABSOLUTLY ANY HELP
would be greatly appreciated
User avatar
Linegod
Developer
Posts: 1626
Joined: Thu Feb 20, 2003 10:16 am
Location: Canada
Contact:

Post by Linegod »

If you are dealing with another Linux/*nix box, I would use an OID. The net-snmp daemon can call just about any script you want.

Take a look at how it is done for postfix mailgraph - http://forums.cacti.net/viewtopic.php?t=6657

Then modify that to do what you want.
--
Live fast, die young
You're sucking up my bandwidth.

J.P. Pasnak,CD
CCNA, LPIC-1
http://www.warpedsystems.sk.ca
kruz
Posts: 23
Joined: Tue Sep 19, 2006 2:19 pm

Post by kruz »

thank you very much
i am starting a fairly complex project
to get output of different commands(all numerical)
and having cacti graph them

from one linux box(server 1, server i want the script to run on) results to server2 (the cacti server)

thank you very much i will look into it


thank you again, i will post my results, and or scripts

any more input anyone?
kruz
Posts: 23
Joined: Tue Sep 19, 2006 2:19 pm

Post by kruz »

can anyone shed more light on the subject? thanks.
idle
Cacti User
Posts: 77
Joined: Wed May 26, 2004 10:49 am
Location: Barcelona
Contact:

Post by idle »

Hi.
Check cacti scripts: <path_cacti>/scripts/*.
For example diskfree.sh

Code: Select all

#!/bin/sh
df -k $1 | grep -v Filesystem| awk '{printf "megabytes:" $4 " percent:" int($5)}'
kruz
Posts: 23
Joined: Tue Sep 19, 2006 2:19 pm

Post by kruz »

idle:

will this execute the script on the server
and send back the results??

thank you,
kruz
warnesj
Cacti User
Posts: 173
Joined: Sun May 29, 2005 7:34 pm

Post by warnesj »

I've done the same thing as Linegod with my MailScanner and Sendmail graphs (http://forums.cacti.net/viewtopic.php?t=15651).

I have a script running on my mail server to count a variety of things. Then when I query an SNMP OID I choose then Net-SNMP runs another script to read those counters into my Cacti server.

Check out your snmpd.conf file and look for a section about Executables/scripts. Or check the Net-SNMP documentation section for the snmpd.conf file (http://net-snmp.sourceforge.net/docs/ma ... .conf.html) and look for the "Arbitrary Extension Commands" section. It should point you in the direction I think you're looking for.
Post Reply

Who is online

Users browsing this forum: No registered users and 1 guest