#!/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
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备注
[root@localhost ~]# bash zabbix.sh get_web
{
"data":[
{"{#NAME}":"www.baidu.com"},
{"