zabbix如何使用自定义的脚本来获取数据并展示
启用配置:
1
2
3
4
5
6
7
8
|
[root@
test
zabbix]
# pwd
/etc/zabbix
[root@
test
zabbix]
# cat zabbix_agentd.conf |grep -i include
Include=
/etc/zabbix/zabbix_agentd
.conf.d/
[root@
test
zabbix]
# ls
zabbix_agentd.conf zabbix_agentd.conf.d
[root@
test
zabbix]
# cat zabbix_agentd.conf.d/ecqun_disk.conf
UserParameter=userdef.dev.io[*],
/usr/local/bin/zbx_disk_io
.sh $1 $2
|
对应的脚本:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
|
[root@
test
zabbix]
# cat /usr/local/bin/zbx_disk_io.sh
#!/bin/bash
#
case
$1
in
tps)
iostat -d -m |
grep
$2 |
awk
'{print $2}'
;;
read
)
iostat -d -m |
grep
$2 |
awk
'{print $3}'
;;
write)
iostat -d -m |
grep
$2 |
awk
'{print $4}'
;;
*)
echo
$
"Usage: $0 {tps|read|wirte} {sda|sdb..}"
exit
2
esac
[root@
test
zabbix]
# ll /usr/local/bin/zbx_disk_io.sh
-rwxr-xr-x 1 zabbix zabbix 319 Mar 17 19:13
/usr/local/bin/zbx_disk_io
.sh
|
对应的zabbix frontend配置:
本文转自 pcnk 51CTO博客,原文链接:http://blog.51cto.com/nosmoking/1621566,如需转载请自行联系原作者