https://www.zabbix.com/documentation/4.0/_export/xhtml/zh/manual/web_monitoring
#!/usr/bin/python
# coding: UTF-8
import StringIO
import pycurl
import sys
import os
class Test:
def __init__(self):
self.contents = ‘‘
def body_callback(self,buf):
self.contents = self.contents + buf
def test_gzip(input_url):
t = Test()
#gzip_test = file("gzip_test.txt", ‘w‘)
c = pycurl.Curl()
c.setopt(pycurl.WRITEFUNCTION,t.body_callback)
c.setopt(pycurl.ENCODING, ‘gzip‘)
c.setopt(pycurl.URL,input_url)
c.perform()
http_code = c.getinfo(pycurl.HTTP_CODE)
http_conn_time = c.getinfo(pycurl.CONNECT_TIME)
http_pre_tran = c.getinfo(pycurl.PRETRANSFER_TIME)
http_start_tran = c.getinfo(pycurl.STARTTRANSFER_TIME)
http_total_time = c.getinfo(pycurl.TOTAL_TIME)
http_size = c.getinfo(pycurl.SIZE_DOWNLOAD)
#此处可选多个,因为需要所以只选了TOTAL_TIME
print " %f"%(http_total_time)
if __name__ == ‘__main__‘:
input_url = sys.argv[1]
test_gzip(input_url)
#添加内容
UserParameter=url.state[*],/etc/zabbix/url-status.py $1
service zabbix-agent restart
原文:https://www.cnblogs.com/xuewenlong/p/12882213.html