Check service.sh
De wikiGite
Révision datée du 25 mars 2010 à 09:37 par Frank (discussion | contributions)
Script de surveillance des services qui ne peuvent pas l'être avec monit
(pas de fichier pid, et/ou pas de port réseau à surveiller)
#!/bin/bash
# FSo 2010
# check services that can't be check by monit (ex : no pid file and no network port)
# v1.0 : creation avec surveillance monit et ossec
# First : monit itself !
/etc/init.d/monit status > /dev/null 2>&1
if [ $? -ne 0 ]
then
/etc/init.d/monit restart > /dev/null 2>&1
fi
# OSSEC don't have standard pid files
OSSEC_DIR=/opt/ossec
OSSECPROC=0
for pidfile in $(ls $OSSEC_DIR/var/run/*.pid)
do
ps -p $(cat $pidfile) | grep ossec > /dev/null 2>&1
if [ $? -ne 0 ]
then
OSSECPROC=1
fi
done
if [ $OSSECPROC -eq 1 ]
then
/etc/init.d/ossec restart
fi
A intégrer (par un lien) à /etc/cron.hourly ou /etc/cron.quarter-hourly
cd /etc/cron.hourly/ ln -s /opt/systools/check_services.sh
