Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import requests, psutil
- import time
- import datetime
- thing_name = "6d073d05-beagleDeagle"
- def dweet(thing, **vals):
- url = "http://dweet.io/dweet/for/{}".format(thing)
- requests.post(url, params=vals)
- def get_uptime():
- with open("/proc/uptime", "r") as f:
- raw = f.read()
- seconds = float(raw.split()[0])
- return seconds
- while True:
- uptime = get_uptime()
- uptime_datetime = datetime.datetime.fromtimestamp(uptime)
- uptime_datetime.strftime("%H:$M:$S")
- load = psutil.cpu_percent(interval=2)
- mem = psutil.virtual_memory()[2]
- dweet(thing_name, uptime=uptime, cpu_load=load, memory=mem)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement