需求:因为断电故障,会致使虚机文件系统损坏,最后变成read-only的模式,这种状况影响转码虚机的服务。因此对于read-only文件系统,须要在zabbix监控起来,若是发现哪一个虚机的文件系统是read-only的,要立刻发信报警。bash
处理方法:能够经过脚本和zabbix实现。ide
脚本详细以下:spa
脚本1it
#!/bin/sh
testfile="/test.tmp"
touch $testfile >/dev/null 2&>1
if [ -f "$testfile" ] ; then
rm -f $testfile&&echo "1"
else
echo "0"
fi
ast
脚本2class
#!/bin/bash
for file in `ls /root`
do
if [ -f $file ];then
filew=`ls -l $file|cut -c 3`
if [ $filew = w ];then
echo "1"
exit 1
else
echo "0"
exit 0
fi
fi
done
test
#!/bin/sh
declare -a pid
ro=`mount|awk '{print $6}'|grep ro`
if [ -z $ro ];then
echo "1"
exit 1
else
echo "0"
exit 0
fi
~ awk
3个脚本均可以实现目的。监控