Created
August 17, 2019 13:36
-
-
Save Sean-Bradley/5c508baf1681403b62f950c0079cd22a to your computer and use it in GitHub Desktop.
This file contains hidden or 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 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) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
To keep this process running in the background after you close your ssh session, run it in
screen
.