NAME

Nagios::Passive::BulkResult - submit passive check results to nagios' checkresult_dir in one file

SYNOPSIS

my $bulk = Nagios::Passive::BulkResult->new(
  checkresults_dir => '/var/lib/nagios/checkresults',
);
for my $check (@checkresults) {
  my $nw = Nagios::Passive->create(
      checkresults_dir => undef, # the checkresults_dir key is required here
      service_description => $check->{service_description},
      check_name => $check_name,
      host_name  => $check->{hostname},
      return_code => $check->{code},
      output => 'looks (good|bad|horrible) | performancedata'
  );
  $bulk->add($nw);
}
$bulk->submit;

DESCRIPTION

Submitting a huge amount of results with Nagios::Passive::ResultPath has some limits. Typically a checkresult has a size of 200 bytes or so. But the blocksize of most filesystems is about 4K. Therefore a file takes at least 4K of disk space.

Well, disk space is cheap and nagios deletes the file again after it has processed it, but most of the time the checkresults_dir is a memory filesystem. And suddenly you waste a lot of RAM. Also reading one large file is faster than reading thousands of small files.

Nagios can handle multiple check results within one file. This is what this module provides. You just create Nagios::Passive objects with an undefined checkresults_dir and add these to the BulkResult container. When you are done, just call ->submit on the container and one big file is created.