TT.pm

filter: Statementstmt 21.0% 100 / 476 Branchbran 10.8% 23 / 212 Conditioncond 5.5% 2 / 36 MC/DCmcdc 0.0% 0 / 23 Subroutinesub 45.9% 17 / 37 Podpod 100% 3 / 3 totaltotal 18.4% 145 / 787 CC 158 SCAR 53.4
CC
158
Cov
17%
_build_template
812.0
_build_dynamic_object_config
420.0
_check_typos
182.0
CRAP 207.9
↑ Summary TT/Input/Nagios.pm »
1 package Monitoring::TT;
2  
3 4 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
4 4 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
5 4 ▶use utf8;
Subroutine BEGIN: called CC=1 SCAR=0.0
6 4 ▶use Pod::Usage;
Subroutine BEGIN: called CC=1 SCAR=0.0
7 4 ▶use Getopt::Long;
Subroutine BEGIN: called CC=1 SCAR=0.0
8 4 ▶use Template;
Subroutine BEGIN: called CC=1 SCAR=0.0
9 4 ▶use Monitoring::TT::Identifier;
Subroutine BEGIN: called CC=1 SCAR=0.0
10 4 ▶use Monitoring::TT::Log qw/error warn info debug trace log/;
Subroutine BEGIN: called CC=1 SCAR=0.0
11 4 ▶use Monitoring::TT::Object;
Subroutine BEGIN: called CC=1 SCAR=0.0
12 4 ▶use Monitoring::TT::Render;
Subroutine BEGIN: called CC=1 SCAR=0.0
13 4 ▶use Monitoring::TT::Utils;
Subroutine BEGIN: called CC=1 SCAR=0.0
14  
15 4 our $VERSION = '1.0.2';
16  
17 #####################################################################
18  
19 =head1 NAME
20  
21 Monitoring::TT - Generic Monitoring Config based on Template Toolkit Templates
22  
23 =head1 DESCRIPTION
24  
25 Generic Monitoring Config based on Template Toolkit Templates
26  
27 =cut
28  
29 #####################################################################
30  
31 =head1 CONSTRUCTOR
32  
33 =head2 new
34  
35 new(%options)
36  
37 =cut
38  
39 3 ▶sub new {
Subroutine new: called CC=4 SCAR=14.0
Pod documented
40 3 my($class, %options) = @_;
41 3 my $self = {
42 tt_opts => {
43 TRIM => 1,
44 RELATIVE => 1,
45 STAT_TTL => 60,
46 STRICT => 1,
47 }
48 };
49 3 bless $self, $class;
50  
51 3 ▶ $self->{'tt_opts'}->{'STRICT'} = 1 if $ENV{'TEST_AUTHOR'};
Branch: 1 branch
BranchTrueFalseTotal
if $ENV{"TEST_AUTHOR"} 0 3 3
52 3 ▶ $self->{'tt_opts'}->{'STRICT'} = 1 if -f '.author';
Branch: 1 branch
BranchTrueFalseTotal
if -f ".author" 0 3 3
53 3 for my $s (@{Monitoring::TT::Identifier::functions('Monitoring::TT::Render')}) {
54 69 $self->{'tt_opts'}->{'PRE_DEFINE'}->{$s} = \&{'Monitoring::TT::Render::'.$s};
55 }
56 3 $Monitoring::TT::Render::tt = $self;
57  
58 3 return $self;
59 }
60  
61 #####################################################################
62  
63 =head1 METHODS
64  
65 =head2 run
66  
67 run config generator and write it to the output folder
68  
69 =cut
70  
71 0 ▶sub run {
Subroutine run: not called CC=12 SCAR=49.0
Pod documented
72 0 my( $self ) = @_;
73 0 ▶ return unless $self->_get_options();
Branch: 1 branch
BranchTrueFalseTotal
unless $self->_get_options 0 0 0
74 0 info('generating config from '.join(', ', @{$self->{'in'}}));
75 0 info('into '.$self->{'out'});
76 0 for my $in (@{$self->{'in'}}) {
77 0 ▶ if(! -d $in.'/.') {
Branch: 1 branch
BranchTrueFalseTotal
unless (-d $in . '/.') 0 0 0
78 0 error($in.': '.$!);
79 0 exit 1;
80 }
81 }
82 0 $self->_run_hook('pre', join(',', @{$self->{'in'}}));
83  
84 # die if output directory already exists
85 0 ▶ if(-e $self->{'out'} and !$self->{'opt'}->{'force'}) {
Branch: 1 branch
BranchTrueFalseTotal
if (-e $self->{"out"} and not $self->{"opt"}{"force"}) 0 0 0
Condition0%0/3
-e $self->{"out"} and not $self->{"opt"}{"force"}
!ll&&!rl&&r
000
MC/DC0%0/2
-e $self->{"out"} and not $self->{"opt"}{"force"}
-e $self->{"out"} not $self->{"opt"}{"force"}
Truth table0%0/3
A and not(B)
A= -e $self->{"out"}B= not $self->{"opt"}{"force"}
ABresult
0X0
100
111
86 0 ▶ my @files = glob($self->{'out'}.'/*');
Subroutine BEGIN: called CC=1 SCAR=0.2
87 0 ▶ if(scalar @files > 0) {
Branch: 1 branch
BranchTrueFalseTotal
if (scalar @files > 0) 0 0 0
88 0 error($self->{'out'}.' does already exist and is not empty. (use --force to overwrite contents)');
89 0 exit 1;
90 }
91 }
92 0 $self->_mkdir_r($self->{'out'});
93  
94 0 ▶ info('using template filter: '.$self->{'opt'}->{'templatefilter'}) if $self->{'opt'}->{'templatefilter'};
Branch: 1 branch
BranchTrueFalseTotal
if $self->{"opt"}{"templatefilter"} 0 0 0
95 0 ▶ info('using contact filter: '.$self->{'opt'}->{'contactfilter'}) if $self->{'opt'}->{'contactfilter'};
Branch: 1 branch
BranchTrueFalseTotal
if $self->{"opt"}{"contactfilter"} 0 0 0
96 0 ▶ info('using host filter: '.$self->{'opt'}->{'hostfilter'}) if $self->{'opt'}->{'hostfilter'};
Branch: 1 branch
BranchTrueFalseTotal
if $self->{"opt"}{"hostfilter"} 0 0 0
97  
98 # reset counter
99 0 $self->{'possible_types'} = {};
100 0 $self->{'possible_tags'} = {};
101 0 $self->{'possible_apps'} = {};
102  
103 0 $self->_copy_static_files();
104 0 $self->_build_dynamic_config();
105 0 ▶ $self->_check_typos() unless $self->{'opt'}->{'templatefilter'};
Branch: 1 branch
BranchTrueFalseTotal
unless $self->{"opt"}{"templatefilter"} 0 0 0
106 0 $self->_post_process();
107 0 ▶ $self->_print_stats() if $Monitoring::TT::Log::Verbose >= 2;
Branch: 1 branch
BranchTrueFalseTotal
if $Monitoring::TT::Log::Verbose >= 2 0 0 0
108 0 $self->_run_hook('post', join(',', @{$self->{'in'}}));
109 0 info('done');
110 0 return 0;
111 }
112  
113 #####################################################################
114  
115 =head2 tt
116  
117 return template toolkit object
118  
119 =cut
120  
121 6 ▶sub tt {
Subroutine tt: called CC=2 SCAR=6.9
Pod documented
122 6 my($self) = @_;
123  
124 6 ▶ return $self->{'_tt'} if $self->{'_tt'};
Branch: 1 branch
BranchTrueFalseTotal
if $self->{"_tt"} 4 2 6
125  
126 # make some globals available in TT stash
127 2 $self->{'tt_opts'}->{'PRE_DEFINE'}->{'src'} = $self->{'in'};
128  
129 2 $self->{'_tt'} = Template->new($self->{'tt_opts'});
130 2 $Template::Stash::PRIVATE = undef;
131  
132 2 return $self->{'_tt'};
133 }
134  
135 #####################################################################
136 # INTERNAL SUBS
137 #####################################################################
138 0 ▶sub _get_options {
Subroutine _get_options: not called CC=11 SCAR=48.8
139 0 my($self) = @_;
140 0 Getopt::Long::Configure('no_ignore_case');
141 0 Getopt::Long::Configure('bundling');
142 0 $self->{'opt'} = {
143 files => [],
144 verbose => 1,
145 force => 0,
146 dryrun => 0,
147 };
148 GetOptions (
149 'h|help' => \$self->{'opt'}->{'help'},
150 0 ▶ 'v|verbose' => sub { $self->{'opt'}->{'verbose'}++ },
Subroutine __ANON__: not called CC=1 SCAR=6.9
151 'q|quiet' => \$self->{'opt'}->{'quiet'},
152 'V|version' => \$self->{'opt'}->{'version'},
153 'f|force' => \$self->{'opt'}->{'force'},
154 'cf|contactfilter=s' => \$self->{'opt'}->{'contactfilter'},
155 'hf|hostfilter=s' => \$self->{'opt'}->{'hostfilter'},
156 'tf|templatefilter=s' => \$self->{'opt'}->{'templatefilter'},
157 'n|dry-run' => \$self->{'opt'}->{'dryrun'},
158 0 ▶ '<>' => sub { push @{$self->{'opt'}->{'files'}}, $_[0] },
Subroutine __ANON__: not called CC=1 SCAR=6.9
159 0 ▶ ) or $self->_usage();
Branch: 1 branch
BranchTrueFalseTotal
&GetOptions("h|help", \$self->{"opt"}{"help"}, "v|verbose", sub { $self->{"opt"}{"verbose"}++; } , "q|quiet", \$self->{"opt"}{"quiet"}, "V|version", \$self->{"opt"}{"version"}, "f|force", \$self->{"opt"}{"force"}, "cf|contactfilter=s", \$self->{"opt"}{"contactfilter"}, "hf|hostfilter=s", \$self->{"opt"}{"hostfilter"}, "tf|templatefilter=s", \$self->{"opt"}{"templatefilter"}, "n|dry-run", \$self->{"opt"}{"dryrun"}, "<>", sub { push @{$$self{"opt"}{"files"};}, $_[0]; } ) or $self->_usage 0 0 0
160 0 ▶ if($self->{'opt'}->{'version'}) { print 'Version ', $VERSION,"\n"; exit 0; }
Branch: 1 branch
BranchTrueFalseTotal
if ($self->{"opt"}{"version"}) 0 0 0
161 0 ▶ pod2usage({ -verbose => 2, -exit => 3 } ) if $self->{'opt'}->{'help'};
Branch: 1 branch
BranchTrueFalseTotal
if $self->{"opt"}{"help"} 0 0 0
162 0 ▶ $self->_usage('please specify at least one input and output folder!') if scalar @{$self->{'opt'}->{'files'}} <= 1;
Branch: 1 branch
BranchTrueFalseTotal
if scalar @{$self->{"opt"}{"files"};} <= 1 0 0 0
163 0 for my $f (@{$self->{'opt'}->{'files'}}) { $f =~ s/\/*$//gmx; }
164 0 $self->{'out'} = pop @{$self->{'opt'}->{'files'}};
165 0 $self->{'in'} = $self->{'opt'}->{'files'};
166 0 ▶ $self->{'opt'}->{'verbose'} = 0 if $self->{'opt'}->{'quiet'};
Branch: 1 branch
BranchTrueFalseTotal
if $self->{"opt"}{"quiet"} 0 0 0
167 0 ▶ $self->{'opt'}->{'dryrun'} = 1 if $self->{'opt'}->{'contactfilter'};
Branch: 1 branch
BranchTrueFalseTotal
if $self->{"opt"}{"contactfilter"} 0 0 0
168 0 ▶ $self->{'opt'}->{'dryrun'} = 1 if $self->{'opt'}->{'hostfilter'};
Branch: 1 branch
BranchTrueFalseTotal
if $self->{"opt"}{"hostfilter"} 0 0 0
169 0 ▶ $self->{'opt'}->{'dryrun'} = 1 if $self->{'opt'}->{'templatefilter'};
Branch: 1 branch
BranchTrueFalseTotal
if $self->{"opt"}{"templatefilter"} 0 0 0
170 0 $Monitoring::TT::Log::Verbose = $self->{'opt'}->{'verbose'};
171 0 ▶ info('Dry Run, Hooks won\'t be executed') if $self->{'opt'}->{'dryrun'};
Branch: 1 branch
BranchTrueFalseTotal
if $self->{"opt"}{"dryrun"} 0 0 0
172 0 return 1;
173 }
174  
175 #####################################################################
176 0 ▶sub _usage {
Subroutine _usage: not called CC=2 SCAR=17.9
177 0 my($self, $msg) = @_;
178 0 ▶ print $msg, "\n\n" if $msg;
Branch: 1 branch
BranchTrueFalseTotal
if $msg 0 0 0
179 0 print "usage: $0 [options] <input> [<input>...] <output>\ndetailed help available with --help\n";
180 0 exit 3;
181 }
182  
183 #####################################################################
184 0 ▶sub _copy_static_files {
Subroutine _copy_static_files: not called CC=3 SCAR=24.8
185 0 my($self) = @_;
186 0 for my $in (@{$self->{'in'}}) {
187 0 ▶ if(-d $in.'/static/.') {
Branch: 1 branch
BranchTrueFalseTotal
if (-d $in . '/static/.') 0 0 0
188 0 my $cmd = 'cp -LR '.$in.'/static/* '.$self->{'out'}.'/';
189 0 debug($cmd);
190 0 `$cmd`;
191 }
192 }
193 0 return;
194 }
195  
196 #####################################################################
197 0 ▶sub _build_dynamic_config {
Subroutine _build_dynamic_config: not called CC=8 SCAR=42.8
198 0 my($self) = @_;
199 # main work block, dynamic object configuration
200 0 $self->_build_dynamic_object_config();
201  
202 # other files
203 0 for my $in (@{$self->{'in'}}) {
204 0 for my $file (sort glob($in.'/*.cfg')) {
205 0 ▶ next if defined $self->{'opt'}->{'templatefilter'} and $file !~ m/$self->{'opt'}->{'templatefilter'}/mx;
Branch: 1 branch
BranchTrueFalseTotal
if defined $self->{"opt"}{"templatefilter"} and not $file =~ /$self->{"opt"}{"templatefilter"}/mx 0 0 0
Condition0%0/3
defined $self->{"opt"}{"templatefilter"} and not $file =~ /$self->{"opt"}{"templatefilter"}/mx
!ll&&!rl&&r
000
MC/DC0%0/2
defined $self->{"opt"}{"templatefilter"} and not $file =~ /$self->{"opt"}{"templatefilter"}/mx
defined $self->{"opt"}{"templatefilter"} not $file =~ /$self->{"opt"}{"templatefilter"}/mx
Truth table0%0/3
A and not(B)
A= defined $self->{"opt"}{"templatefilter"}B= not $file =~ /$self->{"opt"}{"templatefilter"}/mx
ABresult
0X0
100
111
206 0 info('processing non object: '.$file);
207 0 my $outfile = $file;
208 0 $outfile =~ s/.*\///mx;
209 0 ▶ next if $outfile =~ m/^hosts.*\.cfg/gmx;
Branch: 1 branch
BranchTrueFalseTotal
if $outfile =~ /^hosts.*\.cfg/gmx 0 0 0
210 0 ▶ next if $outfile =~ m/^contacts.*\.cfg/gmx;
Branch: 1 branch
BranchTrueFalseTotal
if $outfile =~ /^contacts.*\.cfg/gmx 0 0 0
211 0 $outfile = $self->{'out'}.'/'.$outfile;
212 0 debug('writing: '.$outfile);
213 0 ▶ open(my $fh, '>', $outfile) or die('cannot write '.$outfile.': '.$!);
Branch: 1 branch
BranchTrueFalseTotal
open my $fh, ">", $outfile or die 'cannot write ' . $outfile . ': ' . $! 0 0 0
214 0 print $fh $self->_process_template($self->_read_replaced_template($file), {});
215 0 print $fh "\n";
216 0 close($fh);
217 }
218 }
219  
220 0 return;
221 }
222  
223 #####################################################################
224 # do the main work, this block is essential for maximum performance
225 0 ▶sub _build_dynamic_object_config {
Subroutine _build_dynamic_object_config: not called CC=20 SCAR=60.4
226 0 my($self) = @_;
227  
228 # detect input type
229 0 my $input_types = $self->_get_input_types($self->{'in'});
230  
231 # no dynamic config at all?
232 0 ▶ return unless scalar keys %{$input_types} > 0;
Branch: 1 branch
BranchTrueFalseTotal
unless scalar keys %{$input_types;} > 0 0 0 0
233  
234 # build templates
235 0 my $templates = {
236 contacts => $self->_build_template('conf.d', 'contacts'),
237 hosts => $self->_build_template('conf.d', 'hosts', [ 'conf.d/apps', 'conf.d/apps.cfg' ]),
238 };
239  
240 0 mkdir($self->{'out'}.'/conf.d');
241  
242 0 $self->{'data'} = { hosts => [], contacts => [] };
243 0 for my $type (keys %{$input_types}) {
244 0 my $typefilter = $self->{'opt'}->{substr($type,0,-1).'filter'};
245 0 my $obj_list = [];
246 0 ▶ trace('fetching data for '.$type) if $Monitoring::TT::Log::Verbose >= 4;
Branch: 1 branch
BranchTrueFalseTotal
if $Monitoring::TT::Log::Verbose >= 4 0 0 0
247 0 for my $cls (@{$input_types->{$type}}) {
248 0 for my $in (@{$self->{'in'}}) {
249 0 my $data = $cls->read($in, $type);
250 0 for my $d (@{$data}) {
251 0 $d->{'montt'} = $self;
252 0 my $o = Monitoring::TT::Object->new($type, $d);
253 0 ▶ die('got no object') unless defined $o;
Branch: 1 branch
BranchTrueFalseTotal
unless defined $o 0 0 0
254 0 ▶ next if defined $typefilter and join(',', values %{$o}) !~ m/$typefilter/mx;
Branch: 1 branch
BranchTrueFalseTotal
if defined $typefilter and not join(",", values %{$o;}) =~ /$typefilter/mx 0 0 0
Condition0%0/3
defined $typefilter and not join(",", values %{$o;}) =~ /$typefilter/mx
!ll&&!rl&&r
000
MC/DC0%0/2
defined $typefilter and not join(",", values %{$o;}) =~ /$typefilter/mx
defined $typefilter not join(",", values %{$o;}) =~ /$typefilter/mx
Truth table0%0/3
A and not(B)
A= defined $typefilterB= not join(",", values %{$o;}) =~ /$typefilter/mx
ABresult
0X0
100
111
255 0 ▶ trace($o) if $Monitoring::TT::Log::Verbose >= 5;
Branch: 1 branch
BranchTrueFalseTotal
if $Monitoring::TT::Log::Verbose >= 5 0 0 0
256 0 push @{$obj_list}, $o;
257 }
258 }
259 }
260 # sort objects by name
261 0 @{$obj_list} = sort {$a->{'name'} cmp $b->{'name'}} @{$obj_list};
262 0 $self->{'data'}->{$type} = $obj_list;
263  
264 0 my $outfile = $self->{'out'}.'/conf.d/'.$type.'.cfg';
265 0 info('writing: '.$outfile);
266 0 ▶ open(my $fh, '>', $outfile) or die('cannot write '.$outfile.': '.$!);
Branch: 1 branch
BranchTrueFalseTotal
open my $fh, ">", $outfile or die 'cannot write ' . $outfile . ': ' . $! 0 0 0
267 0 print $fh $self->_process_template($templates->{$type}, { type => $type, data => $obj_list });
268 0 print $fh "\n";
269 0 close($fh);
270 }
271  
272 0 for my $in (@{$self->{'in'}}) {
273 0 for my $file (reverse sort @{$self->_get_files($in.'/conf.d', '\.cfg')}) {
274 0 ▶ next if defined $self->{'opt'}->{'templatefilter'} and $file !~ m/$self->{'opt'}->{'templatefilter'}/mx;
Branch: 1 branch
BranchTrueFalseTotal
if defined $self->{"opt"}{"templatefilter"} and not $file =~ /$self->{"opt"}{"templatefilter"}/mx 0 0 0
Condition0%0/3
defined $self->{"opt"}{"templatefilter"} and not $file =~ /$self->{"opt"}{"templatefilter"}/mx
!ll&&!rl&&r
000
MC/DC0%0/2
defined $self->{"opt"}{"templatefilter"} and not $file =~ /$self->{"opt"}{"templatefilter"}/mx
defined $self->{"opt"}{"templatefilter"} not $file =~ /$self->{"opt"}{"templatefilter"}/mx
Truth table0%0/3
A and not(B)
A= defined $self->{"opt"}{"templatefilter"}B= not $file =~ /$self->{"opt"}{"templatefilter"}/mx
ABresult
0X0
100
111
275 0 ▶ next if $file =~ m/^$in\/conf\.d\/apps/mx;
Branch: 1 branch
BranchTrueFalseTotal
if $file =~ m[^$in/conf\.d/apps]mx 0 0 0
276 0 ▶ next if $file =~ m/^$in\/conf\.d\/contacts/mx;
Branch: 1 branch
BranchTrueFalseTotal
if $file =~ m[^$in/conf\.d/contacts]mx 0 0 0
277 0 ▶ next if $file =~ m/^$in\/conf\.d\/hosts/mx;
Branch: 1 branch
BranchTrueFalseTotal
if $file =~ m[^$in/conf\.d/hosts]mx 0 0 0
278 0 info('processing object file: '.$file);
279 0 my $outfile = $file;
280 0 $outfile =~ s/.*\///mx;
281 0 $outfile = $self->{'out'}.'/conf.d/'.$outfile;
282 0 debug('writing: '.$outfile);
283 0 ▶ open(my $fh, '>', $outfile) or die('cannot write '.$outfile.': '.$!);
Branch: 1 branch
BranchTrueFalseTotal
open my $fh, ">", $outfile or die 'cannot write ' . $outfile . ': ' . $! 0 0 0
284 0 print $fh $self->_process_template($self->_read_replaced_template($file), $self->{'data'});
285 0 print $fh "\n";
286 0 close($fh);
287 }
288 }
289  
290 0 return;
291 }
292  
293 #####################################################################
294 0 ▶sub _print_stats {
Subroutine _print_stats: not called CC=3 SCAR=24.8
295 0 my($self) = @_;
296 0 my $out = $self->{'out'};
297 0 info('written:');
298 0 for my $type (qw/host hostgroup hostdependency hostextinfo hostescalation
299 service servicegroup servicedependency serviceextinfo serviceescalation
300 contact contactgroup command timeperiod
301 /) {
302 0 my $num = $self->_grep_count($out, '^\s*define\s*'.$type.'\( \|{\)');
303 0 ▶ next if $num == 0;
Branch: 1 branch
BranchTrueFalseTotal
if $num == 0 0 0 0
304 0 info(sprintf('# %-15s %6s', $type, $num));
305 }
306 0 return;
307 }
308  
309 #####################################################################
310 0 ▶sub _grep_count {
Subroutine _grep_count: not called CC=3 SCAR=24.8
311 0 my($self, $dir, $pattern) = @_;
312 0 my $txt = `grep -r -c '$pattern' $dir 2>&1`;
313 0 my $total = 0;
314 0 for my $line (split/\n/mx, $txt) {
315 0 ▶ if($line =~ m/:(\d+)$/mx) {
Branch: 1 branch
BranchTrueFalseTotal
if ($line =~ /:(\d+)$/mx) 0 0 0
316 0 $total += $1;
317 }
318 }
319 0 return $total;
320 }
321  
322 #####################################################################
323 0 ▶sub _build_template {
Subroutine _build_template: not called CC=28 SCAR=67.0
324 0 my($self, $dir, $type, $appdirs) = @_;
325 0 my $shorttype = substr($type, 0, -1);
326 0 my $template = "[% FOREACH d = data %][% ".$shorttype." = d %]\n";
327 0 my $found = 0;
328 0 for my $in (@{$self->{'in'}}) {
329 0 for my $path (glob($in.'/'.$dir.'/'.$type.'/ '.
330 $in.'/'.$dir.'/'.$type.'*.cfg')
331 ) {
332 0 ▶ trace('looking for '.$type.' templates in '.$path) if $Monitoring::TT::Log::Verbose >= 4;
Branch: 1 branch
BranchTrueFalseTotal
if $Monitoring::TT::Log::Verbose >= 4 0 0 0
333 0 ▶ if(-e $path) {
Branch: 1 branch
BranchTrueFalseTotal
if (-e $path) 0 0 0
334 0 my $templates = $self->_get_files($path, '\.cfg');
335 0 for my $t (reverse sort @{$templates}) {
336 0 ▶ next if defined $self->{'opt'}->{'templatefilter'} and $t !~ m|$self->{'opt'}->{'templatefilter'}|mx;
Branch: 1 branch
BranchTrueFalseTotal
if defined $self->{"opt"}{"templatefilter"} and not $t =~ /$self->{"opt"}{"templatefilter"}/mx 0 0 0
Condition0%0/3
defined $self->{"opt"}{"templatefilter"} and not $t =~ /$self->{"opt"}{"templatefilter"}/mx
!ll&&!rl&&r
000
MC/DC0%0/2
defined $self->{"opt"}{"templatefilter"} and not $t =~ /$self->{"opt"}{"templatefilter"}/mx
defined $self->{"opt"}{"templatefilter"} not $t =~ /$self->{"opt"}{"templatefilter"}/mx
Truth table0%0/3
A and not(B)
A= defined $self->{"opt"}{"templatefilter"}B= not $t =~ /$self->{"opt"}{"templatefilter"}/mx
ABresult
0X0
100
111
337 0 my $tags = $self->_get_tags_for_path($t, $path);
338 0 my $required_type = shift @{$tags};
339 0 ▶ info('adding '.$type.' template: '.$t.($required_type ? ' for type '.$required_type : '').(scalar @{$tags} > 0 ? ' with tags: '.join(' & ', @{$tags}) : ''));
Branch: 2 branches
BranchTrueFalseTotal
$required_type ? : 0 0 0
scalar @{$tags;} > 0 ? : 0 0 0
340 0 ▶ if($required_type) {
Branch: 1 branch
BranchTrueFalseTotal
if ($required_type) 0 0 0
341 0 $self->{$type.'possible_types'}->{$required_type} = 1;
342 0 $template .= "[% IF d.type == '$required_type' %]";
343 }
344 0 for my $tag (@{$tags}) {
345 0 $self->{$type.'possible_tags'}->{$tag} = 1;
346 0 $template .= "[% IF d.has_tag('$tag') %]";
347 }
348 0 $template .= $self->_read_replaced_template($t);
349 0 for my $tag (@{$tags}) {
350 0 $template .= "[% END %]";
351 }
352 0 ▶ $template .= "[% END %]" if $required_type;
Branch: 1 branch
BranchTrueFalseTotal
if $required_type 0 0 0
353 0 $found++;
354 0 $template .= "\n";
355 }
356 }
357 }
358 }
359  
360 # add apps for hosts
361 0 ▶ if(defined $appdirs and scalar @{$appdirs} > 0) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined $appdirs and scalar @{$appdirs;} > 0) 0 0 0
Condition0%0/3
defined $appdirs and scalar @{$appdirs;} > 0
!ll&&!rl&&r
000
MC/DC0%0/2
defined $appdirs and scalar @{$appdirs;} > 0
defined $appdirs scalar @{$appdirs;} > 0
Truth table0%0/3
A and B
A= defined $appdirsB= scalar @{$appdirs;} > 0
ABresult
0X0
100
111
362 0 for my $in (@{$self->{'in'}}) {
363 0 for my $path (@{$appdirs}) {
364 0 $path = $in.'/'.$path;
365 0 ▶ trace('looking for '.$type.' apps in '.$path) if $Monitoring::TT::Log::Verbose >= 4;
Branch: 1 branch
BranchTrueFalseTotal
if $Monitoring::TT::Log::Verbose >= 4 0 0 0
366 0 ▶ if(-e $path) {
Branch: 1 branch
BranchTrueFalseTotal
if (-e $path) 0 0 0
367 0 my $templates = $self->_get_files($path, '\.cfg');
368 0 for my $t (reverse sort @{$templates}) {
369 0 ▶ next if defined $self->{'opt'}->{'templatefilter'} and $t !~ m|$self->{'opt'}->{'templatefilter'}|mx;
Branch: 1 branch
BranchTrueFalseTotal
if defined $self->{"opt"}{"templatefilter"} and not $t =~ /$self->{"opt"}{"templatefilter"}/mx 0 0 0
Condition0%0/3
defined $self->{"opt"}{"templatefilter"} and not $t =~ /$self->{"opt"}{"templatefilter"}/mx
!ll&&!rl&&r
000
MC/DC0%0/2
defined $self->{"opt"}{"templatefilter"} and not $t =~ /$self->{"opt"}{"templatefilter"}/mx
defined $self->{"opt"}{"templatefilter"} not $t =~ /$self->{"opt"}{"templatefilter"}/mx
Truth table0%0/3
A and not(B)
A= defined $self->{"opt"}{"templatefilter"}B= not $t =~ /$self->{"opt"}{"templatefilter"}/mx
ABresult
0X0
100
111
370 0 my $apps = $self->_get_tags_for_path($t, $path);
371 0 ▶ info('adding apps template: '.$t.(scalar @{$apps} > 0 ? ' for apps: '.join(' & ', @{$apps}) : ''));
Branch: 1 branch
BranchTrueFalseTotal
scalar @{$apps;} > 0 ? : 0 0 0
372 0 for my $app (@{$apps}) {
373 0 $self->{'possible_apps'}->{$app} = 1;
374 0 $template .= "[% IF d.has_app('$app') %]";
375 }
376 0 $template .= $self->_read_replaced_template($t);
377 0 for my $app (@{$apps}) {
378 0 $template .= "[% END %]";
379 }
380 0 $found++;
381 0 $template .= "\n";
382 }
383 }
384 }
385 }
386 }
387  
388 0 ▶ if($found == 0) {
Branch: 1 branch
BranchTrueFalseTotal
if ($found == 0) 0 0 0
389 0 debug('no templates for type '.$type.' found');
390 0 return '';
391 }
392 0 $template .= "[% END %]\n";
393 0 ▶ if($Monitoring::TT::Log::Verbose >= 4) {
Branch: 1 branch
BranchTrueFalseTotal
if ($Monitoring::TT::Log::Verbose >= 4) 0 0 0
394 0 trace('created template:');
395 0 trace($template);
396 }
397 0 return $template;
398 }
399  
400 #####################################################################
401 0 ▶sub _get_files {
Subroutine _get_files: not called CC=9 SCAR=45.0
402 0 my($self, $dir, $pattern) = @_;
403 0 ▶ if(!-d $dir and $dir =~ m/$pattern/mx) {
Branch: 1 branch
BranchTrueFalseTotal
if (not -d $dir and $dir =~ /$pattern/mx) 0 0 0
Condition0%0/3
not -d $dir and $dir =~ /$pattern/mx
!ll&&!rl&&r
000
MC/DC0%0/2
not -d $dir and $dir =~ /$pattern/mx
not -d $dir $dir =~ /$pattern/mx
Truth table0%0/3
not(A) and B
A= not -d $dirB= $dir =~ /$pattern/mx
ABresult
0X0
100
111
404 0 return([$dir]);
405 }
406 0 my @files;
407 0 ▶ return \@files unless -d $dir;
Branch: 1 branch
BranchTrueFalseTotal
unless -d $dir 0 0 0
408 0 ▶ opendir(my $d, $dir) or die("cannot read directory $dir: $!");
Branch: 1 branch
BranchTrueFalseTotal
opendir my $d, $dir or die "cannot read directory ${dir}: $!" 0 0 0
409 0 ▶ while(my $file = readdir($d)) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined(my $file = readdir $d)) 0 0 0
410 0 ▶ next if substr($file,0,1) eq '.';
Branch: 1 branch
BranchTrueFalseTotal
if substr($file, 0, 1) eq "." 0 0 0
411 0 ▶ if(-d $dir.'/'.$file.'/.') {
Branch: 1 branch
BranchTrueFalseTotal
if (-d $dir . '/' . $file . '/.') { } 0 0 0
412 0 push @files, @{$self->_get_files($dir.'/'.$file, $pattern)};
413 } else {
414 0 ▶ next if $file !~ m/$pattern/mx;
Branch: 1 branch
BranchTrueFalseTotal
unless $file =~ /$pattern/mx 0 0 0
415 0 push @files, $dir."/".$file;
416 }
417 }
418 0 return \@files;
419 }
420  
421 #####################################################################
422 3 ▶sub _process_template {
Subroutine _process_template: called CC=6 SCAR=21.8
423 3 my($self, $template, $data) = @_;
424  
425 3 ▶ if(!defined $self->{'_config_template'}) {
Branch: 1 branch
BranchTrueFalseTotal
unless (defined $self->{"_config_template"}) 2 1 3
426 2 $self->{'_config_template'} = "";
427 2 for my $in (@{$self->{'in'}}) {
428 0 debug('looking for a '.$in.'/config.cfg');
429 0 ▶ if(-e $in.'/config.cfg') {
Branch: 1 branch
BranchTrueFalseTotal
if (-e $in . '/config.cfg') 0 0 0
430 0 debug('added config template '.$in.'/config.cfg');
431 0 $self->{'_config_template'} .= $self->_read_replaced_template($in.'/config.cfg')."\n";
432 }
433 }
434 }
435 3 $template = $self->{'_config_template'}.$template;
436  
437 3 ▶ if($Monitoring::TT::Log::Verbose >= 4) {
Branch: 1 branch
BranchTrueFalseTotal
if ($Monitoring::TT::Log::Verbose >= 4) 0 3 3
438 0 trace('template:');
439 0 trace('==========================');
440 0 trace($template);
441 0 trace('==========================');
442 }
443  
444 3 my $output;
445 3 ▶ $self->tt->process(\$template, $data, \$output) or $self->_template_process_die($template, $data);
Branch: 1 branch
BranchTrueFalseTotal
$self->tt->process(\$template, $data, \$output) or $self->_template_process_die($template, $data) 3 0 3
446  
447 # clean up result
448 3 $output =~ s/^\s*$//sgmxo;
449 3 $output =~ s/^\n//gmxo;
450  
451 3 return $output;
452 }
453  
454 #####################################################################
455 0 ▶sub _post_process {
Subroutine _post_process: not called CC=5 SCAR=34.0
456 0 my($self) = @_;
457 0 my $out = $self->{'out'};
458 0 for my $in (@{$self->{'in'}}) {
459 0 for my $processor (sort glob($in.'/post_process*')) {
460 0 info('postprocessing with '.$processor);
461 0 ▶ if(!-x $processor) {
Branch: 1 branch
BranchTrueFalseTotal
unless (-x $processor) 0 0 0
462 0 error("post processor ".$processor." must be executable");
463 0 next;
464 }
465 0 my $res = `$processor $out`;
466 0 my $rc = $?;
467 0 ▶ if($rc != 0) {
Branch: 1 branch
BranchTrueFalseTotal
if ($rc != 0) 0 0 0
468 0 warn($res);
469 }
470 }
471 }
472 0 return;
473 }
474  
475 #####################################################################
476 1 ▶sub _get_input_classes {
Subroutine _get_input_classes: called CC=10 SCAR=25.5
477 1 my($self, $folders) = @_;
478 1 my $types = [];
479  
480 1 for my $dir (@{$folders}) {
481 0 ▶ next unless -d $dir.'/lib/.';
Branch: 1 branch
BranchTrueFalseTotal
unless -d $dir . '/lib/.' 0 0 0
482 0 unshift @INC, "$dir/lib";
483 0 ▶ trace('added '.$dir.'/lib to @INC') if $Monitoring::TT::Log::Verbose >= 4;
Branch: 1 branch
BranchTrueFalseTotal
if $Monitoring::TT::Log::Verbose >= 4 0 0 0
484 }
485  
486 1 ▶ if($Monitoring::TT::Log::Verbose >= 4) {
Branch: 1 branch
BranchTrueFalseTotal
if ($Monitoring::TT::Log::Verbose >= 4) 0 1 1
487 0 trace('@INC:');
488 0 trace(\@INC);
489 }
490  
491 1 my $uniq_types = {};
492 1 my $uniq_libs = {};
493 1 for my $inc (@INC) {
494 9 ▶ next if defined $uniq_libs->{$inc};
Branch: 1 branch
BranchTrueFalseTotal
if defined $uniq_libs->{$inc} 1 8 9
495 8 $uniq_libs->{$inc} = 1;
496 8 my @files = glob($inc.'/Monitoring/TT/Input/*.pm');
497 8 for my $file (glob($inc.'/Monitoring/TT/Input/*.pm')) {
498 4 ▶ trace('found input class: '.$file) if $Monitoring::TT::Log::Verbose >= 4;
Branch: 1 branch
BranchTrueFalseTotal
if $Monitoring::TT::Log::Verbose >= 4 0 4 4
499 4 $file =~ s|^$inc/Monitoring/TT/Input/||mx;
500 4 $file =~ s|\.pm$||mx;
501 4 ▶ push @{$types}, $file unless defined $uniq_types->{$types}->{$file};
Branch: 1 branch
BranchTrueFalseTotal
unless defined $uniq_types->{$types}{$file} 2 2 4
502 4 $uniq_types->{$types}->{$file} = 1;
503 }
504 }
505 1 return $types;
506 }
507  
508 #####################################################################
509 0 ▶sub _get_input_types {
Subroutine _get_input_types: not called CC=6 SCAR=37.4
510 0 my($self, $folders) = @_;
511 0 my $input_types = {};
512 0 my $input_classes = $self->_get_input_classes($folders);
513 0 for my $t (@{$input_classes}) {
514 0 debug('requesting input files from: '.$t);
515 0 my $objclass = 'Monitoring::TT::Input::'.$t;
516 ## no critic
517 0 eval "require $objclass;";
518 ## use critic
519 0 ▶ error($@) if $@;
Branch: 1 branch
BranchTrueFalseTotal
if $@ 0 0 0
520 0 my $obj = \&{$objclass."::new"};
521 0 my $it = &$obj($objclass, montt => $self);
522 0 my $types = $it->get_types($folders);
523 0 ▶ trace('input \''.$t.'\' supports: '.join(', ', @{$types})) if $Monitoring::TT::Log::Verbose >= 4;
Branch: 1 branch
BranchTrueFalseTotal
if $Monitoring::TT::Log::Verbose >= 4 0 0 0
524 0 for my $type (@{$types}) {
525 0 ▶ $input_types->{$type} = [] unless defined $input_types->{$type};
Branch: 1 branch
BranchTrueFalseTotal
unless defined $input_types->{$type} 0 0 0
526 0 push @{$input_types->{$type}}, $it;
527 }
528 }
529 0 return $input_types;
530 }
531  
532 #####################################################################
533 0 ▶sub _run_hook {
Subroutine _run_hook: not called CC=8 SCAR=42.8
534 0 my($self, $name, $args) = @_;
535 0 ▶ return if $self->{'opt'}->{'dryrun'};
Branch: 1 branch
BranchTrueFalseTotal
if $self->{"opt"}{"dryrun"} 0 0 0
536 0 for my $in (@{$self->{'in'}}) {
537 0 my $hook = $in.'/hooks/'.$name;
538 0 ▶ trace("hook: looking for ".$hook) if $Monitoring::TT::Log::Verbose >= 4;
Branch: 1 branch
BranchTrueFalseTotal
if $Monitoring::TT::Log::Verbose >= 4 0 0 0
539 0 ▶ if(-x $hook) {
Branch: 1 branch
BranchTrueFalseTotal
if (-x $hook) 0 0 0
540 0 my $cmd = $hook;
541 0 ▶ $cmd = $cmd." ".$args if defined $args;
Branch: 1 branch
BranchTrueFalseTotal
if defined $args 0 0 0
542 0 debug($cmd);
543 0 open(my $ph, '-|', $cmd);
544 0 ▶ while(my $line = <$ph>) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined(my $line = readline $ph)) 0 0 0
545 0 log($line);
546 }
547 0 close($ph);
548 0 my $rc = $?>>8;
549 0 debug('hook returned: '.$rc);
550 0 ▶ if($rc) {
Branch: 1 branch
BranchTrueFalseTotal
if ($rc) 0 0 0
551 0 debug(' -> exiting');
552 0 exit $rc;
553 }
554 }
555 }
556 0 return;
557 }
558  
559 #####################################################################
560 3 ▶sub _read_replaced_template {
Subroutine _read_replaced_template: called CC=9 SCAR=23.5
561 3 my($self, $template) = @_;
562 3 $template =~ s|//|/|gmxo;
563 3 my $text = '[%# SRC '.$template.':1 #%]';
564 3 ▶ open(my $fh, '<', $template) or die("cannot read: ".$template.': '.$!);
Branch: 1 branch
BranchTrueFalseTotal
open my $fh, "<", $template or die 'cannot read: ' . $template . ': ' . $! 3 0 3
565 3 ▶ while(my $line = <$fh>) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined(my $line = readline $fh)) 25 3 28
566 # remove utf8 file bom
567 25 ▶ if($. == 1) {
Branch: 1 branch
BranchTrueFalseTotal
if ($. == 1) 3 22 25
568 3 my $bom = pack("CCC", 0xef, 0xbb, 0xbf);
569 3 ▶ if(substr($line,0,3) eq $bom) {
Branch: 1 branch
BranchTrueFalseTotal
if (substr($line, 0, 3) eq $bom) 0 3 3
570 0 $line = substr($line, 3);
571 }
572 }
573 25 $text .= $line;
574 25 ▶ if($line =~ m/^define\s+(\w+)/mxo) {
Branch: 1 branch
BranchTrueFalseTotal
if ($line =~ /^define\s+(\w+)/mox) 3 22 25
575 3 ▶ if($1 eq 'service' or $1 eq 'host' or $1 eq 'contact') {
Branch: 1 branch
BranchTrueFalseTotal
if ($1 eq 'service' or $1 eq 'host' or $1 eq 'contact') { } 3 0 3
Condition33%2/6
$1 eq "service" or $1 eq "host" or $1 eq "contact"
l!l&&r!l&&!r
300
$1 eq "service" or $1 eq "host"
l!l&&r!l&&!r
030
MC/DC0%0/3
$1 eq "service" or $1 eq "host" or $1 eq "contact"
$1 eq "service" $1 eq "host" $1 eq "contact"
Truth table25%1/4
A or B or C
A= $1 eq "service"B= $1 eq "host"C= $1 eq "contact"
ABCresult
1XX1
01X1
0011
0000
576 3 $text .= ' _SRC '.$template.':'.$.."\n";
577 } else {
578 0 $text .= '# SRC '.$template.':'.$.."\n";
579 }
580 }
581 }
582 3 close($fh);
583 3 return $text;
584 }
585  
586 #####################################################################
587 0 ▶sub _get_tags_for_path {
Subroutine _get_tags_for_path: not called CC=1 SCAR=6.9
588 0 my($self, $path, $basepath) = @_;
589 0 my $tmppath = lc $path;
590 0 $tmppath =~ s|^$basepath||mx;
591 0 $tmppath =~ s|\.cfg$||mx;
592 0 $tmppath =~ s|^/||mx;
593 0 my @tags = split(/\//mx, $tmppath);
594 0 return \@tags;
595 }
596  
597 #####################################################################
598 0 ▶sub _template_process_die {
Subroutine _template_process_die: not called CC=9 SCAR=45.0
599 0 my($self, $template, $data) = @_;
600 0 my $tterror = "".$self->tt->error();
601 0 my $already_printed = 0;
602  
603 # try to find file / line
604 0 ▶ if($tterror =~ m/input\s+text\s+line\s+(\d+)/mx) {
Branch: 1 branch
BranchTrueFalseTotal
if ($tterror =~ /input\s+text\s+line\s+(\d+)/mx) 0 0 0
605 0 my $linenr = $1;
606 0 my @lines = split/\n/mx, $template;
607 0 my($realfile, $realline) = $self->_get_file_and_line_for_error(\@lines, $linenr);
608 0 ▶ if($realfile) {
Branch: 1 branch
BranchTrueFalseTotal
if ($realfile) 0 0 0
609 0 my $newloc = $realfile.' line '.$realline;
610 0 $tterror =~ s|input\s+text\s+line\s+\d+|$newloc|gmx;
611 }
612 }
613  
614 # var.undef error - undefined variable: host.tag('contact_groups')
615 0 ▶ if($tterror =~ m/var\.undef\ error\ -\ undefined\ variable:\s+(.*)$/mx) {
Branch: 1 branch
BranchTrueFalseTotal
if ($tterror =~ /var\.undef\ error\ -\ undefined\ variable:\s+(.*)$/mx) 0 0 0
616 0 my $err = $1;
617 0 my $linenr = 0;
618 0 error($tterror);
619 0 $already_printed = 1;
620 0 my @lines = split/\n/mx, $template;
621 0 for my $line (@lines) {
622 0 $linenr++;
623 0 ▶ if($line =~ m/\Q$err\E/mx) {
Branch: 1 branch
BranchTrueFalseTotal
if ($line =~ /\Q$err\E/mx) 0 0 0
624 0 my($realfile, $realline) = $self->_get_file_and_line_for_error(\@lines, $linenr);
625 0 ▶ if($realfile) {
Branch: 1 branch
BranchTrueFalseTotal
if ($realfile) 0 0 0
626 0 error('occurs in: '.$realfile.':'.$realline);
627 }
628 }
629 }
630 }
631  
632 0 ▶ error($tterror) unless $already_printed;
Branch: 1 branch
BranchTrueFalseTotal
unless $already_printed 0 0 0
633 0 debug('in template:');
634 0 debug($template);
635 0 ▶ trace($data) if $Monitoring::TT::Log::Verbose >= 4;
Branch: 1 branch
BranchTrueFalseTotal
if $Monitoring::TT::Log::Verbose >= 4 0 0 0
636 0 exit 1;
637 }
638  
639 #####################################################################
640 0 ▶sub _get_file_and_line_for_error {
Subroutine _get_file_and_line_for_error: not called CC=4 SCAR=30.0
641 0 my($self, $lines, $linenr) = @_;
642 0 ▶ for(my $x = $linenr; $x >= 0; $x--) {
Branch: 1 branch
BranchTrueFalseTotal
if ($x >= 0) 0 0 0
643 0 ▶ if(defined $lines->[$x] and $lines->[$x] =~ m/SRC\s+(.*):(\d+)/mx) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined $lines->[$x] and $lines->[$x] =~ /SRC\s+(.*):(\d+)/mx) 0 0 0
Condition0%0/3
defined $lines->[$x] and $lines->[$x] =~ /SRC\s+(.*):(\d+)/mx
!ll&&!rl&&r
000
MC/DC0%0/2
defined $lines->[$x] and $lines->[$x] =~ /SRC\s+(.*):(\d+)/mx
defined $lines->[$x] $lines->[$x] =~ /SRC\s+(.*):(\d+)/mx
Truth table0%0/3
A and B
A= defined $lines->[$x]B= $lines->[$x] =~ /SRC\s+(.*):(\d+)/mx
ABresult
0X0
100
111
644 0 my $diff = $x - $2 + 1;
645 0 return($1, ($linenr - $diff))
646 }
647 }
648 0 return(undef, undef);
649 }
650  
651 #####################################################################
652 0 ▶sub _mkdir_r {
Subroutine _mkdir_r: not called CC=4 SCAR=30.0
653 0 my($self, $dir) = @_;
654 0 my $path = '';
655 0 for my $part (split/(\/)/mx, $dir) {
656 0 $path .= $part;
657 0 ▶ next if $path eq '';
Branch: 1 branch
BranchTrueFalseTotal
if $path eq "" 0 0 0
658 0 ▶ mkdir($path) unless -d $path;
Branch: 1 branch
BranchTrueFalseTotal
unless -d $path 0 0 0
659 }
660 0 return;
661 }
662  
663 #####################################################################
664 0 ▶sub _check_typos {
Subroutine _check_typos: not called CC=13 SCAR=52.0
665 0 my($self) = @_;
666 0 for my $type (qw/hosts contacts/) {
667 0 for my $o (@{$self->{'data'}->{$type}}) {
668 0 ▶ if($o->{'type'} and $o->{'type'} ne 'contact') {
Branch: 1 branch
BranchTrueFalseTotal
if ($o->{"type"} and $o->{"type"} ne "contact") 0 0 0
Condition0%0/3
$o->{"type"} and $o->{"type"} ne "contact"
!ll&&!rl&&r
000
MC/DC0%0/2
$o->{"type"} and $o->{"type"} ne "contact"
$o->{"type"} $o->{"type"} ne "contact"
Truth table0%0/3
A and B
A= $o->{"type"}B= $o->{"type"} ne "contact"
ABresult
0X0
100
111
669 0 ▶ warn('unused type \''.$o->{'type'}.'\' defined in '.$o->{'file'}.':'.$o->{'line'}) unless defined $self->{$type.'possible_types'}->{$o->{'type'}};
Branch: 1 branch
BranchTrueFalseTotal
unless defined $$self{$type . 'possible_types'}{$o->{"type"}} 0 0 0
670 }
671 0 ▶ if($o->{'tags'}) {
Branch: 1 branch
BranchTrueFalseTotal
if ($o->{"tags"}) 0 0 0
672 0 for my $t (keys %{$o->{'tags'}}) {
673 0 ▶ next if substr($t,0,1) eq '_';
Branch: 1 branch
BranchTrueFalseTotal
if substr($t, 0, 1) eq "_" 0 0 0
674 0 ▶ warn('unused tag \''.$t.'\' defined in '.$o->{'file'}.':'.$o->{'line'}) unless defined $self->{$type.'possible_tags'}->{$t};
Branch: 1 branch
BranchTrueFalseTotal
unless defined $$self{$type . 'possible_tags'}{$t} 0 0 0
675 }
676 }
677 0 ▶ if($o->{'apps'}) {
Branch: 1 branch
BranchTrueFalseTotal
if ($o->{"apps"}) 0 0 0
678 0 for my $a (keys %{$o->{'apps'}}) {
679 0 ▶ warn('unused app \''.$a.'\' defined in '.$o->{'file'}.':'.$o->{'line'}) unless defined $self->{$type.'possible_apps'}->{$a};
Branch: 1 branch
BranchTrueFalseTotal
unless defined $$self{$type . 'possible_apps'}{$a} 0 0 0
680 }
681 }
682 }
683 }
684 0 return;
685 }
686  
687 =head1 AUTHOR
688  
689 Sven Nierlein, 2013, <sven.nierlein@consol.de>
690  
691 =cut
692  
693 4 1;
↑ Summary TT/Input/Nagios.pm »