I used an raspberry pi 3 with the DHT22 Sensor and wrote a little python script.
The script runs fine and without sudo so I dont think its an permission problem. All NRPE checks work from my nagios host except my own script.
I worked my way thru several posts but wasnt able to get it fixed.
log on Nagios Host says: Jun 30 17:52:42 MON1 check_nrpe: Remote 10.0.0.162 accepted a Version 3 Packet
root@MON1:~# /usr/lib/nagios/plugins/check_nrpe -H 10.0.0.162 -c check_users
USERS OK - 2 users currently logged in |users=2;5;10;0
root@MON1:~# /usr/lib/nagios/plugins/check_nrpe -H 10.0.0.162 -c check_temps
NRPE: Unable to read output
Code: Select all
#!/usr/bin/python3
import Adafruit_DHT, sys
DHT_SENSOR = Adafruit_DHT.DHT22
DHT_PIN = 4
#while True:
werte = Adafruit_DHT.read_retry(DHT_SENSOR, DHT_PIN)
temproom = werte[1]
if temproom < 25:
print("OKAY - Temperatur ist {:.1f}".format(temproom))
sys.exit(0)
elif temproom > 25 and temproom < 30:
print("WARNING - Temperatur ist {:.1f}".format(temproom))
sys.exit(1)
elif temproom > 30:
print("CRITICAL - Temperatur ist {:.1f}".format(temproom))
sys.exit(2)
else:
print("UNKNOWN - Fehler beim auslesen")
sys.exit(3)