The Perl Toolchain Summit needs more sponsors. If your company depends on Perl, please support this very important event.

NAME

Nagios::Spool::Writer - drop check results into Nagios' check_result_path.

SYNOPSIS

  my $nw = Nagios::Spool::Writer->new(
    checkresults_dir => $checkresultsdir,
    service_description => $service_description,
    check_name => $check_name,
    host_name  => $hostname,
    return_code => 0, # 1 2 3 
    output => 'looks (good|bad|horrible) | performancedata'
  );
  $nw->write_file;

DESCRIPTION

This module gives you the ability to drop checkresults directly into Nagios' check_result_path.

CONSTRUCTOR

new( %ARGS )

checkresults_dir DIRECTORY

The directory where Nagios' configuration option `check_result_path' points to.

hostname STRING

The hostname on which the check is bound to.

service_description STRING

The service description of the check. This is optional, if you omit it, the result is treated as a check result for the host check of hostname

check_name STRING

The name of the check. A nagios check typically returns a line as follows:

  CHECKNAME STATUS - MESSAGE | PERFORMANCE_DATA

This method sets the value of CHECKNAME.

output STRING

This sets the text after the dash of the nagios output. (see check_name). Currently you have to supply performance data to this method, for example:

  $nw->output('/nagios fetched in 0.1s | time=0.1;1;5')
return_code NUMBER
0 - OK
1 - WARNING
2 - CRITICAL
3 - UNKNOWN

This also sets the value of STATUS (see check_name). It defaults to `0' if omited.

Instead of setting the return_code directly you can use set_thresholds and set_status. (See METHODS).

METHODS

set_thresholds

This set's up an Nagios::Plugin::Threshold object.

  $ns->set_thresholds(
     warning => <rangespec>,
     critical => <rangespec>,
  );

For details see http://nagiosplug.sourceforge.net/developer-guidelines.html#THRESHOLDFORMAT

set_status VALUE

Does value checking of VALUE against the threshold object created with set_thresholds and sets return_code accordingly.

write_file

Write the check_result into Nagios' check_result_path.

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.

AUTHOR

Danijel Tasov, <data@cpan.org>

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.