No notifications while restarting any services on remote host

Roy Sigurd Karlsbakk roy at karlsbakk.net
Tue Apr 14 09:35:18 CEST 2009


On 14. april. 2009, at 08.33, Kaushal Shriyan wrote:

> Hi,
>
> When i restart any services on the remote client For example tomcat  
> application server running on port 8080. I dont get any  
> notifications or alerts. Just want to understand the technique is it  
> because of the normal_check_interval  5 configured in services.cfg  
> and interval_length=60 defined in nagios.cfg.


When you restart something like a tomcat server, it takes to short a  
time for Nagios to notice. If you want a notice when something is  
restarted, write a script that checks the root PID of the process and  
make this generate an email. I don't Nagios is very well suited for  
this operation, but a small script written in <your favourite  
language> can do it without much problems. Example:

---
$ cat pidcheck.sh
#!/bin/sh

PIDDIR=/var/pidcheck
PIDFILE=$PIDDIR/$1

[ -d $PIDDIR ] || mkdir -p $PIDDIR

thispid=`pidof apache2 | cut -d" " -f1`

if [ ! -f $PIDFILE ]
then
	echo -n $thispid > $PIDFILE
	exit 0
fi
# implicit 'else'
oldpid=`cat $PIDFILE`
if [ $thispid -ne $oldpid ]
then
	echo New pid for $1: $thispid
	echo -n $thispid > $PIDFILE
	exit 1
else
	exit 0
fi
# ----


$ ./pidcheck.sh apache2
$ ./pidcheck.sh apache2
$ sudo /etc/init.d/apache2 restart
  * Restarting web server apache2
    ...done.
$ ./pidcheck.sh apache2
New pid for apache2: 3125
$ echo $?
1
$ ./pidcheck.sh apache2
$ echo $?
0

--
Roy Sigurd Karlsbakk
(+47) 97542685 / 98013356
roy at karlsbakk.net
--
I all pedagogikk er det essensielt at pensum presenteres  
intelligibelt. Det er en elementært imperativ for alle pedagoger å  
unngå eksessiv anvendelse av idiomer med fremmed opprinnelse. I de  
fleste tilfeller eksisterer adekvate og relevante synonymer på norsk.


------------------------------------------------------------------------------
This SF.net email is sponsored by:
High Quality Requirements in a Collaborative Environment.
Download a free trial of Rational Requirements Composer Now!
http://p.sf.net/sfu/www-ibm-com
_______________________________________________
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