Le script ci-dessous permet d'effectuer un controle des systèmes de fichiers, et d'alerter si celui-ci n'est pas monté.
#!/bin/ksh
#
FORMAT=std
while getopts n opt
do
case $opt in
"n") FORMAT=NAGIOS
shift
;;
esac
done
TYPE=`echo $1 |tr '[A-Z]' '[a-z]' `
CRITICAL=0
LISTEDEFAUT=""
verifMontage()
{
TYPE=$1
#lsfs -v $TYPE 2>/dev/null|grep -v Mount |while read nomlv nodename mountpoint reste
lsfs -c -v $TYPE 2>/dev/null|grep -v MountPoint |awk 'FS=":" { print $2,$1,$8,$4 }'| while read nomlv mountpoint AutoMount nodename reste
do
if test "$AutoMount" != "yes"
then
continue
fi
df |grep -w $mountpoint > /dev/null 2>&1
if test $? -ne 0
then
if test "$FORMAT" = "NAGIOS"
then
LISTEDEFAUT="$mountpoint=indisponible.$LISTEDEFAUT"
else
echo "CRITICAL : $mountpoint($nomlv) non disponible."
fi
CRITICAL=2
fi
done
}
# # # ### # #
## ## # # # ## #
# # # # # # # # # #
# # # # # # # # #
# # ####### # # # #
# # # # # # ##
# # # # ### # #
case "$TYPE" in
"nfs"|"mmfs"|"jfs"|"jfs2")verifMontage $TYPE
;;
"") verifMontage jfs2
verifMontage nfs
verifMontage mmfs
;;
*) echo "Usage : $0 [nfs|mmfs|jfs2|jfs"
exit 1
esac
if test $CRITICAL -eq 2
then
if test "$FORMAT" = "NAGIOS"
then
echo "CRITICAL : $LISTEDEFAUT"
fi
else
echo "OK : Montages disponibles"
fi
exit $CRITICAL