.\" Automatically generated by Pod::Man 2.27 (Pod::Simple 3.28) .\" .\" Standard preamble: .\" ======================================================================== .de Sp \" Vertical space (when we can't use .PP) .if t .sp .5v .if n .sp .. .de Vb \" Begin verbatim text .ft CW .nf .ne \\$1 .. .de Ve \" End verbatim text .ft R .fi .. .\" Set up some character translations and predefined strings. \*(-- will .\" give an unbreakable dash, \*(PI will give pi, \*(L" will give a left .\" double quote, and \*(R" will give a right double quote. \*(C+ will .\" give a nicer C++. Capital omega is used to do unbreakable dashes and .\" therefore won't be available. \*(C` and \*(C' expand to `' in nroff, .\" nothing in troff, for use with C<>. .tr \(*W- .ds C+ C\v'-.1v'\h'-1p'\s-2+\h'-1p'+\s0\v'.1v'\h'-1p' .ie n \{\ . ds -- \(*W- . ds PI pi . if (\n(.H=4u)&(1m=24u) .ds -- \(*W\h'-12u'\(*W\h'-12u'-\" diablo 10 pitch . if (\n(.H=4u)&(1m=20u) .ds -- \(*W\h'-12u'\(*W\h'-8u'-\" diablo 12 pitch . ds L" "" . ds R" "" . ds C` "" . ds C' "" 'br\} .el\{\ . ds -- \|\(em\| . ds PI \(*p . ds L" `` . ds R" '' . ds C` . ds C' 'br\} .\" .\" Escape single quotes in literal strings from groff's Unicode transform. .ie \n(.g .ds Aq \(aq .el .ds Aq ' .\" .\" If the F register is turned on, we'll generate index entries on stderr for .\" titles (.TH), headers (.SH), subsections (.SS), items (.Ip), and index .\" entries marked with X<> in POD. Of course, you'll have to process the .\" output yourself in some meaningful fashion. .\" .\" Avoid warning from groff about undefined register 'F'. .de IX .. .nr rF 0 .if \n(.g .if rF .nr rF 1 .if (\n(rF:(\n(.g==0)) \{ . if \nF \{ . de IX . tm Index:\\$1\t\\n%\t"\\$2" .. . if !\nF==2 \{ . nr % 0 . nr F 2 . \} . \} .\} .rr rF .\" .\" Accent mark definitions (@(#)ms.acc 1.5 88/02/08 SMI; from UCB 4.2). .\" Fear. Run. Save yourself. No user-serviceable parts. . \" fudge factors for nroff and troff .if n \{\ . ds #H 0 . ds #V .8m . ds #F .3m . ds #[ \f1 . ds #] \fP .\} .if t \{\ . ds #H ((1u-(\\\\n(.fu%2u))*.13m) . ds #V .6m . ds #F 0 . ds #[ \& . ds #] \& .\} . \" simple accents for nroff and troff .if n \{\ . ds ' \& . ds ` \& . ds ^ \& . ds , \& . ds ~ ~ . ds / .\} .if t \{\ . ds ' \\k:\h'-(\\n(.wu*8/10-\*(#H)'\'\h"|\\n:u" . ds ` \\k:\h'-(\\n(.wu*8/10-\*(#H)'\`\h'|\\n:u' . ds ^ \\k:\h'-(\\n(.wu*10/11-\*(#H)'^\h'|\\n:u' . ds , \\k:\h'-(\\n(.wu*8/10)',\h'|\\n:u' . ds ~ \\k:\h'-(\\n(.wu-\*(#H-.1m)'~\h'|\\n:u' . ds / \\k:\h'-(\\n(.wu*8/10-\*(#H)'\z\(sl\h'|\\n:u' .\} . \" troff and (daisy-wheel) nroff accents .ds : \\k:\h'-(\\n(.wu*8/10-\*(#H+.1m+\*(#F)'\v'-\*(#V'\z.\h'.2m+\*(#F'.\h'|\\n:u'\v'\*(#V' .ds 8 \h'\*(#H'\(*b\h'-\*(#H' .ds o \\k:\h'-(\\n(.wu+\w'\(de'u-\*(#H)/2u'\v'-.3n'\*(#[\z\(de\v'.3n'\h'|\\n:u'\*(#] .ds d- \h'\*(#H'\(pd\h'-\w'~'u'\v'-.25m'\f2\(hy\fP\v'.25m'\h'-\*(#H' .ds D- D\\k:\h'-\w'D'u'\v'-.11m'\z\(hy\v'.11m'\h'|\\n:u' .ds th \*(#[\v'.3m'\s+1I\s-1\v'-.3m'\h'-(\w'I'u*2/3)'\s-1o\s+1\*(#] .ds Th \*(#[\s+2I\s-2\h'-\w'I'u*3/5'\v'-.3m'o\v'.3m'\*(#] .ds ae a\h'-(\w'a'u*4/10)'e .ds Ae A\h'-(\w'A'u*4/10)'E . \" corrections for vroff .if v .ds ~ \\k:\h'-(\\n(.wu*9/10-\*(#H)'\s-2\u~\d\s+2\h'|\\n:u' .if v .ds ^ \\k:\h'-(\\n(.wu*10/11-\*(#H)'\v'-.4m'^\v'.4m'\h'|\\n:u' . \" for low resolution devices (crt and lpr) .if \n(.H>23 .if \n(.V>19 \ \{\ . ds : e . ds 8 ss . ds o a . ds d- d\h'-1'\(ga . ds D- D\h'-1'\(hy . ds th \o'bp' . ds Th \o'LP' . ds ae ae . ds Ae AE .\} .rm #[ #] #H #V #F C .\" ======================================================================== .\" .IX Title "Nagios::StatusLog 3pm" .TH Nagios::StatusLog 3pm "2013-09-24" "perl v5.18.1" "User Contributed Perl Documentation" .\" For nroff, turn off justification. Always turn off hyphenation; it makes .\" way too many mistakes in technical documents. .if n .ad l .nh .SH "NAME" Nagios::StatusLog, Nagios::(Service|Host|Program)::Status \- Perl objects to represent the Nagios status file .SH "DESCRIPTION" .IX Header "DESCRIPTION" Reads the Nagios status log and returns ::Status objects that can be used to get status information about a host. For Nagios version 2.x logs, pass in the Version => 2.0 parameter to \fInew()\fR. And similarly, pass in the Version => 3.0 parameter to \fInew()\fR for Nagios version 3.x logs. .PP .Vb 8 \& my $log = Nagios::StatusLog\->new( \& Filename => "/var/opt/nagios/status.log", \& Version => 1.0 \& ); \& $localhost = $log\->host( "localhost" ); \& print "status of localhost is now ",$localhost\->status(),"\en"; \& $log\->update(); \& print "status of localhost is now ",$localhost\->status(),"\en"; \& \& # for Nagios v2.0 \& my $log = Nagios::StatusLog\->new( \& Filename => "/var/cache/nagios2/status.dat", \& Version => 2.0 \& ); \& \& # for Nagios v3.0 \& my $log = Nagios::StatusLog\->new( \& Filename => "/var/cache/nagios3/status.dat", \& Version => 3.0 \& ); .Ve .SH "METHODS" .IX Header "METHODS" .IP "\fInew()\fR" 4 .IX Item "new()" Create a new Nagios::StatusLog instance. The object will be initialized for you (using \f(CW$self\fR\->\fIupdate()\fR). Nagios::StatusLog\->new( \*(L"/var/opt/nagios/status.log\*(R" ); .IP "\fIupdate()\fR" 4 .IX Item "update()" Updates the internal data structures from the logfile. \f(CW$log\fR\->\fIupdate()\fR; .IP "\fIservice()\fR" 4 .IX Item "service()" Returns a Nagios::Service::Status object. Input arguments can be a host_name and description list, or a Nagios::Service object. .Sp .Vb 2 \& my $svc_stat = $log\->service( "localhost", "SSH" ); \& my $svc_stat = $log\->service( $localhost_ssh_svc_object ); .Ve .Sp Nagios::Service::Status has the following accessor methods (For V1): host_name description status current_attempt state_type last_check next_check check_type checks_enabled accept_passive_service_checks event_handler_enabled last_state_change problem_has_been_acknowledged last_hard_state time_ok current_notification_number time_warning time_critical process_performance_data notifications_enabled latency scheduled_downtime_depth is_flapping plugin_output percent_state_change execution_time time_unknown failure_prediction_enabled last_notification obsess_over_service flap_detection_enabled .IP "\fIlist_services()\fR" 4 .IX Item "list_services()" Returns an array of all service descriptions in the status log. Services that may be listed on more than one host are only listed once here. .Sp .Vb 1 \& my @all_services = $log\->list_services; .Ve .IP "\fIlist_services_on_host()\fR" 4 .IX Item "list_services_on_host()" Returns an array of services descriptions for a given host. .Sp .Vb 2 \& my @host_services = $log\->list_services_on_host($hostname); \& my @host_services = $log\->list_services_on_host($nagios_object); .Ve .IP "\fIserviceproblems()\fR" 4 .IX Item "serviceproblems()" Returns a hash of all services that are not in an \s-1OK\s0 state .Sp .Vb 1 \& my %serviceproblems = $log\->serviceproblems(); .Ve .IP "\fIhost()\fR" 4 .IX Item "host()" Returns a Nagios::Host::Status object. Input can be a simple host_name, a Nagios::Host object, or a Nagios::Service object. .Sp .Vb 3 \& my $hst_stat = $log\->host( \*(Aqlocalhost\*(Aq ); \& my $hst_stat = $log\->host( $host_object ); \& my $hst_stat = $log\->host( $svc_object ); .Ve .Sp Nagios::Host::Status has the following accessor methods (for V1): host_name status last_check last_state_change problem_has_been_acknowledged time_up time_down time_unreachable last_notification current_notification_number notifications_enabled event_handler_enabled checks_enabled flap_detection_enabled is_flapping percent_state_change scheduled_downtime_depth failure_prediction_enabled process_performance_data plugin_output .IP "\fIlist_hosts()\fR" 4 .IX Item "list_hosts()" Returns a simple array of host names (no objects). .Sp .Vb 1 \& my @hosts = $log\->list_hosts; .Ve .IP "\fIlist_hostdowntime()\fR" 4 .IX Item "list_hostdowntime()" Returns a simple array of host downtimes (no objects) .Sp .Vb 1 \& my @hostdowntimes = $log\->list_hostdowntime; .Ve .IP "\fIinfo()\fR [Nagios v2 & v3 logs only]" 4 .IX Item "info() [Nagios v2 & v3 logs only]" Returns a Nagios::Info::Status object. It only has two methods, \fIcreated()\fR and \fIversion()\fR. .Sp .Vb 4 \& my $i = $log\->info; \& printf "Logfile created at %s unix epoch time for Nagios verion %s\en", \& $i\->created, \& $i\->version; .Ve .IP "\fIcontact()\fR [Nagios v3 logs only]" 4 .IX Item "contact() [Nagios v3 logs only]" Returns a Nagios::Contact::Status object. Input can be a simple contact_name, or a Nagios::Contact object. .Sp .Vb 2 \& my $c = $log\->contact( \*(Aqjohn\*(Aq ); \& my $c = $log\->contact( $contact_object ); .Ve .Sp Nagios::Contact::Status has the following accessor methods (for v3): contact_name modified_attributes modified_host_attributes modified_service_attributes host_notification_period service_notification_period last_host_notification last_service_notification host_notifications_enabled service_notifications_enabled .IP "\fIhostcomment()\fR [Nagios v3 logs only]" 4 .IX Item "hostcomment() [Nagios v3 logs only]" Returns a Nagios::Hostcomment::Status object. Input can be a simple host_name, or a Nagios::Host or Nagios::Service object. .Sp .Vb 7 \& my $c = $log\->hostcomment( \*(Aqlocalhost\*(Aq ); \& my $c = $log\->hostcomment( $localhost_object ); \& my $c = $log\->hostcomment( $localhost_service_object ); \& foreach my $id (sort keys %$c) { \& printf "Host %s has a comment[$id] made by %s on %s: %s", \& $c\->{$id}\->host_name, $c\->{$id}\->author, scalar localtime $c\->{$id}\->entry_time, $c\->{$id}\->comment_data; \& } .Ve .Sp Nagios::Hostcomment::Status is a perl \s-1HASH,\s0 keyed with the Nagios comment IDs, where each \s-1ID\s0 has the following accessor methods (for v3): host_name entry_type comment_id source persistent entry_time expires expire_time author comment_data .IP "\fIservicecomment()\fR [Nagios v3 logs only]" 4 .IX Item "servicecomment() [Nagios v3 logs only]" Returns a Nagios::Servicecomment::Status object. Input can be a simple host_name or Nagios::Host object with a service description or Nagios::Service object, or just a Nagios::Service object by itself. .Sp .Vb 7 \& my $c = $log\->servicecomment( \*(Aqlocalhost\*(Aq, \*(AqSSH\*(Aq ); \& my $c = $log\->servicecomment( $localhost_object, $localhost_ssh_svc_object ); \& my $c = $log\->servicecomment( $localhost_ssh_svc_object ); \& foreach my $id (sort keys %$c) { \& printf "Service %s on %s has a comment[$id] made by %s on %s: %s", \& $c\->{$id}\->service_description, $c\->{$id}\->host_name, $c\->{$id}\->author, scalar localtime $c\->{$id}\->entry_time, $c\->{$id}\->comment_data; \& } .Ve .Sp Nagios::Servicecomment::Status is a perl \s-1HASH,\s0 keyed with the Nagios comment IDs, where each \s-1ID\s0 has the following accessor methods (for v3): host_name service_description entry_type comment_id source persistent entry_time expires expire_time author comment_data .IP "\fIhostdowntime()\fR [Nagios v3 logs only]" 4 .IX Item "hostdowntime() [Nagios v3 logs only]" Returns a Nagios::Hostdowntime::Status object. Input can be a simple host_name, or a Nagios::Host or Nagios::Service object. .Sp .Vb 8 \& my $d = $log\->hostdowntime( \*(Aqlocalhost\*(Aq ); \& my $d = $log\->hostdowntime( $localhost_object ); \& my $d = $log\->hostdowntime( $localhost_service_object ); \& foreach my $id (sort keys %$d) { \& printf "Host %s has scheduled downtime[$id] made by %s on %s for %.1f hours [%s \- %s]: %s", \& $d\->{$id}\->host_name, $d\->{$id}\->author, scalar localtime $d\->{$id}\->entry_time, ($d\->{$id}\->duration)/3600.0, \& scalar localtime $d\->{$id}\->start_time, scalar localtime $d\->{$id}\->end_time, $d\->{$id}\->comment; \& } .Ve .Sp Nagios::Hostdowntime::Status is a perl \s-1HASH,\s0 keyed with the Nagios downtime IDs, where each \s-1ID\s0 has the following accessor methods (for v3): host_name downtime_id entry_time start_time end_time triggered_by fixed duration author comment .IP "\fIservicedowntime()\fR [Nagios v3 logs only]" 4 .IX Item "servicedowntime() [Nagios v3 logs only]" Returns a Nagios::Servicedowntime::Status object. Input can be a simple host_name or Nagios::Host object with a service description or Nagios::Service object, or just a Nagios::Service object by itself. .Sp .Vb 8 \& my $c = $log\->servicedowntime( \*(Aqlocalhost\*(Aq, \*(AqSSH\*(Aq ); \& my $c = $log\->servicedowntime( $localhost_object, $localhost_ssh_svc_object ); \& my $c = $log\->servicedowntime( $localhost_ssh_svc_object ); \& foreach my $id (sort keys %$d) { \& printf "Service %s on %s has scheduled downtime[$id] made by %s on %s for %.1f hours [%s \- %s]: %s", \& $d\->{$id}\->service_description, $d\->{$id}\->host_name, $d\->{$id}\->author, scalar localtime $d\->{$id}\->entry_time, ($d\->{$id}\->duration)/3600.0, \& scalar localtime $d\->{$id}\->start_time, scalar localtime $d\->{$id}\->end_time, $d\->{$id}\->comment; \& } .Ve .Sp Nagios::Servicedowntime::Status is a perl \s-1HASH,\s0 keyed with the Nagios downtime IDs, where each \s-1ID\s0 has the following accessor methods (for v3): host_name service_description downtime_id entry_time start_time end_time triggered_by fixed duration author comment .IP "\fIprogram()\fR" 4 .IX Item "program()" Returns a Nagios::Program::Status object. No arguments. .Sp .Vb 1 \& my $prog_st = $log\->program; .Ve .Sp Nagios::Program::Status has the following accessor methods (For V1): program_start nagios_pid daemon_mode last_command_check last_log_rotation enable_notifications execute_service_checks accept_passive_service_checks enable_event_handlers obsess_over_services enable_flap_detection enable_failure_prediction process_performance_data .SH "STRUCTURE" .IX Header "STRUCTURE" This module contains 4 packages: Nagios::StatusLog, Nagios::Host::Status, Nagios::Service::Status, and Nagios::Program::Status. The latter 3 of them are mostly generated at compile-time in the \s-1BEGIN\s0 block. The accessor methods are real subroutines, not \s-1AUTOLOAD,\s0 so making a ton of calls to this module should be fairly quick. Also, \fIupdate()\fR is set up to only do what it says \- updating from a fresh logfile should not invalidate your existing ::Status objects. .SH "AUTHOR" .IX Header "AUTHOR" Al Tobey .SH "SEE ALSO" .IX Header "SEE ALSO" Nagios::Host Nagios::Service