Read-Only Partition Check for remote Client
Posted: Mon Mar 18, 2019 8:58 am
Hello All,
I am trying to find a way to make Nagios-XI able to see if some host partition is read-only or not
sample Bash Script :
#Build File List array
FSROEXTRACT=`cat /etc/fstab| egrep "ext" | grep -v "^#"| awk '{ print $2 }'`
FSROLIST=(
$FSROEXTRACT
)
#Check if each file system is writeable
count=0
FSROCHECKTOTAL=0
while [ "x${FSROLIST[count]}" != "x" ]
do
FSROCHECK=`touch ${FSROLIST[count]}/test.txt 2> /dev/null && { rm ${FSROLIST[count]}/test.txt 2> /dev/null; echo "0"; } || echo "1"`
FSROCHECKTOTAL=$(( $FSROCHECKTOTAL + $FSROCHECK ))
if [ "$FSROCHECK" == 1 ] && [ -d "${FSROLIST[count]}" ]; then
echo $CURDATE ${FSROLIST[count]} is read only. >> /tmp/fsrocheck.log
fi
count=$(( $count + 1 ))
done
if [ "$FSROCHECKTOTAL" == 0 ]; then
echo $CURDATE all file systems are writeable. >> /tmp/fsrocheck.log
fi
Regards,
I am trying to find a way to make Nagios-XI able to see if some host partition is read-only or not
sample Bash Script :
#Build File List array
FSROEXTRACT=`cat /etc/fstab| egrep "ext" | grep -v "^#"| awk '{ print $2 }'`
FSROLIST=(
$FSROEXTRACT
)
#Check if each file system is writeable
count=0
FSROCHECKTOTAL=0
while [ "x${FSROLIST[count]}" != "x" ]
do
FSROCHECK=`touch ${FSROLIST[count]}/test.txt 2> /dev/null && { rm ${FSROLIST[count]}/test.txt 2> /dev/null; echo "0"; } || echo "1"`
FSROCHECKTOTAL=$(( $FSROCHECKTOTAL + $FSROCHECK ))
if [ "$FSROCHECK" == 1 ] && [ -d "${FSROLIST[count]}" ]; then
echo $CURDATE ${FSROLIST[count]} is read only. >> /tmp/fsrocheck.log
fi
count=$(( $count + 1 ))
done
if [ "$FSROCHECKTOTAL" == 0 ]; then
echo $CURDATE all file systems are writeable. >> /tmp/fsrocheck.log
fi
Regards,