Comment créer un script de surveillance des services pour ISPConfig.

Le script

Pour mettre en place ce script, vous pouvez vous connecter en SSH à votre serveur VPS, Éditez un nouveau fichier texte que vous pouvez appeler check-services.sh et copiez le code suivant :

#!/bin/bash

PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin

varproftpd=$(ps aux |awk '{print $11}' |grep proftpd:)

if [ -z $varproftpd ]; then
        /etc/init.d/proftpd start
else
        echo "proftpd .... Running !" > /dev/null
fi

varpostfix=$(ps aux |awk '{print $11}' |grep postfix)

if [ -z $varpostfix ]; then
        /etc/init.d/postfix start
else
        echo "postfix .... Running !"  > /dev/null
fi

varapache=$(ps aux |awk '{print $11}' |grep apache |tail -n 1)

if [ -z $varapache ]; then
        /etc/init.d/apache2 start
else
        echo "apache .... Running !"  > /dev/null
fi

Ce Script est à titre démonstratif, nous ne garantissons pas qu'il marchera pour vous.

Donnez les droits d'exécution à ce Script :

chmod 700 check-services.sh

Le Crontab

Afin de lancer le Script tous les 5 minutes, nous allons créer une tâche Cron :

Lancez la commande :

crontab -e

Ajoutez la ligne :

*/5 * * * * /root/check-services.sh
comment_creer_un_script_de_surveillance_des_services_pour_ispconfig.txt · Dernière modification: 2011/11/25 15:40 (modification externe)
Haut de page
CC Attribution-Noncommercial-Share Alike 3.0 Unported
chimeric.de = chi`s home Valid CSS Driven by DokuWiki do yourself a favour and use a real browser - get firefox!! Recent changes RSS feed Valid XHTML 1.0