Nagios::Passive::BulkResult - submit passive check results to nagios' checkresult_dir in one file
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;
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. So 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 a Nagios::Passive objects with an undefined checkresults_dir and add that object to the BulkResult container. When you are done, just call ->submit on the container and one big file is created.
->submit
To install Nagios::Passive, copy and paste the appropriate command in to your terminal.
cpanm
cpanm Nagios::Passive
CPAN shell
perl -MCPAN -e shell install Nagios::Passive
For more information on module installation, please visit the detailed CPAN module installation guide.