标签:printf 文件系统 mic 参数 ISE sed -n length 自定义 file
vi Linux_mountfilename_discovery.sh
portarray=(`mount |grep "^/" |grep -E "ext3|reiserfs|ext4|xfs" |awk ‘{print $3}‘`)
#portarray=(`netstat -tnlp|egrep -i "$1"|awk {‘print $4‘}|awk -F‘:‘ ‘{if ($NF~/^[0-9]*$/) print $NF}‘|sort|uniq`)
length=${#portarray[@]}
printf "{\n"
printf ‘\t‘"\"data\":["
for ((i=0;i<$length;i++))
do
printf ‘\n\t\t{‘
printf "\"{#FILENAME}\":\"${portarray[$i]}\"}"
if [ $i -lt $[$length-1] ];then
printf ‘,‘
fi
done
printf "\n\t]\n"
printf "}\n"
vim Linux_mountfilename_status.sh
filename=$1
#判断是否为空
if [ "$1" == "" ]; then
echo "1"
else
#判断是否执行命令成功
null1=`df $1 |sed -n 2p |awk ‘{print $NF}‘ /dev/null 2>&1;echo $?`
if [ $null1 -eq 0 ]; then
#判断挂载的文件系统是否异常
mount1=`echo $1`
df1=`df $1 |sed -n 2p |awk ‘{print $NF}‘`
if [ $mount1 = $df1 ]; then
echo "0"
else
echo "2"
fi
else
echo "1"
fi
fi
vim Linux_mount.conf
UserParameter=linux.mountfilename.discovery,/etc/zabbix/scripts/Linux_mountfilename_discovery.sh
UserParameter=linux.mountfilename.status[*],/etc/zabbix/scripts/Linux_mountfilename_status.sh $1
略
标签:printf 文件系统 mic 参数 ISE sed -n length 自定义 file
原文地址:https://www.cnblogs.com/A121/p/13288633.html