Support forum for Nagios Core, Nagios Plugins, NCPA, NRPE, NSCA, NDOUtils and more. Engage with the community of users including those using the open source solutions.
Good afternoon, I developed a plugin in Python to read a value of a presence sensor connected through the serial port with arduino. I used several techniques, the latest version used the pynagios library. I realized that by removing the code that connects the serial port the plugin works normally, but to keep the code snippet in webinterface and returns status WARNING and status NULL. Someone can help me ? Please
Specifically, I think you need to move your "return" statements over in the if and else sections. I am not a python expert, but from what I have read this seems to be the case.
Also, you might like the presentation I did at this year's Nagios World Conference. I did something very similar to what you are doing with Arduinos:
I think not, because I run manually and works normally. In this example that I said the passage that communicates with the serial port and I configured the manual value
Can you give us some examples of this working and not working from the cli, along with the associated exit codes after each run?
Nagios-Plugins maintainer exclusively, unless you have other C language bugs with open-source nagios projects, then I am happy to help! Please pm or use other communication to alert me to issues as I no longer track the forum.
#!/usr/bin/python
import pynagios
import serial
from pynagios import Plugin, Response
class MyCheck(Plugin):
def check(self):
ser = serial.Serial('/dev/ttyACM0',9600,timeout=0)
if str(ser.read()) == '1':
return Response(pynagios.CRITICAL, "Intrusos Detectados")
else:
return Response(pynagios.OK, "Sem Ameacas")
if __name__ == "__main__":
# Instantiate the plugin, check it, and then exit
MyCheck().check().exit()