[Nagiosplug-devel] Nagios::Plugin add_message(UNKNOWN, ...

Gerhard Lausser Gerhard.Lausser at consol.de
Fri Oct 9 16:17:39 CEST 2009


> > i'm just curious: why can't i buffer an error message with 
> > $plugin->add_message(UNKNOWN, "could not contact blabla...");
> 
> Not sure what you mean...

subroutine analyze_device {
  # do an inventory of the monitored device
  # collect information about all it's components
  # do a lot of things which require e.g. writing to temp files
  foreach (@components) {
    if (a certain problem found) {
      add_message(UNKNOWN, 'e.g. component xy could not be checked')
      # not good if the plugin is aborted here with nagios_exit 
    } elsif (another problem found) {
      add_message(CRITICAL, 'component xy failed')
    } else {
      add_message(OK, 'component xy fine')
    }
  }
  # cleanup temp files, maybe close database connections
}

main:
prepare_a_lot_of_things();
analyze_device();
cleanup_more();
my ($code, $message) = $plugin->check_messages(join_all => ', ');
$plugin->nagios_exit($code, $message);

My question was: why can i add messages with (OK, WARNING, CRITICAL) and
save them for the final output with nagios_exit, but not messages with an
UNKNOWN level?
For simple plugins, it might be ok to abort the execution with nagios_die in
case of an UNKNOWN situation. But if the plugin is a really big one, i would
like to treat UNKNOWN like any other error.


Gerhard





More information about the Devel mailing list