Created
November 26, 2017 06:56
-
-
Save audstanley/1b9d5a9edfacbe0c3f0a9e74dc4a750b to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import requests | |
import plotly.plotly as py | |
from time import sleep | |
from plotly.graph_objs import * | |
from datetime import datetime | |
global ipOfNvidia | |
ipOfNvidia = "http://10.8.0.2:4080" | |
payload = { | |
"body":[ | |
{"topic": "record", | |
"action":"read", | |
"recordName": "nload" | |
} | |
] | |
} | |
xArr = [] | |
y1Arr = [] | |
y2Arr = [] | |
count = 0 | |
while count < 86400: | |
request = requests.post(ipOfNvidia, json=payload) | |
d = request.json() | |
dspeed = d["body"][0]["data"]["wifi"]["download"] | |
uspeed = d["body"][0]["data"]["wifi"]["upload"] | |
x = datetime.now() | |
xArr.append(x) | |
if d["body"][0]["data"]["wifi"]["dspeed"][0:1] == "B": | |
dspeed /= 1000 | |
elif d["body"][0]["data"]["wifi"]["dspeed"][0:1] == "M": | |
dspeed *= 1000 | |
if d["body"][0]["data"]["wifi"]["uspeed"][0:1] == "B": | |
uspeed /= 1000 | |
elif d["body"][0]["data"]["wifi"]["uspeed"][0:1] == "M": | |
uspeed *= 1000 | |
y1Arr.append(dspeed) | |
y2Arr.append(uspeed) | |
if count % 120 == 0: | |
DownloadSpeed = Scatter( x=xArr, y=y1Arr , name="Download") | |
UploadSpeed = Scatter( x=xArr, y=y2Arr, name="Upload" ) | |
data = Data( [ DownloadSpeed, UploadSpeed ] ) | |
plot_url = py.plot(data, filename='NvidiaSpeed', fileopt='extend') | |
xArr = [] | |
y1Arr = [] | |
y2Arr = [] | |
print "Download Speed: " + str(dspeed) + " Upload Speed: " + str(uspeed) | |
print "actual: " + d["body"][0]["data"]["wifi"]["dspeed"] | |
count += 1 | |
sleep(1) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment