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 GROUP=www-data
DEBUG=0 DEBUG=0
NAGIOS=0
UPGRADE=0 UPGRADE=0
EXTRACT=0 EXTRACT=0
JUST_DISP=0 JUST_DISP=0
function usage() { function usage() {
echo "Usage : $0 [-v] [-d] [-u]" echo "Usage : $0 [-v] [-n] [-d] [-u]"
echo " -v Verbose mode" echo " -v Verbose mode"
echo " -n Nagios mode"
echo " -d Download new release" echo " -d Download new release"
echo " -u Upgrade installation" echo " -u Upgrade installation"
echo " -j Just display current stable version" echo " -j Just display current stable version"
echo " -h Display this help" echo " -h Display this help"
} }
while getopts ":dvhuj" opt; do while getopts ":dvnhuj" opt; do
case $opt in case $opt in
v) v)
DEBUG=1 DEBUG=1
;; ;;
n)
NAGIOS=1
;;
d) d)
DOWNLOAD=1 DOWNLOAD=1
;; ;;
@ -86,6 +91,7 @@ do
break; break;
elif [ $i -eq $MAX_CHECK ] elif [ $i -eq $MAX_CHECK ]
then 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." 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 [ $DEBUG -eq 1 ] && echo $error
if [ -f $CACHE_FAILED ] if [ -f $CACHE_FAILED ]
@ -118,8 +124,21 @@ current="`echo $current|sed 's/-rc$//'`"
current="`echo $current|sed 's/-beta$//'`" current="`echo $current|sed 's/-beta$//'`"
[ $DEBUG -eq 1 ] && echo "Current : $current" [ $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" ] if [ "$newest" != "$current" ]
then 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 ] if [ $DOWNLOAD -eq 1 ]
then then
@ -292,4 +311,5 @@ then
fi fi
else else
[ $DEBUG -eq 1 ] && echo "Pas de changement de version" [ $DEBUG -eq 1 ] && echo "Pas de changement de version"
[ $NAGIOS -eq 1 ] && echo "OK : Lastest version installed" && exit 1
fi fi