According to Eric Newton:
> Thanks for the details.  The current code will send an event if there 
> there's a problem running the plugin.

Not confirmed.

  [EMAIL PROTECTED]:~$ svn status -u Products/ZenStatus/zenagios.py
  Status against revision:   2126

Explicitly set zNagiosPath to a non existent path. Then:

  [EMAIL PROTECTED]:~$ ./bin/zenagios run -v 10 -d slime3.wu-wien.ac.at
  DEBUG:zen.zenagios:Updated configCycleInterval config to 30
  DEBUG:zen.zenagios:running '/usr/local/nagios/libexec/check_http -H 
slime3.wu-wien.ac.at -u /Docs/'
  DEBUG:zen.zenagios:Process check_http -H slime3....-u /Docs/  started
  DEBUG:zen.zenagios:Received exit code 126 for: ''
  DEBUG:zen.zenagios:Process check_http -H slime3....-u /Docs/  stopped (126), 
0.034800 elapsed

Only DEBUG entries (no INFO, no WARNING), an no event. Sure, there is
now a "Received exit code 126 for: ''", but that is easy to oversee.

I still think there is a bug in the error handling of the command
execution. The lines in Cmd.processEnded make no sense for me:

  class Cmd:
    [...]
    def processEnded(self, pr):
        self.result = pr
        self.lastStop = time.time()
        if not isinstance(pr, failure.Failure):
            log.debug('Process %s stopped (%s), %f elapsed' % (
                self.name(),
                pr.exitCode,
                self.lastStop - self.lastStart))
            return self
        return pr

because "pr" is *never* a failure.Failure instance.

With my patch, we get in the above example:

  [EMAIL PROTECTED]:~$ ./bin/zenagios run -v 10 -d slime3.wu-wien.ac.at
  DEBUG:zen.zenagios:Updated configCycleInterval config to 30
  DEBUG:zen.zenagios:running '/usr/local/nagios/libexec/check_http -H 
slime3.wu-wien.ac.at -u /Docs/'
  DEBUG:zen.zenagios:Process check_http -H slime3....-u /Docs/  started
  DEBUG:zen.zenagios:Received exit code 126 for: ''
  ERROR:zen.zenagios:A process has ended with a probable error condition: 
process ended with exit code 126.

At least, it is an ERROR entry, thus visible without "-v 10" ;-)

Again my patch, this time against the current version:


-8<---------------------------------------------------------------------

Index: zenagios.py
===================================================================
--- zenagios.py (revision 2126)
+++ zenagios.py (working copy)
@@ -88,6 +88,7 @@
 
     def processEnded(self, reason):
         "notify the starter that their process is complete"
+        self.reason = reason    # can be a failure.Failure instance
         self.exitCode = reason.value.exitCode
         log.debug('Received exit code %s for: %r' % (self.exitCode, 
self.output))
         self.output = [s.strip() for s in self.output.split('\n')][0]
@@ -267,15 +268,19 @@
 
 
     def processEnded(self, pr):
+        """ return value goes to znagios.finished
+            can be a Cmd or failure.Failure instance"""
+        reason, pr.reason = pr.reason, None        # del attribute; needed?
         self.result = pr
         self.lastStop = time.time()
-        if not isinstance(pr, failure.Failure):
+        if isinstance(reason, failure.Failure) and pr.exitCode != 0:
+           return reason
+        else:
             log.debug('Process %s stopped (%s), %f elapsed' % (
                 self.name(),
                 pr.exitCode,
                 self.lastStop - self.lastStart))
             return self
-        return pr
 
 
     def updateConfig(self,device,ipAddress, username, password,

-8<---------------------------------------------------------------------


\wlang{}

-- 
[EMAIL PROTECTED]                Fax: +43/1/31336/9207
Zentrum fuer Informatikdienste, Wirtschaftsuniversitaet Wien, Austria
_______________________________________________
zenoss-users mailing list
[email protected]
http://lists.zenoss.org/mailman/listinfo/zenoss-users

Reply via email to