Add Nagios mode

This commit is contained in:
Benjamin Renard 2014-12-31 10:08:39 +01:00
parent bf57ace811
commit 56ba702200

View file

@ -16,24 +16,29 @@ OWNER=root
GROUP=www-data
DEBUG=0
NAGIOS=0
UPGRADE=0
EXTRACT=0
JUST_DISP=0
function usage() {
echo "Usage : $0 [-v] [-d] [-u]"
echo "Usage : $0 [-v] [-n] [-d] [-u]"
echo " -v Verbose mode"
echo " -n Nagios mode"
echo " -d Download new release"
echo " -u Upgrade installation"
echo " -j Just display current stable version"
echo " -h Display this help"
}
while getopts ":dvhuj" opt; do
while getopts ":dvnhuj" opt; do
case $opt in
v)
DEBUG=1
;;
n)
NAGIOS=1
;;
d)
DOWNLOAD=1
;;
@ -86,6 +91,7 @@ do
break;
elif [ $i -eq $MAX_CHECK ]
then
[ $NAGIOS -eq 1 ] && echo "WARNING : Fail to retrieve current stable version" && exit 1
error="Site du projet injoignable (ou structure du site modifie !!) => Impossible de recuperer le numero de la version stable actuel."
[ $DEBUG -eq 1 ] && echo $error
if [ -f $CACHE_FAILED ]
@ -118,8 +124,21 @@ current="`echo $current|sed 's/-rc$//'`"
current="`echo $current|sed 's/-beta$//'`"
[ $DEBUG -eq 1 ] && echo "Current : $current"
if [ -z "$current" ]
then
[ $NAGIOS -eq 1 ] && echo "UNKNOWN : Fail to retrieve current installed version" && exit 3
echo "ERROR : Fail to retrieve current version !"
exit 3
fi
if [ "$newest" != "$current" ]
then
if [ $NAGIOS -eq 1 ]
then
echo "CRITICAL : A newest version of Roundcube Webmail is available (newest : $newest / current : $current)"
exit 2
fi
if [ $DOWNLOAD -eq 1 ]
then
@ -292,4 +311,5 @@ then
fi
else
[ $DEBUG -eq 1 ] && echo "Pas de changement de version"
[ $NAGIOS -eq 1 ] && echo "OK : Lastest version installed" && exit 1
fi