How to write simple scripts for Cacti?

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

Moderators: Moderators, Developers

Post Reply
Author
Message
switched
Posts: 29
Joined: Fri Nov 21, 2008 4:15 pm

How to write simple scripts for Cacti?

#1 Post by switched » Sat Jul 31, 2010 5:21 am

Guys,
I have a couple of ideas that would help me monitor some of my devices.

What I really want to do is write a script to do the following every 5 minutes or so:
1) SSH to a remote device
2) enter logon password
3) Telnet into the box's propriety software (command is telnet 0)
4) Log into the custom software (user/pass)
5) run a single command
6) Take the 'value' in the output (it will display one text line with a value after the text...I just need the integer)
7) and graph it.

Thats it!
So I know what I want to do, but how do I go about learning where to find out how to do this under the linux environment.

Im happy to spend some time learning, I just need to work out what I need to research to get the above working.. Is there any particular scripting language? that would help me here, I'm sorry for the silly request,but this is all new to me
Can anyone throw a few ideas? :oops:

User avatar
TheWitness
Developer
Posts: 14817
Joined: Tue May 14, 2002 5:08 pm
Location: MI, USA
Contact:

#2 Post by TheWitness » Sat Jul 31, 2010 7:51 am

First of all, don't do it with a user/password. Second, you can setup snmp to run the command for you. Research the "exec" syntax for snmpd.conf. If you still feel compelled to use ssh, use a private key and not a user/password. Then either write and distribute a local script or use some re-direct magic to perform all the steps.

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

Life is an adventure, let yours begin with Cacti!

Author of MacTrack, Boost, CLog, SpikeKill, Platform RTM, DSStats, maintainer of Spine, lot's of unpublished work and most of Cacti's bugs.
_________________
Official Cacti Documentation
GitHub Repository with Supported Plugins
Central Plugin Repository
Central Templates Repository


I'm still out there people. Getting excited for Cacti 1.2. I think it will be a great release.

switched
Posts: 29
Joined: Fri Nov 21, 2008 4:15 pm

#3 Post by switched » Sat Jul 31, 2010 8:55 am

Thanks TheWitness,

I should have mentioned Cacti resides on corporate network, but the device I want to monitor resides on public WWW...

I've never done scripting, my role would really benefit from being able to write scripts to function with our NMS applications inc Cacti.. Im just having difficulty knowing what it is I need to research PERL, or something? :cry: My background is cisco.. not linux.

User avatar
TheWitness
Developer
Posts: 14817
Joined: Tue May 14, 2002 5:08 pm
Location: MI, USA
Contact:

#4 Post by TheWitness » Sat Jul 31, 2010 11:11 am

Yea, you should use a private key. Tips include:

Code: Select all

man ssh
I am sure there are a few good SSH examples in the how-tos on my signature that use SSH.

I wish you the best of luck...

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

Life is an adventure, let yours begin with Cacti!

Author of MacTrack, Boost, CLog, SpikeKill, Platform RTM, DSStats, maintainer of Spine, lot's of unpublished work and most of Cacti's bugs.
_________________
Official Cacti Documentation
GitHub Repository with Supported Plugins
Central Plugin Repository
Central Templates Repository


I'm still out there people. Getting excited for Cacti 1.2. I think it will be a great release.

[vr]
Posts: 13
Joined: Wed Dec 30, 2009 8:40 am
Location: Saginaw, MI

#5 Post by [vr] » Thu Sep 23, 2010 12:36 am

You can use the expect scripting language (expectk) to interactively perform those remote duties and return the results locally.
Cacti: 0.8.7e (from cacti.net)
Plugin Architecture: 2.5
OS: Debian i386

User avatar
lcano
Cacti User
Posts: 190
Joined: Thu Oct 09, 2008 5:46 pm
Location: Spain

#6 Post by lcano » Thu Sep 23, 2010 8:34 am

I really prefer perl or shell scripting, better than expect, don't you?

[vr]
Posts: 13
Joined: Wed Dec 30, 2009 8:40 am
Location: Saginaw, MI

#7 Post by [vr] » Thu Sep 23, 2010 4:37 pm

lcano wrote:I really prefer perl or shell scripting, better than expect, don't you?
I've never learned perl and I wasn't aware you could interactively process things on remote systems with standard shell scripts.
Cacti: 0.8.7e (from cacti.net)
Plugin Architecture: 2.5
OS: Debian i386

User avatar
lcano
Cacti User
Posts: 190
Joined: Thu Oct 09, 2008 5:46 pm
Location: Spain

#8 Post by lcano » Fri Sep 24, 2010 2:39 am

[vr] wrote:I've never learned perl and I wasn't aware you could interactively process things on remote systems with standard shell scripts.
SSH provides you the option to execute commands in remote systems. Then, you can choose between ssh perl modules, or direct ssh commands in shell scripts. It's easy and you don't have to check the answers of the remote system like you should do with expect. SSH controls it. Something like this:

http://www.linuxhowtos.org/Tips%20and%2 ... mmands.htm

Post Reply