Environment: Centos 6.6
Zabbix Automatic discovery Web site:
[Email protected] ~]# tail-3/etc/zabbix/zabbix_agentd.confuserparameter=web.site_discovery,/etc/zabbix/scripts/ Discovery_web_site.sh Web_site_discoveryuserparameter=web.site_code[*],/etc/zabbix/scripts/discovery_web_ site.sh web_site_code $1userparameter=memory.free,free-m|grep Mem |awk ' {print $4} ' [[email protected] ~]#[[email Protected] ~]# Cat/etc/zabbix/scripts/web.txtwww.baidu.comwww.qq.comwww.51cto.com[[email protected] ~]#[[email Protected] ~]# zabbix_get-s 192.168.31.160-k web.site_discovery
650) this.width=650; "src=" Http://s3.51cto.com/wyfs02/M00/80/47/wKiom1c9HpKBPi-2AAAp-ZVrKt4207.png "title=" 1.png " alt= "Wkiom1c9hpkbpi-2aaap-zvrkt4207.png"/>
[Email protected] ~]# zabbix_get-s 192.168.31.160-k web.site_code[www.baidu.com]200[[email protected] ~]#
650) this.width=650; "src=" Http://s5.51cto.com/wyfs02/M01/80/47/wKiom1c9HqqC-0iWAAARuA7s2G4984.png "title=" 1.png " alt= "Wkiom1c9hqqc-0iwaaarua7s2g4984.png"/>
Create a web_monitor template, Configuration---Templates :
650) this.width=650; "src=" Http://s1.51cto.com/wyfs02/M02/80/47/wKiom1c9HsWwTntXAAB_R3R3lYs056.png "title=" 1.png " alt= "Wkiom1c9hswwtntxaab_r3r3lys056.png"/>
Configuration---Templates (web_status_code_monitor)---discovery---create discovery rule:
650) this.width=650; "src=" Http://s1.51cto.com/wyfs02/M02/80/45/wKioL1c9H9PywZXOAACKVnnnuAE272.png "title=" 1.png " alt= "Wkiol1c9h9pywzxoaackvnnnuae272.png"/>650) this.width=650; src= http://s2.51cto.com/wyfs02/M02/80/47/ Wkiom1c9hwcjkkbjaabehopayvg800.png "title=" 1.png "alt=" Wkiom1c9hwcjkkbjaabehopayvg800.png "/>
Configuration---Templates (web_status_code_monitor)---discovery (1)---Item prototypes (0)---Create Item prototype:
650) this.width=650; "src=" Http://s2.51cto.com/wyfs02/M02/80/45/wKioL1c9IAmijAmBAACSBl_Brqs099.png "style=" float: none; "title=" 1.png "alt=" Wkiol1c9iamijambaacsbl_brqs099.png "/>
650) this.width=650; "src=" Http://s2.51cto.com/wyfs02/M00/80/47/wKiom1c9Hx-yluekAABgl8Xmfk8098.png "style=" float: none; "title=" 2.png "alt=" Wkiom1c9hx-yluekaabgl8xmfk8098.png "/>
Configuration---Templates (web_status_code_monitor)---discovery (1)--- Trigger Prototypes (0)---Create Trigger Prototype:
650) this.width=650; "src=" Http://s1.51cto.com/wyfs02/M02/80/47/wKiom1c9H0nAsZjUAAAx-9A6SXM891.png "style=" float: none; "title=" 1.png "alt=" Wkiom1c9h0naszjuaaax-9a6sxm891.png "/>
650) this.width=650; "src=" Http://s4.51cto.com/wyfs02/M02/80/45/wKioL1c9IDXjvB1wAACNjBMVXKk387.png "style=" float: none; "title=" 2.png "alt=" Wkiol1c9idxjvb1waacnjbmvxkk387.png "/>
650) this.width=650; "src=" Http://s4.51cto.com/wyfs02/M00/80/47/wKiom1c9H0qTBnwyAABgjz3O2F4916.png "style=" float: none; "title=" 3.png "alt=" Wkiom1c9h0qtbnwyaabgjz3o2f4916.png "/>
Configuration---Templates (web_status_code_monitor)---discovery (1)---graph prototypes (0)---Create Graph prototype:
650) this.width=650; "src=" Http://s2.51cto.com/wyfs02/M00/80/45/wKioL1c9IFaQcRJFAACBMKY_1Cs296.png "style=" float: none; "title=" 1.png "alt=" Wkiol1c9ifaqcrjfaacbmky_1cs296.png "/>
650) this.width=650; "src=" Http://s2.51cto.com/wyfs02/M01/80/47/wKiom1c9H2uAnd76AABU2aaCMDU300.png "style=" float: none; "title=" 2.png "alt=" Wkiom1c9h2uand76aabu2aacmdu300.png "/>
Configuration---Host---Zabbix server---Templates---Add:
650) this.width=650; "src=" Http://s5.51cto.com/wyfs02/M02/80/47/wKiom1c9H4LioJcFAABD_8KYH_4608.png "title=" 1.png " alt= "Wkiom1c9h4liojcfaabd_8kyh_4608.png"/>
Configuration---Host---"Zabbix Server"---Discovery (1):
650) this.width=650; "src=" Http://s4.51cto.com/wyfs02/M02/80/47/wKiom1c9H7SRYjQQAABhFr1VeRo211.png "style=" float: none; "title=" 1.png "alt=" Wkiom1c9h7sryjqqaabhfr1vero211.png "/>
650) this.width=650; "src=" Http://s3.51cto.com/wyfs02/M02/80/45/wKioL1c9IKDhDdpuAAB3d2v6ak8082.png "style=" float: none; "title=" 2.png "alt=" Wkiol1c9ikdhddpuaab3d2v6ak8082.png "/>
650) this.width=650; "src=" Http://s3.51cto.com/wyfs02/M01/80/47/wKiom1c9H7WR7NCWAACp1J6AB2w043.png "style=" float: none; "title=" 3.png "alt=" Wkiom1c9h7wr7ncwaacp1j6ab2w043.png "/>
650) this.width=650; "src=" Http://s3.51cto.com/wyfs02/M01/80/45/wKioL1c9IKCQJLy1AAC1PWb5cok586.png "style=" float: none; "title=" 4.png "alt=" Wkiol1c9ikcqjly1aac1pwb5cok586.png "/>
The value returned by the script must be in JSON format
[[email protected] ~]# cat /etc/zabbix/scripts/discovery_web_site.sh###### #cat /etc/ Zabbix/scripts/web_site_code_status#########!/bin/bash#function:monitor tcp connect status from zabbix#license:GPL#version:1.0source /etc/bashrc > /dev/null 2>& 1source /etc/profile > /dev/null 2>&1#/usr/bin/curl -o /dev/null -s -w %{http_code} http://$1/web_dir= "/etc/zabbix/scripts" web_site_discovery () {WEB_ Site= ($ (cat "$Web _dir"/web.txt|grep -v "^#")) printf ' {\ n ' printf ' \ t ' data ': [\ n ' for ((i=0;i<${#WEB_SITE [@]};++i)] {num=$ (echo $ ((${#WEB_SITE [@]}-1)) if [ "$i" != "${num}" ];thenprintf ' \t\t{ \n ' printf "\t\t\t\" {#SITENAME}\ ": \" ${web_site[$i]}\ "},\ N "elseprintf ' \t\t{ \n ' printf " \t\t\t\ "{#SITENAME}\": \ "${web_site[$num]}\"}]}\n "Fi}}web_site_ code () {/usr/bin/curl -o /dev/null -s -w %{http_code} http://$1}case "$" inweb_site_ Discovery) web_site_discovery;; Web_site_code) web_site_code $2;; *) echo "Usage:$0 {web_site_discovery|web_site_code url}";; esac[[email protected] ~]#
650) this.width=650; "src=" Http://s1.51cto.com/wyfs02/M02/80/48/wKiom1c9I4_jz8IYAABgrybxyl8538.png "title=" 1.png " alt= "Wkiom1c9i4_jz8iyaabgrybxyl8538.png"/>
This article from "Pengcheng-soy sauce bottle" blog, declined reprint!
"8", low level discovery discovery for real-time monitoring