I have a Raspberry Pi with a temperature sensor connected via GPIO. To pull the data from the sensor I use the following Python script (get-temp.py).
Code: Select all
#!/usr/bin/python3
import sys, Adafruit_DHT
sensor = Adafruit_DHT.AM2302
pin = 4
temperature = round(Adafruit_DHT.read_retry(sensor, pin)[1],2)
if temperature is not None:
sys.stdout.write('Temperature = {0}°C|{0};;;;'.format(temperature))
sys.exit(0)
else:
sys.stdout.write('Failed to get reading.')
sys.exit(3)
However, if I run it using the get_by_ssh plugin it returns exit code 1 (which isn't a valid exit code for the script):bash-4.2$ ssh monitoring@172.16.1.101 -i /etc/icinga2/secure/monitoring /opt/get-temp.py
Temperature = 25.4°C|25.4;;;;
I'm not familiar with how get_by_ssh operates. Why would the result be different with the 2 methods above? Any help would be appreciated.bash-4.2$ ./check_by_ssh -l monitoring -i /etc/icinga2/secure/monitoring -C /opt/get-temp.py -H 172.16.1.101 -E
WARNING - check_by_ssh: Remote command '/opt/get-temp.py' returned status 1
Thanks.