|
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
|
#!/bin/bash # Script to fetch nginx statuses for tribily monitoring systems web=('www.baidu.com' 'www.hao123.com')
function get_web(){
length=${#web[@]}
printf "{\n"
printf '\t'"\"data\":["
for ((i=0;i<$length;i++))
do
printf '\n\t\t{'
printf "\"{#NAME}\":\"${web[$i]}\"}"
if [ $i -lt $[$length-1] ];then
printf ','
fi
done
printf "\n\t]\n"
printf "}\n"
}function web_site_code()
{ /usr/bin/curl -I -m 10 -o /dev/null -s -w %{http_code} "$1"
}$1 $2###3备注[[email protected] ~]# bash zabbix.sh get_web
{ "data":[
{"{#NAME}":"www.baidu.com"},
{"{#NAME}":"www.hao123.com"}
]
}[[email protected] ~]# bash zabbix.sh web_site_code www.baidu.com
200自动发现清单填写json字符串需要的函数,监控原型填写触发器的规则,监控项原型传的参数为自动发现规则的变量,下面是监控项原型的变量自动发现清单变量或者键值填写get_web,监控项原型填写web_site_code{#name}
|
本文转自 小小三郎1 51CTO博客,原文链接:http://blog.51cto.com/wsxxsl/2051483,如需转载请自行联系原作者