1
0
Fork 0

nagios/diskstats: status unknown when device not found

This commit is contained in:
Chl 2024-07-31 14:40:56 +02:00
parent f5f7727c5b
commit 70c9730237

View file

@ -71,6 +71,7 @@ fi
while getopts hd:i:I: OPT; do
case "$OPT" in
'd')
DEVICE_FOUND=0
while read \
MAJOR MINOR DEVICE_NAME \
READS_COMPLETED READS_MERGED SECTORS_READ TIME_SPENT_READING \
@ -83,6 +84,7 @@ while getopts hd:i:I: OPT; do
do
case "$DEVICE_NAME" in
$OPTARG)
DEVICE_FOUND=1
# Checking the thresholds
if [ -n "$THRESHOLD_IO_IN_PROGRESS_CRITICAL" ] && [ "$IO_IN_PROGRESS" -gt "$THRESHOLD_IO_IN_PROGRESS_CRITICAL" ]; then
OUTPUT_EXIT_STATUS=$STATE_CRITICAL
@ -117,6 +119,16 @@ while getopts hd:i:I: OPT; do
;;
esac
done < /proc/diskstats
# Check if the device requested has been found.
if [ "$DEVICE_FOUND" -lt 1 ]; then
echo "UNKNOWN device '$OPTARG' not found."
exit $STATE_UNKNOWN
fi
;;
'h')
usage
exit 0
;;
'i')
@ -134,6 +146,8 @@ while getopts hd:i:I: OPT; do
esac
done
# Should we check if no device has been requested ? Overkill ?
# Final ouput
case "$OUTPUT_EXIT_STATUS" in
'0')