4
I created a plugin to monitor an Arduino presence sensor for Nagios. The plugin read values from the serial port in Arduino. The problem is that Nagios does not let the plugin running, it executes takes the values and closes. This way it does not read the data correctly.
#!/usr/bin/python
import os, sys
import serial
ser = serial.Serial('/dev/ttyACM0', 9600, timeout=0)
while True:
if state == "0":
print "OK - Sem Alertas"
sys.exit(0)
elif (str(ser.read()) == '2'):
print "WARNING "
sys.exit(1)
elif (str(ser.read()) == '1'):
print "CRITICAL - Intrusos Detectados"
sys.exit(2)
else:
print "UKNOWN - Parametro Desconhecido"
sys.exit(3)