4.服务器添加脚本和配置文件
客户端添加脚本
[root@zabbix /opt/zabbixsh 16:28:31&&123]#pwd /opt/zabbixsh [root@zabbix /opt/zabbixsh 16:28:39&&124]#ls chk_disk.sh 脚本内容: #!/bin/bash #使用UserParameter=disk.all,/usr/local/zabbix/scripts/chk_disk.sh check_disk #返回0严重 返回1警告 返回2 OK ##使用UserParameter=disk.all.inode,/usr/local/zabbix/scripts/chk_disk.sh check_disk_inode #返回0严重 返回1警告 返回2 OK DEBUG=0 function check_disk(){ row=`df -Ph |wc -l` (( DEBUG )) && echo $row n=() for i in `seq 2 $row` do (( DEBUG )) && echo $i ava=`df -Ph |sed -n "$i"p|awk '{print $4}'` u_per=`df -Ph |sed -n "$i"p|sed -n "s/\%//"p|awk '{print $5}'` p_p=`df -h -P|sed -n "$i"p|awk '{print $6}'` ((DEBUG)) && echo "ava ${ava} , u_per ${u_per} , p_p ${p_p}" if [ ! -n "$(echo $u_per| sed -n "/^[0-9]\+$/p")" ] then continue fi if [ "$u_per" -gt "94" ];then n[$i]=0 elif [ "$u_per" -gt "89" ];then n[$i]=1 else n[$i]=2 fi done echo ${n[*]} | sed "s/ /\n/g" | sort -n | head -n1 } function check_disk_inode(){ row=`df -iPh |wc -l` n=() for i in `seq 2 $row` do ava=`df -iPh |sed -n "$i"p|awk '{print $4}'` u_per=`df -iPh |sed -n "$i"p|sed -n "s/\%//"p|awk '{print $5}'` p_p=`df -ih -P|sed -n "$i"p|awk '{print $6}'` ((DEBUG)) && echo "ava ${ava} , u_per ${u_per} , p_p ${p_p}" if [ ! -n "$(echo $u_per| sed -n "/^[0-9]\+$/p")" ] then continue fi if [ "$u_per" -gt "94" ];then n[$i]=0 elif [ "$u_per" -gt "89" ];then n[$i]=1 else n[$i]=2 fi done echo ${n[*]} | sed "s/ /\n/g" | sort -n | head -n1 } if [ "$1" == "check_disk" ] then check_disk fi if [ "$1" == "check_disk_inode" ] then check_disk_inode fi if [ "$1" == "" ] then echo "usage:{check_disk|check_disk_inode}" fi
客户端添加zabbix_agentd配置文件
[root@zabbix /opt/zabbix/etc/zabbix_agentd.conf.d 16:33:10&&139]#pwd /opt/zabbix/etc/zabbix_agentd.conf.d [root@zabbix /opt/zabbix/etc/zabbix_agentd.conf.d 16:33:11&&140]#ls crond.conf disk.conf crond.conf内容: UserParameter=crond.ping,/sbin/pidof crond | wc -l disk.conf内容: UserParameter=disk.all,/opt/zabbixsh/chk_disk.sh check_disk UserParameter=disk.all.inode,/opt/zabbixsh/chk_disk.sh check_disk_inode
重启zabbix客户端
查看不支持项是否已经支持