Branch Coverage

blib/lib/Monitoring/Availability.pm
Criterion Covered Total %
branch 282 438 64.3


line true false branch
164 124 0 if (exists $$self{$opt_key}) { }
188 0 18 if (defined $ENV{'MONITORING_AVAILABILITY_DEBUG'})
193 0 18 if ($$self{'verbose'} and not defined $$self{'logger'})
203 0 18 if $$self{'verbose'}
204 0 18 if $$self{'verbose'}
322 0 20 if $$self{'verbose'}
323 0 20 if $$self{'verbose'}
327 86 0 if (exists $$self{'report_options'}{$opt_key}) { }
346 0 32 if (ref $service ne 'HASH')
349 0 32 unless (defined $$service{'host'} and defined $$service{'service'})
356 8 12 if (scalar @{$$self{'report_options'}{'hosts'};} == 1) { }
12 0 elsif (scalar @{$$self{'report_options'}{'services'};} == 1) { }
367 0 20 if (scalar keys %{$$result{'services'};} == 0 and scalar keys %{$$result{'hosts'};} == 0)
368 0 0 if $$self{'verbose'}
374 20 0 unless ($$self{'report_options'}{'calc_all'})
386 0 20 if ($$self{'report_options'}{'log_file'} and not $$self{'report_options'}{'log_string'} and not $$self{'report_options'}{'log_dir'}) { }
19 1 elsif (defined $$self{'report_options'}{'log_string'} or $$self{'report_options'}{'log_file'} or $$self{'report_options'}{'log_dir'}) { }
1 0 elsif (defined $$self{'report_options'}{'log_livestatus'}) { }
0 0 elsif (defined $$self{'report_options'}{'log_iterator'}) { }
422 0 8 if $$self{'report_options'}{'build_log'} == 0
424 8 0 unless $$self{'log_output_calculated'}
443 0 9 if $$self{'report_options'}{'build_log'} == 0
445 1 8 unless $$self{'log_output_calculated'}
456 0 20 if $$self{'verbose'}
478 20 0 if ($$self{'report_options'}{'assumeinitialstates'})
482 0 20 if $$self{'verbose'}
485 0 8 if ($initial_assumend_state == -1)
487 0 0 if ($@)
505 0 20 if $$self{'verbose'}
509 20 0 if ($$self{'report_options'}{'assumeinitialstates'})
517 1 31 if ($initial_assumend_state == -1)
519 0 1 if ($@)
533 0 13 if ($initial_assumend_host_state == -1)
535 0 0 if ($@)
552 20 156 if ($last_time < $report_options_start and $$data{'time'} >= $report_options_start)
557 6 170 if ($$self{'report_options'}{'breakdown'} != 0)
560 0 4 if $$self{'verbose'}
568 3 173 if ($$data{'time'} >= $report_options_end and $last_time < $report_options_end)
572 2 1 unless defined $$data{'fake'}
581 175 1 unless defined $$data{'fake'}
590 0 0 if ($$self{'verbose'})
598 0 0 unless open my $fh, '<', $file
606 0 0 unless $data
625 0 0 if ($$self{'verbose'})
633 0 0 unless ($logs->has_next)
665 0 1 if ($$self{'verbose'})
672 1 0 if (scalar @{$logs;} == 0)
706 0 19 if ($$self{'verbose'})
715 0 19 if $$self{'verbose'}
740 0 20 if ($last_time < $$self{'report_options'}{'start'})
747 0 1 if $$self{'verbose'}
755 17 3 if ($last_time < $$self{'report_options'}{'end'})
766 0 175 if ($verbose)
773 2 56 if (exists $$data{'hard'} and not $report_options_includesoftstates and $$data{'hard'} != 1)
774 0 2 if $verbose
779 57 116 if (defined $$data{'proc_start'}) { }
6 110 elsif (defined $$data{'timeperiod'}) { }
780 12 45 unless ($$self{'report_options'}{'assumestatesduringnotrunning'})
781 10 2 if ($$data{'proc_start'} == 1 or $$data{'proc_start'} == 2) { }
783 0 10 if $verbose
788 1 5 if defined $last_known_state and $last_known_state >= 0
795 1 9 if defined $last_known_state and $last_known_state >= 0
800 0 2 if $verbose
812 39 18 if ($$data{'proc_start'} == 1 or $$data{'proc_start'} == 2) { }
814 1 38 if $$data{'proc_start'} == 2
827 0 18 if $$data{'proc_start'} == -1
843 3 3 if ($$self{'report_options'}{'rpttimeperiod'} eq $$data{'timeperiod'})
844 0 3 if $verbose
849 3 0 if defined $last_known_state and $last_known_state >= 0
856 0 3 if defined $last_known_state and $last_known_state >= 0
864 2 1 if ($$self{'in_timeperiod'})
882 2 63 if ($report_options_calc_all == 0 and defined $$data{'host_name'} and not defined $$self{'host_data'}{$$data{'host_name'}} and not defined $$self{'service_data'}{$$data{'host_name'}})
883 0 2 if $verbose
888 0 63 if ($report_options_calc_all == 0 and $$data{'host_name'} and $$data{'service_description'} and not defined $$self{'service_data'}{$$data{'host_name'}}{$$data{'service_description'}})
893 0 0 if $verbose
898 47 61 if ($$data{'service_description'}) { }
16 45 elsif (defined $$data{'host_name'}) { }
901 45 2 if ($$data{'type'} eq 'CURRENT SERVICE STATE' or $$data{'type'} eq 'SERVICE ALERT' or $$data{'type'} eq 'INITIAL SERVICE STATE') { }
2 0 elsif ($$data{'type'} eq 'SERVICE DOWNTIME ALERT') { }
906 35 10 if ($$data{'state'} == 0) { }
3 7 elsif ($$data{'state'} == 1) { }
3 4 elsif ($$data{'state'} == 3) { }
4 0 elsif ($$data{'state'} == 2) { }
910 45 0 if (defined $state_text)
912 45 0 if $$data{'hard'}
913 25 20 unless $$self{'report_options'}{'build_log'} == 2
925 0 2 unless $$self{'report_options'}{'showscheduleddowntime'}
932 1 1 if ($$data{'start'}) { }
944 2 0 unless $$self{'report_options'}{'build_log'} == 2
955 0 0 if $verbose
963 11 5 if ($$data{'type'} eq 'CURRENT HOST STATE' or $$data{'type'} eq 'HOST ALERT' or $$data{'type'} eq 'INITIAL HOST STATE') { }
5 0 elsif ($$data{'type'} eq 'HOST DOWNTIME ALERT') { }
968 7 4 if ($$data{'state'} == 0) { }
3 1 elsif ($$data{'state'} == 1) { }
1 0 elsif ($$data{'state'} == 2) { }
971 11 0 if (defined $state_text)
973 11 0 if $$data{'hard'}
986 0 5 unless $$self{'report_options'}{'showscheduleddowntime'}
990 0 5 if $verbose
1004 3 2 if ($$data{'start'}) { }
1027 0 0 if $verbose
1031 0 45 if $verbose
1042 0 124 if $verbose
1049 86 38 if ($report_options_start < $$data{'time'} and $report_options_end >= $$data{'time'})
1051 86 0 if (defined $$service_hist{'last_state'})
1055 2 84 if (defined $$self{'in_timeperiod'} and not $$self{'in_timeperiod'}) { }
39 45 elsif ($$service_hist{'last_state'} == 0) { }
3 42 elsif ($$service_hist{'last_state'} == 1) { }
5 37 elsif ($$service_hist{'last_state'} == 2) { }
3 34 elsif ($$service_hist{'last_state'} == 3) { }
33 1 elsif ($$service_hist{'last_state'} == -2) { }
1 0 elsif ($$service_hist{'last_state'} == -3) { }
1093 119 5 if (defined $$data{'state'})
1094 0 119 if $verbose
1096 85 34 if $$data{'state'} >= 0
1109 0 52 if $verbose
1115 39 13 if ($report_options_start < $$data{'time'} and $report_options_end >= $$data{'time'})
1117 39 0 if (defined $$host_hist{'last_state'})
1121 1 38 if (defined $$self{'in_timeperiod'} and not $$self{'in_timeperiod'}) { }
14 24 elsif ($$host_hist{'last_state'} == 0) { }
3 21 elsif ($$host_hist{'last_state'} == 1) { }
1 20 elsif ($$host_hist{'last_state'} == 2) { }
18 2 elsif ($$host_hist{'last_state'} == -2) { }
2 0 elsif ($$host_hist{'last_state'} == -3) { }
1153 47 5 if (defined $$data{'state'})
1154 0 47 if $verbose
1156 24 23 if $$data{'state'} >= 0
1166 74 51 unless defined $scheduled_type
1167 0 125 if $verbose
1169 5 120 if ($in_downtime)
1170 0 5 if $verbose
1175 9 116 if ($$self{'report_options'}{'breakdown'} != 0)
1178 0 9 if $verbose
1179 0 9 if ($in_downtime)
1180 0 0 if $verbose
1191 0 0 unless $verbose
1193 0 0 if (ref $text ne '')
1227 0 81 unless defined $duration
1228 74 7 if $duration < 0
1230 0 81 if ($duration < 0)
1236 14 67 if ($duration >= 86400)
1240 23 58 if ($duration >= 3600)
1244 37 44 if ($duration >= 60)
1257 0 45 if $verbose
1261 35 29 if (defined $$self{'service_data'}{$host}{$service}{'last_known_state'}) { }
29 0 elsif (defined $$self{'service_data'}{$host}{$service}{'last_state'}) { }
1281 11 10 if (defined $$self{'host_data'}{$host}{'last_known_state'}) { }
10 0 elsif (defined $$self{'host_data'}{$host}{'last_state'}) { }
1305 1 19 unless defined $$options{'backtrack'}
1306 0 20 unless defined $$options{'assumeinitialstates'}
1307 1 19 unless defined $$options{'assumestateretention'}
1308 1 19 unless defined $$options{'assumestatesduringnotrunning'}
1309 20 0 unless defined $$options{'includesoftstates'}
1310 0 20 unless defined $$options{'initialassumedhoststate'}
1311 0 20 unless defined $$options{'initialassumedservicestate'}
1312 19 1 unless defined $$options{'showscheduleddowntime'}
1313 12 8 unless defined $$options{'timeformat'}
1314 18 2 unless defined $$options{'breakdown'}
1325 20 18 if (defined $$options{'backtrack'})
1326 0 20 if ($$options{'backtrack'} < 0)
1338 100 90 if (defined $$options{$yes_no})
1339 70 30 if (lc $$options{$yes_no} eq 'yes') { }
30 0 elsif (lc $$options{$yes_no} eq 'no') { }
1351 20 18 if (defined $$options{'initialassumedhoststate'})
1352 18 2 if (lc $$options{'initialassumedhoststate'} eq 'unspecified') { }
0 2 elsif (lc $$options{'initialassumedhoststate'} eq 'current') { }
2 0 elsif (lc $$options{'initialassumedhoststate'} eq 'up') { }
0 0 elsif (lc $$options{'initialassumedhoststate'} eq 'down') { }
0 0 elsif (lc $$options{'initialassumedhoststate'} eq 'unreachable') { }
1373 20 18 if (defined $$options{'initialassumedservicestate'})
1374 16 4 if (lc $$options{'initialassumedservicestate'} eq 'unspecified') { }
1 3 elsif (lc $$options{'initialassumedservicestate'} eq 'current') { }
2 1 elsif (lc $$options{'initialassumedservicestate'} eq 'ok') { }
0 1 elsif (lc $$options{'initialassumedservicestate'} eq 'warning') { }
1 0 elsif (lc $$options{'initialassumedservicestate'} eq 'unknown') { }
0 0 elsif (lc $$options{'initialassumedservicestate'} eq 'critical') { }
1398 20 18 if (defined $$options{'breakdown'})
1399 0 20 if (lc $$options{'breakdown'} eq '') { }
0 20 elsif (lc $$options{'breakdown'} eq 'months') { }
0 20 elsif (lc $$options{'breakdown'} eq 'weeks') { }
2 18 elsif (lc $$options{'breakdown'} eq 'days') { }
0 18 elsif (lc $$options{'breakdown'} eq 'none') { }
18 0 elsif ($$options{'breakdown'} == 0 or $$options{'breakdown'} == 1 or $$options{'breakdown'} == 2 or $$options{'breakdown'} == 3) { }
1432 0 105 if $verbose
1435 0 105 if $$self{'report_options'}{'build_log'} == 0
1446 0 9 if $verbose
1450 0 9 if (defined $$self{'first_known_state_before_report'})
1454 0 9 if (defined $$self{'first_known_proc_before_report'})
1460 0 9 if ($changed)
1465 2 7 if ($$self{'report_options'}{'initialassumedservicestate'} != -2 and scalar @{$$self{'report_options'}{'services'};} == 1)
1470 1 1 if ($first_state == -1)
1471 0 2 if ($first_state == 0) { }
1 1 elsif ($first_state == 1) { }
1 0 elsif ($first_state == 3) { }
0 0 elsif ($first_state == 2) { }
1476 2 0 if (defined $$self{'full_log_store'}[0])
1477 2 0 if ($fake_start >= $$self{'full_log_store'}[0]{'log'}{'start'})
1491 1 8 if ($$self{'report_options'}{'initialassumedhoststate'} != -2 and scalar @{$$self{'report_options'}{'hosts'};} == 1)
1496 0 1 if ($first_state == -1)
1497 1 0 if ($first_state == 0) { }
0 0 elsif ($first_state == 1) { }
0 0 elsif ($first_state == 2) { }
1501 0 1 if (defined $$self{'full_log_store'}[0] and $fake_start >= $$self{'full_log_store'}[0]{'log'}{'start'})
1513 0 9 if ($verbose)
1526 72 9 if (defined $$next_log_entry{'log'}{'start'}) { }
1535 80 1 if ($$self{'report_options'}{'timeformat'} ne '%s')
1540 30 51 unless defined $$log_entry{'full_only'}
1553 0 1 unless defined $string
1555 1 0 if (defined $$self{'state_string_2_int'}{$string})
1581 0 32 if $timestamp
1582 0 32 if ($breakdown != 0)
1586 0 0 if defined $$data{'breakdown'}{$timestr}
1610 5 8 if $timestamp
1611 2 11 if ($breakdown != 0)
1615 0 5 if defined $$data{'breakdown'}{$timestr}
1628 14 0 if ($$self{'report_options'}{'breakdown'} == 1) { }
0 0 elsif ($$self{'report_options'}{'breakdown'} == 2) { }
0 0 elsif ($$self{'report_options'}{'breakdown'} == 3) { }
1646 18 2 if $$self{'report_options'}{'breakdown'} == 0