r26400 - in /trunk/libnagios-object-perl/lib/Nagios: Config.pm Object.pm Object/Config.pm StatusLog.pm
ryan52-guest at users.alioth.debian.org
ryan52-guest at users.alioth.debian.org
Fri Oct 31 08:35:07 UTC 2008
Author: ryan52-guest
Date: Fri Oct 31 08:35:03 2008
New Revision: 26400
URL: http://svn.debian.org/wsvn/pkg-perl/?sc=1&rev=26400
Log:
undo accidental commit with the patches applied
Modified:
trunk/libnagios-object-perl/lib/Nagios/Config.pm
trunk/libnagios-object-perl/lib/Nagios/Object.pm
trunk/libnagios-object-perl/lib/Nagios/Object/Config.pm
trunk/libnagios-object-perl/lib/Nagios/StatusLog.pm
Modified: trunk/libnagios-object-perl/lib/Nagios/Config.pm
URL: http://svn.debian.org/wsvn/pkg-perl/trunk/libnagios-object-perl/lib/Nagios/Config.pm?rev=26400&op=diff
==============================================================================
--- trunk/libnagios-object-perl/lib/Nagios/Config.pm (original)
+++ trunk/libnagios-object-perl/lib/Nagios/Config.pm Fri Oct 31 08:35:03 2008
@@ -29,7 +29,7 @@
=head1 NAME
-Nagios::Config - Parser for the Nagios::Object set of perl modules
+Nagios::Config
=head1 DESCRIPTION
@@ -58,7 +58,6 @@
my $cf = Nagios::Config->new( Filename => $configfile );
my $cf = Nagios::Config->new( Filename => $configfile, Version => 1 );
my $cf = Nagios::Config->new( Filename => $configfile, Version => 2 );
- my $cf = Nagios::Config->new( Filename => $configfile, Version => 3 );
=cut
Modified: trunk/libnagios-object-perl/lib/Nagios/Object.pm
URL: http://svn.debian.org/wsvn/pkg-perl/trunk/libnagios-object-perl/lib/Nagios/Object.pm?rev=26400&op=diff
==============================================================================
--- trunk/libnagios-object-perl/lib/Nagios/Object.pm (original)
+++ trunk/libnagios-object-perl/lib/Nagios/Object.pm Fri Oct 31 08:35:03 2008
@@ -309,7 +309,7 @@
=head1 NAME
-Nagios::Object - Creates perl objects to represent Nagios objects
+Nagios::Object
=head1 DESCRIPTION
Modified: trunk/libnagios-object-perl/lib/Nagios/Object/Config.pm
URL: http://svn.debian.org/wsvn/pkg-perl/trunk/libnagios-object-perl/lib/Nagios/Object/Config.pm?rev=26400&op=diff
==============================================================================
--- trunk/libnagios-object-perl/lib/Nagios/Object/Config.pm (original)
+++ trunk/libnagios-object-perl/lib/Nagios/Object/Config.pm Fri Oct 31 08:35:03 2008
@@ -26,7 +26,7 @@
=head1 NAME
-Nagios::Object::Config - Perl objects to represent Nagios configuration
+Nagios::Object::Config
=head1 DESCRIPTION
@@ -41,7 +41,6 @@
Create a new configuration object. If Version is not specified, the already weak
validation will be weakened further to allow mixing of Nagios 1.0 and 2.0 configurations.
For now, the minor numbers of Version are ignored. Do not specify any letters as in '2.0a1'.
-Currently only the features present in Nagios 2 are supported for Nagios 3.
To enable regular expression matching, use either the "regexp_matching" or "true_regexp_matching"
arguments to new(). See enable_regexp_matching() and enable_true_regexp_matching() below.
@@ -138,9 +137,7 @@
=cut
-=begin comment
-
-# COMMENTED OUT NEW PARSER WORK IN PROGRESS
+=item COMMENTED OUT NEW PARSER WORK IN PROGRESS
# this is the new one I'm working on to improve speed and flexibility
sub parse2 {
@@ -204,8 +201,6 @@
}
}
}
-
-=end comment
=cut
Modified: trunk/libnagios-object-perl/lib/Nagios/StatusLog.pm
URL: http://svn.debian.org/wsvn/pkg-perl/trunk/libnagios-object-perl/lib/Nagios/StatusLog.pm?rev=26400&op=diff
==============================================================================
--- trunk/libnagios-object-perl/lib/Nagios/StatusLog.pm (original)
+++ trunk/libnagios-object-perl/lib/Nagios/StatusLog.pm Fri Oct 31 08:35:03 2008
@@ -28,36 +28,18 @@
Service => [qw(
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 time_unknown time_warning time_critical last_notification current_notification_number notifications_enabled latency execution_time flap_detection_enabled is_flapping percent_state_change scheduled_downtime_depth failure_prediction_enabled process_performance_data obsess_over_service plugin_output
service_description modified_attributes check_command event_handler has_been_checked should_be_scheduled check_execution_time check_latency current_state max_attempts last_hard_state_change last_time_ok last_time_warning last_time_unknown last_time_critical performance_data next_notification no_more_notifications active_checks_enabled passive_checks_enabled acknowledgement_type last_update
- check_interval check_options check_period current_event_id current_notification_id current_problem_id last_event_id last_problem_id long_plugin_output notification_period retry_interval
)],
Host => [qw(
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
modified_attributes check_command event_handler has_been_checked should_be_scheduled check_execution_time check_latency current_state last_hard_state check_type performance_data next_check current_attempt max_attempts state_type last_hard_state_change last_time_up last_time_down last_time_unreachable next_notification no_more_notifications acknowledgement_type active_checks_enabled passive_checks_enabled obsess_over_host last_update
- check_interval check_options check_period current_event_id current_notification_id current_problem_id last_event_id last_problem_id long_plugin_output notification_period retry_interval
)],
Program => [qw(
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
modified_host_attributes modified_service_attributes active_service_checks_enabled passive_service_checks_enabled active_host_checks_enabled passive_host_checks_enabled obsess_over_hosts check_service_freshness check_host_freshness global_host_event_handler global_service_event_handler
- active_ondemand_host_check_stats active_ondemand_service_check_stats active_scheduled_host_check_stats active_scheduled_service_check_stats cached_host_check_stats cached_service_check_stats external_command_stats high_external_command_buffer_slots next_comment_id next_downtime_id next_event_id next_notification_id next_problem_id parallel_host_check_stats passive_host_check_stats passive_service_check_stats serial_host_check_stats total_external_command_buffer_slots used_external_command_buffer_slots
)],
- Contact => [qw(
- 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
- )],
- Servicecomment => [qw(
- host_name service_description entry_type comment_id source persistent entry_time expires expire_time author comment_data
- )],
- Hostcomment => [qw(
- host_name entry_type comment_id source persistent entry_time expires expire_time author comment_data
- )],
- Servicedowntime => [qw(
- host_name service_description downtime_id entry_time start_time end_time triggered_by fixed duration author comment
- )],
- Hostdowntime => [qw(
- host_name downtime_id entry_time start_time end_time triggered_by fixed duration author comment
- )],
- Info => [qw( created version )]
+ Info => [qw( created version )]
);
GENESIS: {
@@ -84,17 +66,16 @@
=head1 NAME
-Nagios::StatusLog, Nagios::(Service|Host|Program)::Status - Perl objects to represent the Nagios status file
+Nagios::StatusLog, Nagios::(Service|Host|Program)::Status
=head1 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 new(). And similarly, pass in the
-Version => 3.0 parameter to new() for Nagios version 3.x logs.
+pass in the Version => 2.0 parameter to new().
my $log = Nagios::StatusLog->new(
- Filename => "/var/cache/nagios/status.dat",
+ Filename => "/var/opt/nagios/status.log",
Version => 1.0
);
$localhost = $log->host( "localhost" );
@@ -104,14 +85,8 @@
# for Nagios v2.0
my $log = Nagios::StatusLog->new(
- Filename => "/var/cache/nagios2/status.dat",
+ Filename => "/var/opt/nagios/status.dat",
Version => 2.0
- );
-
- # for Nagios v3.0
- my $log = Nagios::StatusLog->new(
- Filename => "/var/cache/nagios3/status.dat",
- Version => 3.0
);
=head1 METHODS
@@ -148,17 +123,12 @@
}
my $self = bless( {
- LOGFILE => $logfile,
- VERSION => $version,
- INFO => {},
- CONTACT => {},
- PROGRAM => {},
- HOST => {},
- HOSTCOMMENT => {},
- HOSTDOWNTIME => {},
- SERVICE => {},
- SERVICECOMMENT => {},
- SERVICEDOWNTIME => {}
+ LOGFILE => $logfile,
+ VERSION => $version,
+ INFO => {},
+ PROGRAM => {},
+ HOST => {},
+ SERVICE => {}
}, $type );
$self->update();
@@ -174,9 +144,7 @@
sub update {
my $self = shift;
- if ( $self->{VERSION} >= 3 ) {
- return $self->update_v3( @_ );
- } elsif ( $self->{VERSION} >= 2 && $self->{VERSION} < 3 ) {
+ if ( $self->{VERSION} >= 2 ) {
return $self->update_v2( @_ );
}
return $self->update_v1( @_ );
@@ -309,97 +277,6 @@
{( .*? )}
# match the last bracket only if followed by another definition
(?= \s* (?:info|program|host|service) \s* { )
- # capture remaining text (1-2 lines) into $3 for re-processing
- (.*)$
- /xs;
-
- my $entry = '';
- while ( my $line = <$log_fh> ) {
- next if ( $line =~ /^\s*#/ );
- $entry .= $line;
- if ( $entry =~ m/$entry_re/ ) {
- ( my $type, my $text, $entry ) = ( $1, $2, $3 );
- $text =~ s/[\r\n]+\s*/\n/g; # clean up whitespace and newlines
- my %item = map { split /\s*=\s*/, $_, 2 } split /\n/, $text;
- $handlers{$type}->( \%item );
- }
- }
-
- close( $log_fh );
-
- 1;
-}
-
-sub update_v3 ($) {
- my $self = shift;
-
- # be compatible with StatusLog which makes sure that references
- # held in client code remain valid during update (also prevents
- # some memory leaks)
- sub _copy3 {
- my( $from, $to ) = @_;
- foreach my $key ( keys %$from ) {
- $to->{$key} = $from->{$key};
- }
- }
-
- my %handlers = (
- hoststatus => sub {
- my $item = shift;
- my $host = $item->{host_name};
- if ( !exists $self->{HOST}{$host} ) {
- $self->{HOST}{$host} = {};
- }
- _copy3( $item, $self->{HOST}{$host} );
- },
- servicestatus => sub {
- my $item = shift;
- my $host = $item->{host_name};
- my $svc = $item->{service_description};
-
- if ( !exists $self->{SERVICE}{$host}{$svc} ) {
- $self->{SERVICE}{$host}{$svc} = {};
- }
- _copy3( $item, $self->{SERVICE}{$host}{$svc} );
- },
- info => sub {
- _copy3( shift, $self->{INFO} );
- },
- programstatus => sub {
- _copy3( shift, $self->{PROGRAM} );
- },
- contactstatus => sub {
- _copy3( shift, $self->{CONTACT} );
- },
- servicecomment => sub {
- _copy3( shift, $self->{SERVICECOMMENT} );
- },
- hostcomment => sub {
- _copy3( shift, $self->{HOSTCOMMENT} );
- },
- servicedowntime => sub {
- _copy3( shift, $self->{SERVICEDOWNTIME} );
- },
- hostdowntime => sub {
- _copy3( shift, $self->{HOSTDOWNTIME} );
- }
-
- );
-
- my $log_fh = gensym;
- open( $log_fh, "<$self->{LOGFILE}" )
- || croak "could not open file $self->{LOGFILE} for reading: $!";
-
- # change the first line of the RE to this:
- # (info|programstatus|hoststatus|servicestatus|contactstatus|servicecomment|hostcomment|servicedowntime|hostdowntime) \s* {(
- # to make it a bit more careful, but it has a measurable cost on runtime
- my $entry_re = qr/
- # capture the type into $1
- (\w+) \s*
- # capture all of the text between the brackets into $2
- {( .*? )}
- # match the last bracket only if followed by another definition
- (?=(?: \s* (?:info|programstatus|hoststatus|servicestatus|contacstatus|servicecomment|hostcomment|servicedowntime|hostdowntime) \s* { | \Z) )
# capture remaining text (1-2 lines) into $3 for re-processing
(.*)$
/xs;
More information about the Pkg-perl-cvs-commits
mailing list