Monkey Albino

Linux altar53.supremepanel53.com 4.18.0-553.8.1.lve.el8.x86_64 #1 SMP Thu Jul 4 16:24:39 UTC 2024 x86_64
/ lib64/ nagios/ plugins/

//lib64/nagios/plugins/check_fs.sh

#!/bin/bash

set -o pipefail -u

FILE="/tmp/dirty_fs_7Qas9rRW"
DMESG=$(which dmesg)
DMESGOPTS="-T"
GREP=$(which grep)
GREPOPTS="-w"
GREPSTRING="EXT4-fs error"
TAIL=$(which tail)
TAILOPTS="-1"
TOUCH=$(which touch)

[[ -f $FILE ]] && \
printf "\360\237\214\213 " && \
echo "CRITICAL: Filesystem is broken. Restart and repair now." && \
exit 2

CHECK_FS=$($DMESG $DMESGOPTS | $GREP $GREPOPTS "$GREPSTRING" | $TAIL $TAILOPTS)

if [ ! -z "$CHECK_FS" ]
then
    	$TOUCH $FILE 2>/dev/null && \
        printf "\360\237\214\213 " && \
        echo "CRITICAL: Filesystem is broken. Restart and repair now." && \
        exit 2 || \
        printf "\360\237\231\200 " && \
        echo "UNKNOWN: Cannot create temp file $FILE" &&  \
        exit 3
fi

printf "\360\237\222\232 " && \
echo "OK:" "Filesystem is clean." && \
exit 0