Advertisement
silver2row

Dweet.io and IDeas...hint!

Feb 6th, 2019
276
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.64 KB | None | 0 0
  1. import requests, psutil
  2.  
  3. import time
  4. import datetime
  5.  
  6. thing_name = "6d073d05-beagleDeagle"
  7.  
  8. def dweet(thing, **vals):
  9.     url = "http://dweet.io/dweet/for/{}".format(thing)
  10.     requests.post(url, params=vals)
  11.  
  12. def get_uptime():
  13.     with open("/proc/uptime", "r") as f:
  14.         raw = f.read()
  15.     seconds = float(raw.split()[0])
  16.     return seconds
  17.  
  18. while True:
  19.     uptime = get_uptime()
  20.     uptime_datetime = datetime.datetime.fromtimestamp(uptime)
  21.     uptime_datetime.strftime("%H:$M:$S")
  22.  
  23.     load = psutil.cpu_percent(interval=2)
  24.     mem = psutil.virtual_memory()[2]
  25.  
  26.     dweet(thing_name, uptime=uptime, cpu_load=load, memory=mem)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement