Thanks.# Battery Charge level left
define service{
use generic-service
host_name PowerWare 9125
service_description Battery Charge Left
check_command check_ups!public!charge!70!30
normal_check_interval 15
retry_check_interval 3
}
JR
Thanks.# Battery Charge level left
define service{
use generic-service
host_name PowerWare 9125
service_description Battery Charge Left
check_command check_ups!public!charge!70!30
normal_check_interval 15
retry_check_interval 3
}
Thanks for the reply. I wrote up the shutdown script, modified from another one I had, however partly no to your inquiry. The systems I need to shutdown here are virtual machines. Treating them like any other machine, however they do not have NSCLIENT++ installed so if there is another suggestion open to it. Installing NSCLIENT++ is not even vaguely a big deal but always interested in options.rkennedy wrote:Assuming you already have NRPE commands / scripts defined for the command 'shutdown' setup to trigger, you would go this route.
Create a bash script, that first off detects what state the service is changing in to. Then, just have it execute as NRPE normally would as commands in your bash script. Just because it's on a different service, doesn't mean the Nagios machine can't execute /usr/local/nagios/libexec/check_nrpe -H x.x.x.x -c shutdown from the CLI still.
Once that's created, assign it as an event_handler to the service.
Code: Select all
!/bin/sh
#
# Event handler script for restarting the server on the local machine
#
# use variables for arguments
SERVICESTATE=$1
SERVICESTATETYPE=$2
SERVICEATTEMPT=$3
# we don't want to restart if current status is OK
if [ "$SERVICESTATE" != "OK" ] ; then
# proceed only if we're in soft transition state
if [ "$SERVICESTATETYPE" == "SOFT" ] ; then
# proceed only if this is 3rd attempt, restart
if [ "$SERVICESTATEATTEMPT" == "3" ] ; then
/usr/local/nagios/libexec/check_nrpe -H 192.168.0.x -c shuterdown
/usr/local/nagios/libexec/check_nrpe -H 192.168.0.x -c shuterdown
/usr/local/nagios/libexec/check_nrpe -H 192.168.0.x -c shuterdown
fi
fi
fi
exit 0
This should work, looks like the obstacle now is figuring out how to shut them down without NSClient++, and then we can change the /usr/local/nagios/libexec/check_nrpe -H 192.168.0.x -c reboot part. To help gather a bit more info:jriker1 wrote:Thanks for the reply. I wrote up the shutdown script, modified from another one I had, however partly no to your inquiry. The systems I need to shutdown here are virtual machines. Treating them like any other machine, however they do not have NSCLIENT++ installed so if there is another suggestion open to it. Installing NSCLIENT++ is not even vaguely a big deal but always interested in options.rkennedy wrote:Assuming you already have NRPE commands / scripts defined for the command 'shutdown' setup to trigger, you would go this route.
Create a bash script, that first off detects what state the service is changing in to. Then, just have it execute as NRPE normally would as commands in your bash script. Just because it's on a different service, doesn't mean the Nagios machine can't execute /usr/local/nagios/libexec/check_nrpe -H x.x.x.x -c shutdown from the CLI still.
Once that's created, assign it as an event_handler to the service.
Thanks.
JR
For reference here is the simple event handler I created:
Assuming this won't go straight to a hard state.Code: Select all
!/bin/sh # # Event handler script for restarting the server on the local machine # # use variables for arguments SERVICESTATE=$1 SERVICESTATETYPE=$2 SERVICEATTEMPT=$3 # we don't want to restart if current status is OK if [ "$SERVICESTATE" != "OK" ] ; then # proceed only if we're in soft transition state if [ "$SERVICESTATETYPE" == "SOFT" ] ; then # proceed only if this is 3rd attempt, restart if [ "$SERVICESTATEATTEMPT" == "3" ] ; then /usr/local/nagios/libexec/check_nrpe -H 192.168.0.x -c reboot /usr/local/nagios/libexec/check_nrpe -H 192.168.0.x -c reboot /usr/local/nagios/libexec/check_nrpe -H 192.168.0.x -c reboot fi fi fi exit 0