Custom Plugin
Tedman Eng
teng at dataway.com
Thu Jul 21 03:02:28 CEST 2005
Try adding ;echo $? to the end of your commandline to see what the final
exit code is.
ex: ./lhm.sh 10.30.31.51 ; echo $?
I'm a bit rusty on the details of expect, but the 'interact' statement may
be writing output to the terminal, vs real stdout.
-----Original Message-----
From: Danny Russell [mailto:drussell at mpifix.com]
Sent: Wednesday, July 20, 2005 10:45 AM
To: nagios-users at lists.sourceforge.net
Subject: [Nagios-users] Custom Plugin
I am trying to monitor a host that is behind a Cisco VPN Concentrator. For
simplicity right now I am just trying to use check_ping.
I have written an expect script (lhm.sh) that logs into the VPN and then
runs a check_ping command. Here is the code for lhm.sh:
1 #!/usr/bin/expect -f
2 set cmd_one [lindex $argv 0];
3 log_user 0
4 spawn vpnclient connect lhm pwd password
5 expect "(y/n): " {send "y\r"}
6 spawn ./check_ping -H $cmd_one -w 3000.0,80% -c 5000.0,100% -p 3
7 interact
8 set status [wait]
9 #puts [lindex $status 3]
10 exit [lindex $status 3]
Line #3 - disables the output to go to stdout. This hides all of the nasty
long VPN connection information.
Line #4 - connects to the VPN
Line #5 - sends a 'y' so the VPN is connected
Line #8 - gets the exit return code
Line #10 - exits with the exit return code from $status.
When I call './lhm.sh 10.30.31.51' this is the output:
[root at monitor plugins]# ./lhm.sh 10.30.31.51
PING OK - Packet loss = 0%, RTA = 60.68 ms
[root at monitor plugins]#
When I call './lhm.sh 10.30.31.51' with the puts un-commented this is the
output:
[root at monitor plugins]# ./lhm.sh 10.30.31.51
PING OK - Packet loss = 0%, RTA = 71.03 ms
0
[root at monitor plugins]#
When I call './lhm.sh 10.30.31.61' (A WRONG IP) with the puts un-commented
this is the output:
[root at monitor plugins]# ./lhm.sh 10.30.31.61
CRITICAL - Plugin timed out after 18 seconds
2
[root at monitor plugins]#
The problem is, when I create a custom check command in
/etc/Nagios/checkcommands.cfg to call /usr/lib/Nagios/plugins/lhm.sh Nagios
always reports it as up and (No output!). It even reports at UP if I give it
a wrong IP (10.30.31.61).
Host Status: UP
Status Information:(No output!)
Any ideas?
Thanks!
Danny Russell
Mobile Productivity, Inc.
drussell at mpifix.com
work-801.437.5885 mbl-801.722.5837
Enabling the World To Work
-------------------------------------------------------
SF.Net email is sponsored by: Discover Easy Linux Migration Strategies
from IBM. Find simple to follow Roadmaps, straightforward articles,
informative Webcasts and more! Get everything you need to get up to
speed, fast. http://ads.osdn.com/?ad_id=7477&alloc_id=16492&op=click
_______________________________________________
Nagios-users mailing list
Nagios-users at lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/nagios-users
::: Please include Nagios version, plugin version (-v) and OS when reporting any issue.
::: Messages without supporting info will risk being sent to /dev/null
More information about the Users
mailing list