remote script execution
Moderators: Developers, Moderators
remote script execution
Im running cacti on debian and i need to remotely exceute scripts to a HP-UX host to grab a number from a log file. Nagios has NRPE, is there any way to do this with cacti? Do you thing i can integrate NRPE into some of the custom data querys?
Thanks,
John
Thanks,
John
- rony
- Developer/Forum Admin
- Posts: 6022
- Joined: Mon Nov 17, 2003 6:35 pm
- Location: Michigan, USA
- Contact:
You can use NRPE, but you can also use SSH in a public/private key setup. Or you can even use rsh, but ssh is prefered.
[size=117][i][b]Tony Roman[/b][/i][/size]
[size=84][i]Experience is what causes a person to make new mistakes instead of old ones.[/i][/size]
[size=84][i]There are only 3 way to complete a project: Good, Fast or Cheap, pick two.[/i][/size]
[size=84][i]With age comes wisdom, what you choose to do with it determines whether or not you are wise.[/i][/size]
[size=84][i]Experience is what causes a person to make new mistakes instead of old ones.[/i][/size]
[size=84][i]There are only 3 way to complete a project: Good, Fast or Cheap, pick two.[/i][/size]
[size=84][i]With age comes wisdom, what you choose to do with it determines whether or not you are wise.[/i][/size]
- rony
- Developer/Forum Admin
- Posts: 6022
- Joined: Mon Nov 17, 2003 6:35 pm
- Location: Michigan, USA
- Contact:
Post the output from your NRPE command and I will give you and example script to work off of.
[size=117][i][b]Tony Roman[/b][/i][/size]
[size=84][i]Experience is what causes a person to make new mistakes instead of old ones.[/i][/size]
[size=84][i]There are only 3 way to complete a project: Good, Fast or Cheap, pick two.[/i][/size]
[size=84][i]With age comes wisdom, what you choose to do with it determines whether or not you are wise.[/i][/size]
[size=84][i]Experience is what causes a person to make new mistakes instead of old ones.[/i][/size]
[size=84][i]There are only 3 way to complete a project: Good, Fast or Cheap, pick two.[/i][/size]
[size=84][i]With age comes wisdom, what you choose to do with it determines whether or not you are wise.[/i][/size]
[root@usohcol2net001 libexec]# ./check_nrpe -H 10.250.2.10 -c check_load
load average: 0.08, 0.04, 0.03
./check_nrpe -H 10.250.2.10 -c check_disk2
DISK OK - [3075994 kB (68%) free on /dev/vg00/lvol8]
Those are the 2 nrpe plugins i have working now, many more to write. I'll understand it better once i have one of these being graphed.
Thanks!!
load average: 0.08, 0.04, 0.03
./check_nrpe -H 10.250.2.10 -c check_disk2
DISK OK - [3075994 kB (68%) free on /dev/vg00/lvol8]
Those are the 2 nrpe plugins i have working now, many more to write. I'll understand it better once i have one of these being graphed.
Thanks!!
- rony
- Developer/Forum Admin
- Posts: 6022
- Joined: Mon Nov 17, 2003 6:35 pm
- Location: Michigan, USA
- Contact:
Let's use perl... I like perl for this stuff...
Save this script to a file, then to use it do something like the following. Saved script is named load_avg_parse.pl in this example:
This will output something cacti can use.
Now for the disk usage one, use the following script to parse the output of the NRPE command:
The output will look like:
Now, these scripts are just something I whipped up off the top of my head. If the output doesn't match, it will return unknown values, which will show up on the graphs as "NaN".
As for adding the data sources for this, use the others as explains. Pay attention to the Unix Disk Space one, good examples there.
Gluck!
Code: Select all
#!/usr/bin/perl
# Read stdin and do a regex match for the loads
if (<> =~ m/load average:\s(\d+(\.\d*)?),\s+(\d+(\.\d*)?),\s+(\d+(\.\d*)?)/) {
# regex match, output parsed values
print "5min:" . $1 . " 10min:" . $2 . " 15min:" . $3 . "\n";
exit 0;
} else {
# no match, output unknown
print "5min:U 10min:U 15min:U\n";
exit 1;
}
Code: Select all
./check_nrpe -H 10.250.2.10 -c check_load | ./load_avg_parse.pl
Code: Select all
5min:0.08 10min:0.04 15min:0.03
Now for the disk usage one, use the following script to parse the output of the NRPE command:
Code: Select all
#!/usr/bin/perl
# Read stdin and do a regex match for the loads
if (<> =~ m/DISK\s*OK\s*-\s*\[(\d+)\s+[A-Za-z]+\s+\((\d+)\%\)/) {
# regex match, output parsed values
print "free_kb:" . $1 . " free_percent:" . $2 . "\n";
exit 0;
} else {
# no match, output unknown
print "free_kb:U free_percent:U\n";
exit 1;
}
Code: Select all
free_kb:3075994 free_percent:68
As for adding the data sources for this, use the others as explains. Pay attention to the Unix Disk Space one, good examples there.
Gluck!
[size=117][i][b]Tony Roman[/b][/i][/size]
[size=84][i]Experience is what causes a person to make new mistakes instead of old ones.[/i][/size]
[size=84][i]There are only 3 way to complete a project: Good, Fast or Cheap, pick two.[/i][/size]
[size=84][i]With age comes wisdom, what you choose to do with it determines whether or not you are wise.[/i][/size]
[size=84][i]Experience is what causes a person to make new mistakes instead of old ones.[/i][/size]
[size=84][i]There are only 3 way to complete a project: Good, Fast or Cheap, pick two.[/i][/size]
[size=84][i]With age comes wisdom, what you choose to do with it determines whether or not you are wise.[/i][/size]
Who is online
Users browsing this forum: No registered users and 0 guests