博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
zabbix 通过自定义key完成网卡监控
阅读量:5072 次
发布时间:2019-06-12

本文共 1730 字,大约阅读时间需要 5 分钟。

创建执行脚本:

# cat /etc/zabbix/monitor_scripts/network.sh #!/bin/bash#set -x usage() {        echo "Useage : $0"        echo "eg. sh $0 eth0"        exit 1}if [ $# -lt 1 ]then        usagefieth=$1timer=1in_old=$(cat /proc/net/dev | grep $eth | sed -e "s/\(.*\)\:\(.*\)/\2/g" | awk '{print $1 }')out_old=$(cat /proc/net/dev | grep $eth | sed -e "s/\(.*\)\:\(.*\)/\2/g" | awk '{print $9 }')x=1while [ $x -le 2 ]do        sleep ${timer}        in=$(cat /proc/net/dev | grep $eth | sed -e "s/\(.*\)\:\(.*\)/\2/g" | awk '{print $1 }')        out=$(cat /proc/net/dev | grep $eth | sed -e "s/\(.*\)\:\(.*\)/\2/g" | awk '{print $9 }')        dif_in=$(((in-in_old)/timer))        dif_in=$((dif_in/1024))        dif_out=$(((out-out_old)/timer))        dif_out=$((dif_out/1024))        ct=$(date +"%F %H:%M:%S")        echo "${ct} -- IN: ${dif_in} KByte/s     OUT: ${dif_out} KByte/s"        in_old=${in}        out_old=${out}        x=3doneexit 0

 

# cat /etc/zabbix/monitor_scripts/networkin.sh /etc/zabbix/monitor_scripts/network.sh eth1 |awk '{print $5}'# cat /etc/zabbix/monitor_scripts/networkout.sh /etc/zabbix/monitor_scripts/network.sh eth1 |awk '{print $8}'

 修改配置文件,关联自定义key:

]# grep Include /etc/zabbix/zabbix_agentd.conf ### Option: Include# Include=# Include=/etc/zabbix/zabbix_agentd.userparams.conf# Include=/etc/zabbix/zabbix_agentd/#Include=/etc/zabbix/zabbix_agentd/*.confInclude=/etc/zabbix/zabbix_agentd.d/# cat /etc/zabbix/zabbix_agentd.d/networkInOut.conf UserParameter=networkin,/etc/zabbix/monitor_scripts/networkin.shUserParameter=networkout,/etc/zabbix/monitor_scripts/networkout.sh

 增加自定义模版:Network incoming or outcoming on eth1 

 

查看item:

 

 

 

创建triggers:

查看:

 

创建视图展示:

增加新建的模板并查看效果:

转载于:https://www.cnblogs.com/bass6/p/6894896.html

你可能感兴趣的文章