Voici un script pour verifier l’etat d’une partition /dev/simfs sur une machine virtuelle
#
# Plugin to check simfs disk space
# by christian vallee (cv@valtechnologie.com)
# Nagios script to check simfs usage on linux server
# version 1.1.1
#
##########################################################
##########################################################
# We call them functions because they’re fun
##########################################################
print_help() {
cat << EOF
Linux SimFS Plugin for Nagios
Copyright (c) Christian Vallee (cv@valtechnologie.com)
Version: 1.1.1
Last Modified: 25-02-2014
License: This software can be used for free unless I meet you, then you owe me lunch.
Usage: check_simfs -w [warning %] -c [critical %]
Options:
-w [0-99] = Your warning %. 20 means 20% of your memory can remain before a warning alarm. Do not use the % sign.
-c [0-99] = Your critical %. 10 means 10% of your memory can remain before a critical alarm. Do not use the % sign.
EOF
}
invalid_type() {
echo "\nInvalid $1\n"
print_help
exit 3
}
##############################################
## Suck in the user input
##############################################
while test -n "$1"; do
case $1 in
--help) print_help ; exit 0 ;;
-h) print_help ; exit 0 ;;
-w) WARN=$2; shift ;;
-c) CRIT=$2 ;;
esac
shift
done
##############################################
## Set the defaults if needed
##############################################
[ -z "$WARN" ] && WARN=20
[ -z "$CRIT" ] && CRIT=10
##############################################
## Check user input
##############################################
echo $WARN | grep -v [0-9.] > /dev/null && invalid_type warning
echo $CRIT | grep -v [0-9.] > /dev/null && invalid_type critical
[ “${WARN%.*}” -ge 100 ] && invalid_type warning
[ “${CRIT%.*}” -ge 100 ] && invalid_type critical
[ “${CRIT%.*}” -lt “${WARN%.*}” ] && invalid_type critical
##############################################
## Do the work
## Pull the memory file into awk
## grab the lines we need
## Print the information
##############################################
RESULT=$(df -h | grep simfs | awk -v warn=$WARN -v crit=$CRIT ‘{
len = length($5)
useddiskspace = substr($5, 0, len-1)
}
END {
if ( useddiskspace <= warn ) { result="OK" ; xit="0"}
if ( useddiskspace > warn ) {
if ( useddiskspace <= crit ) { result="WARNING" ; xit="1" }
else if ( useddiskspace > crit ) { result=”CRITICAL” ; xit=”2″ }
}
{print xit” DISK SPACE “result” – “useddiskspace”% ” $0}
}’)
echo ${RESULT#* }
exit ${RESULT%% *}
On ajoute la ligne de commande:
command[check_simfs]=/usr/lib64/nagios/plugins/check_simfs -w 70 -c 90
…
On redemarre le service nrpe