Reference http://john88wang.blog.51cto.com/2165294/1565973
cd /usr/local/zabbix/bin[[email protected] bin]# cat warn_web.py#!/usr/bin/env python# -*- coding: utf-8 -*-import subprocessimport jsonargs = "awk -f ' ' ' {print $1} ' /usr/local/zabbix/scripts/warn.txt ' t = subprocess. Popen (args, shell=true, stdout=subprocess. PIPE). Communicate () [0]lwarns = []for mongo in t.split (' \ n '): If len (MONGO) != 0: lwarns.append ({' {#WARN_HOST} ': mongo}) print json.dumps ({' Data ': lwarns}, indent=4, separators= (', ', ': ') ') [[ Email protected] bin]# cat warn_web.py#!/usr/bin/env python# -*- coding: utf-8 -*-import subprocessimport jsonargs = ' awk -f ' ' ' {print $1} ' /usr/local/zabbix/scripts/warn.txt ' t = subprocess. Popen (args, shell=true, stdout=subprocess. PIPE). Communicate () [0]lwarns = []for mongo in t.split (' \ n '): If len (MONGO) != 0: lwarns.append ({' {#WARN_HOST} ': mongo}) print json.dumps ({' Data ': lwarns}, indent=4, separators= (', ', ': ') ') [[ email protected] bin]# cat warn_monitor.py #!/usr/bin/env python# -*- Coding: utf-8 -*-import urllib2,sysimport jsonif len (SYS.ARGV) == 2: argv1 = sys.argv[1]def http_get (): url = argv1 # page address response = urllib2.urlopen (URL) # Call Urllib2 to send a GET request to the server return response.read () # Gets the page information returned by the server Ret = http_get () retj=json.loads (ret) if retj[' action '] ==  " None ": print 0else: print 1cat /usr/local/zabbix/ Etc/zabbix_agentd.conf.d[[email protected] zabbix_agentd.conf.d]# cat warn_status.conf userparameter=get_warn_name,/usr/local/zabbix/bin/warn_web.pyuserparameter=get_warn_status[*],/usr/local /zabbix/bin/warn_monitor.py $1
Simple judgment.
This article from "Want to have a dream, in case the realization of" blog, declined reprint!
Zabbix Monitoring URL return status