Всем привет, пишу метрику для системы мониторинга. Но не могу выдернуть нужное мне значение из полученной строки.
#!/usr/bin/python
import os, httplib, urllib, time
api_key = 'fd40a213-552b-4843-8g82-29ce78e217er'
page_id = 'jqn5z3452dhm'
metric_id = 'cxn1222342kv0'
api_base = 'api.statuspage.io'
total_points = (60 / 5 * 24)
for i in range(total_points):
ts = int(time.time()) - (i * 5 * 60)
hostname = "my_domain"
responset = os.system("ping -c 2 -n " + hostname)
params = urllib.urlencode({'data[timestamp]': ts, 'data[responset]': responset})
headers = {"Content-Type": "application/x-www-form-urlencoded", "Authorization": "OAuth " + api_key}
conn = httplib.HTTPSConnection(api_base)
conn.request("POST", "/v1/pages/" + page_id + "/metrics/" + metric_id + "/data.json", params, headers)
response = conn.getresponse()
print "Submitted point " + str(i + 1) + " of " + str(total_points)
time.sleep(1)
Соответственно получаю:
--- my_domain ping statistics ---
2 packets transmitted, 2 received, 0% packet loss, time 1000ms
rtt min/avg/max/mdev = 0.199/0.206/0.213/0.007 ms
Соответственно как достать значение 0.007 ? Спасибо!