Zabbix Monitoring URL return status

Source: Internet
Author: User

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

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.