我试图让Zabbix项在FreeBSD上可行,以便从SQUID收集信息。
我有下一个UserParameter:
UserParameter=data.sclient[*], printf "GET cache_object://localhost/purgeng/$2 HTTP/1.0\nAccept */*\n\n" | for i in $(echo "$1" | tr "," "\n" ); do nc -w 3 127.0.0.1 $i ; done | awk '/^[[:space:]]*$$
/ {getline;split($$0, a, / = /);print a[2]} END{if(!NR) print -2}'
但它仅适用于一个端口值,例如:
zabbix_get -s 192.168.1.7 -p 10050 -k data.sclient["1111",distributors/configured]
6
当我尝试使用两个端口值时:
zabbix_get -s 192.168.1.7 -p 10050 -k data.sclient["1111,2222",distributors/configured]
false
请问您能帮助我使用多个端口吗?
答案 0 :(得分:0)
我的问题是for循环设置不正确。
我做了:
UserParameter=data.sclient[*], for i in $(echo $1); do printf "GET cache_object://localhost/purgeng/$2 HTTP/1.0\nAccept */*\n\n" | nc -w 3 127.0.0.1 $i ; done | awk '/^[[:space:]]*$$/ {getline;split($$0, a, / = /);print a[2]} END{if(!NR) print -2}'
$ zabbix_get -s 192.168.1.7 -p 10050 -k data.sclient["1111 2222",distributors/connected]
3
3