-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathspeedflux
More file actions
20 lines (15 loc) · 791 Bytes
/
speedflux
File metadata and controls
20 lines (15 loc) · 791 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
#!/usr/bin/env python
# -*- coding: utf-8 -*-
import os
import subprocess
data = subprocess.check_output(["/opt/scripts/speedtest-cli", "--simple"])
data = data.split(" ")
ping = str(data[1])
download = str(float(data[3]) * 1048576)
upload = str(float(data[5]) * 1048576)
ping_post = "curl -i -XPOST \"http://localhost:8086/write?db=uplink\" --data-binary \"ping,link=dfn,host=speedtest.net value=" + ping + "\""
download_post = "curl -i -XPOST \"http://localhost:8086/write?db=uplink\" --data-binary \"download,link=dfn,target=speedtest.net value=" + download + "\""
upload_post = "curl -i -XPOST \"http://localhost:8086/write?db=uplink\" --data-binary \"upload,link=dfn,target=speedtest.net value=" + upload + "\""
os.system(ping_post)
os.system(download_post)
os.system(upload_post)