voila une petit code Sherpath... qui fait cela Il s'insere dans la crontab.
Bien sur c'est pas le top car le process est surveill� en fonction du param
de ton entree cron mais, il est super simple a utiliser. Tu n'as qu'a
modifier la ligne de dessus et mettre tes services a surveiller.
Philippe DUCHEIN
dans la crontab par exemple pour un test tout les 15mins, met cela
0,15,30,45 * * * * root /usr/sbin/checkservices 1>/dev/null
2>/dev/null
et le fivhier en question:
#!/bin/sh
# Services watcher
# Restart services if necessary
# process_name/rc.d_script/process_uid
PROCESS="syslogd/sysklogd inetd/inetd sshd/ssh sendmail/sendmail
mysqld/mysql/mysql apache/apache proftpd/proftpd dmv2/StartDmv2"
PASS="0"
if test "$#" -gt 0; then
if test "$1" = "restart"; then
PASS="2 1 0"
fi
fi
for LPASS in $PASS; do
if test "$LPASS" -eq 1; then
sleep 2
fi
for LPROC in $PROCESS; do
# Process binary name, rc.d name, and optional process UID
PROC=`echo $LPROC|cut -f1 -d'/'`
RCPROC=`echo $LPROC|cut -f2 -d'/'`
UIDPROC=`echo $LPROC|cut -f3 -d'/'`
if test ! -n "$UIDPROC"; then
UIDPROC=0
else
UIDPROC=`id -u $UIDPROC 2>/dev/null`
echo $PROC $UIDPROC
fi
# Service installed?
if test -f /etc/rc2.d/S*$RCPROC; then
# UID exists?
if test -n "$UIDPROC"; then
if test "$LPASS" -eq 0; then
# Not running
if ! ps -U$UIDPROC -o "%c" | grep -v grep | grep -v
${##*/} | grep -E "$PROC\$" >/dev/null ; then
# Restart it
logger "Restarting $PROC.."
echo "Restarting $PROC.."
/etc/init.d/$RCPROC stop > /dev/null
/etc/init.d/$RCPROC restart
# For services like named, a slight delay is
necessary
sleep 1
fi
elif test "$LPASS" -eq 2; then
killall -q -g "$UIDPROC" "$PROC" 2>/dev/null
else
killall -q -g "$UIDPROC" -9 "$PROC"
2>/dev/null
fi
fi
fi
done
done
-----Message d'origine-----
De : kamel [mailto:[EMAIL PROTECTED]
Envoy� : jeudi 13 juin 2002 13:43
� : [email protected]
Objet : Re: daemontools et ssh
J'ai r�solue mon probl�me, merci
At 09:52 13/06/2002 +0200, kamel latrach wrote:
>Dans le cadre du renforcement du service de messagerie, je teste
>l'utilisation de l'application daemontools ( qui n'exite pas en paquetage
>debian ).
>
>Ainsi, daemontool supervise une s�rrie de services. Il monitor les
>processus et les relance en cas d'interruption.
>
>Ainsi, y en a t il parmis vous qui utilisent daemontools ?
>
>De mon cot�, deamontool monitor mon service de messagerie ( fonctionne
>tres bien )
>
>Ainsi, je voudrais le faire monitor� le service sshd.
>J'utilise l'option -D de sorte � ce que sshd ne passe pas en daemon.
>
>par contre je n'arrive pas � arr�ter sshd par daemontools.
il fallait utilis� exec pour lancer sshd � travers le script de lancement.
>Si qq1 pouvais me renvoyer vers une doc ou avoir une id�e, cela m'aiderai
>bien.
>
>merci
>
>
>--
>To UNSUBSCRIBE, email to [EMAIL PROTECTED]
>with a subject of "unsubscribe". Trouble? Contact
[EMAIL PROTECTED]
--
To UNSUBSCRIBE, email to [EMAIL PROTECTED]
with a subject of "unsubscribe". Trouble? Contact
[EMAIL PROTECTED]
--
To UNSUBSCRIBE, email to [EMAIL PROTECTED]
with a subject of "unsubscribe". Trouble? Contact [EMAIL PROTECTED]