Remote restart by ssh

Menard, Chris Chris.Menard at Aspect.com
Tue Sep 8 15:40:34 CEST 2009


Looks like the restarter script is coded to restart the service on the 3rd SOFT non-OK status.

The log shows Soft1, Soft2 then Hard3.  Looks like you have to restart service in the script on the 2nd Soft status to avoid the HARD state or change the retry count to allow for 3 SOFT status before the HARD.

That being said, the service should have been restarted following the HARD, CRITICAL call.

-----Original Message-----
From: Alex Huth [mailto:a.huth at tmr.net] 
Sent: Tuesday, September 08, 2009 9:25 AM
To: nagios-users at lists.sourceforge.net
Subject: [Nagios-users] Remote restart by ssh

Hi!

I have a service on a remote machine which dies frequently. I want to restart
him by ssh. I followed the steps in the guide, but when i stop him nothing
happens. 
That's what i have done so far:

commands.cfg

define command{
	command_name	restart_saprouter
command_line $USER1$/check_by_ssh -H $HOSTADDRESS$ -t 175 -l admin -i
/adm/etc/nagios/id_nagios -C
'usr/local/libexec/eventhandlers/restart_saprouter.sh $SERVICESTATE$
$SERVICESTATETYPE$ $SERVICEATTEMPT$'	
	}


services.cfg

define service{
        name                            xxxx.base.saprouter-running
        use                             xxxx.base-service
        hostgroup_name                  xxxx.base.saprouters
        service_description             SAP router process present
        check_command                   ssh_check_procs!1:1!1:1!saprouter
	event_handler			restart_saprouter
        }
define servicedependency{
	hostgroup_name			xxxx.base.saprouters
	dependent_hostgroup_name	xxxx.base.saprouters
	service_description		SSH
	dependent_service_description	SAP router process present
	execution_failure_criteria	n
	notification_failure_criteria	w,u,c
	}

the eventhandler script on the remote machine:

#!/bin/sh

case "$1" in
OK)
        ;;
WARNING)
        ;;
UNKNOWN)
        ;;
CRITICAL)
        case "$2" in

        SOFT)

                case "$3" in

                3)
                        echo -n "Restarting SAP-Router service (3rd soft
critical state)..."
                        /etc/init.d/saprouter.sh restart
                        ;;
                        esac
                ;;

        HARD)
                echo -n "Restarting SAP-Router service..."
                /etc/init.d/saprouter.sh restart
                ;;
        esac
        ;;
esac
exit 0


log of nagios:

[1252415755] SERVICE ALERT: xxxxxxxx;SAP router process
present;CRITICAL;SOFT;1;PROCS CRITICAL: 0 processes with command name
'saprouter'
[1252415755] SERVICE EVENT HANDLER: xxxxxxxxxxxxx;SAP router process
present;(null);(null);(null);restart_saprouter
[1252415815] SERVICE ALERT: xxxxxxxxxxxx;SAP router process
present;CRITICAL;SOFT;2;PROCS CRITICAL: 0 processes with command name
'saprouter'
[1252415815] SERVICE EVENT HANDLER: xxxxxxxxxxx;SAP router process
present;(null);(null);(null);restart_saprouter
[1252415875] SERVICE ALERT: xxxxxxxxxx;SAP router process
present;CRITICAL;HARD;3;PROCS CRITICAL: 0 processes with command name
'saprouter'
[1252415875] SERVICE EVENT HANDLER: xxxxxxxxxxxxx;SAP router process
present;(null);(null);(null);restart_saprouter

Can someone give me light where my fault is?

Thx

Alex

------------------------------------------------------------------------------
Let Crystal Reports handle the reporting - Free Crystal Reports 2008 30-Day 
trial. Simplify your report design, integration and deployment - and focus on 
what you do best, core application coding. Discover what's new with 
Crystal Reports now.  http://p.sf.net/sfu/bobj-july
_______________________________________________
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

------------------------------------------------------------------------------
Let Crystal Reports handle the reporting - Free Crystal Reports 2008 30-Day 
trial. Simplify your report design, integration and deployment - and focus on 
what you do best, core application coding. Discover what's new with 
Crystal Reports now.  http://p.sf.net/sfu/bobj-july
_______________________________________________
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