diff options
Diffstat (limited to 'lib/Nagios/Plugin/Config.pm')
-rw-r--r-- | lib/Nagios/Plugin/Config.pm | 7 |
1 files changed, 6 insertions, 1 deletions
diff --git a/lib/Nagios/Plugin/Config.pm b/lib/Nagios/Plugin/Config.pm index 11128dd..dd270e9 100644 --- a/lib/Nagios/Plugin/Config.pm +++ b/lib/Nagios/Plugin/Config.pm | |||
@@ -7,6 +7,7 @@ use base qw(Config::Tiny); | |||
7 | 7 | ||
8 | my $FILENAME1 = 'plugins.ini'; | 8 | my $FILENAME1 = 'plugins.ini'; |
9 | my $FILENAME2 = 'nagios-plugins.ini'; | 9 | my $FILENAME2 = 'nagios-plugins.ini'; |
10 | my $CURRENT_FILE = undef; | ||
10 | 11 | ||
11 | # Config paths ending in nagios (search for $FILENAME1) | 12 | # Config paths ending in nagios (search for $FILENAME1) |
12 | my @NAGIOS_CONFIG_PATH = qw(/etc/nagios /usr/local/nagios/etc /usr/local/etc/nagios /etc/opt/nagios); | 13 | my @NAGIOS_CONFIG_PATH = qw(/etc/nagios /usr/local/nagios/etc /usr/local/etc/nagios /etc/opt/nagios); |
@@ -42,6 +43,7 @@ sub read | |||
42 | die "Cannot find '$FILENAME1' or '$FILENAME2' in any standard location.\n" unless $_[0]; | 43 | die "Cannot find '$FILENAME1' or '$FILENAME2' in any standard location.\n" unless $_[0]; |
43 | } | 44 | } |
44 | 45 | ||
46 | $CURRENT_FILE = $_[0]; | ||
45 | $class->SUPER::read( @_ ); | 47 | $class->SUPER::read( @_ ); |
46 | } | 48 | } |
47 | 49 | ||
@@ -73,7 +75,7 @@ sub read_string | |||
73 | 75 | ||
74 | # Handle properties | 76 | # Handle properties |
75 | if ( /^\s*([^=]+?)\s*=\s*(.*?)\s*$/ ) { | 77 | if ( /^\s*([^=]+?)\s*=\s*(.*?)\s*$/ ) { |
76 | push @{$self->{$ns}->{$1}}, $2; | 78 | push @{$self->{$ns}->{$1}}, $2; |
77 | next; | 79 | next; |
78 | } | 80 | } |
79 | 81 | ||
@@ -85,6 +87,9 @@ sub read_string | |||
85 | 87 | ||
86 | sub write { croak "Write access not permitted" } | 88 | sub write { croak "Write access not permitted" } |
87 | 89 | ||
90 | # Return last file used by read(); | ||
91 | sub np_getfile { return $CURRENT_FILE; } | ||
92 | |||
88 | 1; | 93 | 1; |
89 | 94 | ||
90 | =head1 NAME | 95 | =head1 NAME |