Rechercher une page de manuel
Nagios::StatusLog.3pm
Langue: en
Version: 2008-11-18 (ubuntu - 07/07/09)
Section: 3 (Bibliothèques de fonctions)
NAME
Nagios::StatusLog, Nagios::(Service|Host|Program)::Status - Perl objects to represent the Nagios status fileDESCRIPTION
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 new(). And similarly, pass in the Version => 3.0 parameter to new() for Nagios version 3.x logs.my $log = Nagios::StatusLog->new( Filename => "/var/cache/nagios/status.dat", Version => 1.0 ); $localhost = $log->host( "localhost" ); print "status of localhost is now ",$localhost->status(),"\n"; $log->update(); print "status of localhost is now ",$localhost->status(),"\n"; # 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 );
METHODS
- new()
- Create a new Nagios::StatusLog instance. The object will be initialized for you (using $self->update()).
Nagios::StatusLog->new( ``/var/opt/nagios/status.log'' ); - update()
- Updates the internal data structures from the logfile.
$log->update(); - service()
- Returns a Nagios::Service::Status object. Input arguments can be a host_name and description list, or a Nagios::Service object.
my $svc_stat = $log->service( ``localhost'', ``SSH'' );
my $svc_stat = $log->service( $localhost_ssh_svc_object );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 - 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.
my @all_services = $log->list_services;
- list_services_on_host()
- Returns an array of services descriptions for a given host.
my @host_services = $log->list_services_on_host($hostname); my @host_services = $log->list_services_on_host($nagios_object);
- host()
- Returns a Nagios::Host::Status object. Input can be a simple host_name, a Nagios::Host object, or a Nagios::Service object.
my $hst_stat = $log->host( 'localhost' );
my $hst_stat = $log->host( $host_object );
my $hst_stat = $log->host( $svc_object );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 - list_hosts()
- Returns a simple array of host names (no objects).
my @hosts = $log->list_hosts;
- info() [Nagios v2 logs only]
- Returns a Nagios::Info::Status object. It only has two methods, created() and version().
my $i = $log->info; printf "Logfile created at %s unix epoch time for Nagios verion %s\n", $i->created, $i->version;
- program()
- Returns a Nagios::Program::Status object. No arguments.
my $prog_st = $log->program;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
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 BEGIN block. The accessor methods are real subroutines, not AUTOLOAD, so making a ton of calls to this module should be fairly quick. Also, update() is set up to only do what it says - updating from a fresh logfile should not invalidate your existing ::Status objects.AUTHOR
Al Tobey <tobeya@tobert.org>SEE ALSO
Nagios::Host Nagios::ServiceContenus ©2006-2024 Benjamin Poulain
Design ©2006-2024 Maxime Vantorre