Nagios::Passive - submit passive check results to nagios


NAME

Nagios::Passive - submit passive check results to nagios

Back to Top


SYNOPSIS

  my $nw = Nagios::Passive->create(
    command_file => $command_file,
    service_description => $service_description,
    check_name => $check_name,
    host_name  => $hostname,
    return_code => 0, # 1 2 3 
    output => 'looks (good|bad|horrible) | performancedata'
  );
  $nw->submit;

Back to Top


DESCRIPTION

This is the factory class, currently it creates either a Nagios::Passive::CommandFile or a Nagios::Passive::ResultPath object. Which object is created depends on the keys of the hash you supply to the the create method.

Back to Top


FACTORY METHODS

create( %ARGS )

This method returns either a Nagios::Passive::CommandFile or a Nagios::Passive::ResultPath object.

If there is a key named

object ist created.

Other required keys are host_name and check_name.

host_name is the hostname for which you want to report a check result to nagios.

The typical output of a nagios plugin looks like this:

    CHECK_NAME STATUS - MESSAGE

CHECK_NAME is replaced by check_name. MESSAGE is replaced by output.

STATUS can either be set by setting return_code to 0,1,2 or 3 (See nagios documentation for details) or by using the set_thresholds and set_status methods. return_code default's to 0 if not set somehow.

service_description is optional, if it's omitted the check result belongs to the host check of host_name.

All of the attributes (except the required ones) can also be set afterwards, by calling the setter methods of the same name, i.e.:

  $nw->return_code(0);
  $nw->output("everything ok");
  # results to: CHECK_NAME OK - everything ok

Back to Top


METHODS

On the object you gathered from the create method, you can perform the following operations.

set_thresholds HASH

  $nw->set_thresholds(
     warning => ':91',
     critical => ':97',
  );

This creates a Nagios::Plugin::Threshold object. It can be used to set the return_code with set_status.

set_status VALUE

Sets the return_code according the the threshold object created with set_thresholds and the given VALUE. For example:

   $nw->set_thresholds(warning => ':4', critical => ':8');
   $nw->set_status(6);
   $nw->output("6 is a warning");
   # return_code is now 1, and the output shown in nagios will be
   # CHECK_NAME WARNING - 6 is a warning

add_perf HASH

This can be used to add performance data to the check result. Read the Nagios::Plugin::Performance manpage to get the idea of how to use this.

submit

This writes the data out. In case of the CommandFile this will write the result into nagios' external_command_file. In case of ResultPath this will drop a file into nagios' check_result_path.

Back to Top


LIMITATIONS

This module is in an early stage of development, the API is likely to brake in the future.

Also it interacts with an undocumented feature of Nagios. This feature may disappear in the future.

Back to Top


DEVELOPMENT

Development takes place on github:

http://github.com/datamuc/Nagios-Passive

Back to Top


AUTHOR

Danijel Tasov, <data@cpan.org>

Back to Top


COPYRIGHT

Copyright (C) 2009, Danijel Tasov

This library is free software; you can redistribute it and/or modify it under the same terms as Perl itself.

Back to Top

 Nagios::Passive - submit passive check results to nagios