Nagios::Interface

Run-time interaction with Nagios
Download

Nagios::Interface Ranking & Summary

Advertisement

  • Rating:
  • License:
  • Perl Artistic License
  • Price:
  • FREE
  • Publisher Name:
  • Sam Vilain
  • Publisher web site:
  • http://search.cpan.org/~samv/

Nagios::Interface Tags


Nagios::Interface Description

Run-time interaction with Nagios Nagios::Interface is a Perl module for basic run-time interaction with Nagios 3 instances. There are no functions to parse or write configuration files (yet?), but it can parse most logfile messages, as well as write control messages and parse the status file for receipts of actions that did not log anything useful.SYNOPSIS use Nagios::Interface; # set up a logfile reader which uses File::Tail my $logfile = Nagios::Interface::Logfile->new( tail => File::Tail->new( name => "/var/log/nagios3/nagios.log", maxinterval => 5, interval => 2, tail => 10, ), ); # read a message, parse it and return it my $log_message = $logfile->get_message; # or if you get loglines from somewhere else, pass to parse_logline $log_message = $logfile->parse_logline($_); # returned messages have roles for commonality and classes for type. print $log_message->host . " is " . ($log_message->up ? "UP" : "DOWN"); if $log_message->does("Nagios::Interface::Alert::Host"); # controlling via the nagios control file my $control = Nagios::Interface::Control->new( filename => "/var/lib/nagios3/rw/nagios.cmd", ); # make any kind of log message to issue as a command... # see Nagios::Interface::ConcreteTypes for a list my $svc_downtime = Nagios::Interface::ScheduleServiceDowntime->new( begin => time, end => time + 15 * 60, fixed => 1, author => ($ENV{LOGNAME}||$ENV{USER}||(getpwuid($ "here's a comment", ); my $entry_time = $control->issue($svc_downtime); # reading the status log my $status = Nagios::Interface::Status->new( filename => "/var/cache/nagios3/status.dat", ); sleep 1 while ( (stat $status->filename) < $issue_time ); $status->parse_file; my @blocks = grep { $_->{entry_time} == $entry_time && $_->{comment} eq "here's a comment", } $status->get_blocks("servicedowntime"); use Set::Object qw(set); my $downtime_ids = set( map { $_->{downtime_id} } @blocks) ); print "Downtime IDs: $downtime_ids\n"; # now cancel the downtime, to complete the example $control->issue( map { Nagios::Interface::DeleteServiceDowntime->new( downtime_id => $_ ) } $downtime_ids->members ); Requirements: · Perl


Nagios::Interface Related Software