My side uses the CDN of the net to do the acceleration, then has a bunch of interfaces can call the singleton query, the network House provides all channels to query together, the CDN above all is the money, slightly monitors or is very necessary. API Information Format: Https://myview.chinanetcenter.com/api/bandwidth-channel.action?u=xxxx&p=xxxx&cust=xxx&date =xxxx&channel=xxxxxx;xxxxx&isexactmatch=false®ion=xxxx&isp=xxxx&resulttype=xxxx& FORMAT=XXX&STARTDATE=XXXX&ENDDATE=XXXX Description: You and P are required, p is the CDN background settings myview Password, others can be default or not selected; Channel: Channel information; The default is all. ISP: carrier bandwidth; default is all. StartDate and EndDate: The time of the query, not the default is all, and this time also has a rule, is the month and time before using%20 transcoding: For example (2013-01-01%2010:10 is 2013-01-01 10:10) Its API documentation can be consulted for customer service.
1, first import BS view return data structure:
Start Viewing Data scripts:
[[email protected] python]# cat check_cndbindwaith.py #coding =utf-8import urllib ,urllib2from bs4 import beautifulsoupimport datetimeimport sysusername = " xxx "password = " xxxx "Now_time=datetime.datetime.now () starttime= (now_time - Datetime.timedelta (seconds=300)). Strftime ('%y-%m-%d %h:%m ') starttimeformat = starttime.split () [ 0]+ "%20" +starttime.split () [1]endtime= (Datetime.datetime.now ()). Strftime ('%y-%m-%d %h:%m ') Endtimtformat = endtime.split () [0]+ "%20" +endtime.split () [1]url = "Https://myview.chinanetcenter.com/api /bandwidth-channel.action?u=%s&p=%s&startdate=%s&enddate=%s " % (Username,password, Starttimeformat,endtimtformat) Try: html = urllib2.urlopen (url, timeout=5 ) Except urllib2. HTTPERROR AS ERR:    PRINT STR (ERR) soup = beautifulsoup (HTML) Print soup
See results and value:
[[Email protected] python]# python check_cndbindwaith.py markup_type= Markup_type)) <?xml version= "1.0" encoding= "Utf-8"?>Iv. Zabbix Agent writes scripts and collects data:
[Email protected] scripts]# vim/usr/local/zabbix/etc/zabbix_agentd.confuserparameter=cdn,/usr/bin/python/usr/ local/zabbix/scripts/check_cdnbindwaitch.py
Five. Add Item:
650) this.width=650; "src=" Http://s1.51cto.com/wyfs02/M01/7A/4D/wKioL1anJQOwkk-sAABddOJ9NHc598.png "title=" QQ picture 20160126154842.png "alt=" Wkiol1anjqowkk-saabddoj9nhc598.png "/>
Six: The plot and trigger are added according to their needs:
650) this.width=650; "style=" WIDTH:700PX;HEIGHT:217PX; "src=" http://s4.51cto.com/wyfs02/M02/7A/4E/ Wkiol1anjogwusroaabolza9zfi486.png "title=" qq picture 20160126155520.png "alt=" Wkiol1anjogwusroaabolza9zfi486.png " Border= "0" height= "217" hspace= "0" vspace= "0" width= "/>"
This article is from the "Little Luo" blog, please be sure to keep this source http://xiaoluoge.blog.51cto.com/9141967/1738652
Zabbix Monitor CDN Bandwidth