Skip to content

Instantly share code, notes, and snippets.

@Sean-Bradley
Created August 17, 2019 13:36
Show Gist options
  • Save Sean-Bradley/5c508baf1681403b62f950c0079cd22a to your computer and use it in GitHub Desktop.
Save Sean-Bradley/5c508baf1681403b62f950c0079cd22a to your computer and use it in GitHub Desktop.
import subprocess
import time
while 1:
cmd = '/opt/vc/bin/vcgencmd measure_temp'
process = subprocess.Popen(cmd, stdout=subprocess.PIPE, shell=True)
output, error = process.communicate()
tempC = output.split("=")[1].replace("'C", "").strip()
#print(tempC)
cmd = 'zabbix_sender -z 127.0.0.1 -s "raspberrypi" -k "pitemp" -o "%s" ' % (tempC)
print(cmd)
process = subprocess.Popen(cmd, stdout=subprocess.PIPE, shell=True)
output, error = process.communicate()
print(output)
time.sleep(5)
@Sean-Bradley
Copy link
Author

To keep this process running in the background after you close your ssh session, run it in screen.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment