[Nagiosplug-help] Intermittent (null) result

Holger Weiß holger at CIS.FU-Berlin.DE
Sun Aug 8 13:02:55 CEST 2010


* Tony Yarusso <tyarusso at nagios.com> [2010-08-08 01:11]:
> One of my plugins
> (http://exchange.nagios.org/directory/Plugins/Others/check_cap-%
> 252D-check-Common-Alerting-Protocol-feeds/details) works fine normally,
> but once in a while it will return (null) as the status output and
> trigger a Warning state.  Usually this fixes itself on the next check or
> within a few minutes at least.

Well, I guess that happens because one of the libraries you use raises
an exception which you don't catch.

> What sorts of things would be likely to cause that?  Network timeout on
> the HTTP connection perhaps?

I'm not a Python programmer, but AFAICT, the plugin should tell you
which exception was raised the next time that happens if you apply the
following diff.

---------- 8< -------------------------------------------- 8< ----------
--- check_cap.orig	2010-08-08 12:39:26.000000000 +0200
+++ check_cap	2010-08-08 12:52:21.972137767 +0200
@@ -44,7 +44,7 @@
 #
 # ======================================================================================================================
 
-import sys, urllib2, httplib, datetime, getopt
+import sys, urllib2, httplib, datetime, getopt, traceback
 from xml.dom import minidom
 
 level = {
@@ -300,4 +300,9 @@
 	return status
 
 if __name__ == "__main__":
-	sys.exit(main(sys.argv[1:]))
+	try:
+		sys.exit(main(sys.argv[1:]))
+	except Exception, e:
+		traceback.print_tb(sys.exc_traceback)	# Print trace to stderr.
+		traceback.print_exception(Exception, e, None, file=sys.stdout)
+		sys.exit(3)	# Exit UNKNOWN.
---------- 8< -------------------------------------------- 8< ----------

Holger




More information about the Help mailing list