-
Notifications
You must be signed in to change notification settings - Fork 0
/
avail_report_services_part.tt
129 lines (124 loc) · 8.75 KB
/
avail_report_services_part.tt
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
[% SET perc_ok_total = 0 %]
[% SET perc_warning_total = 0 %]
[% SET perc_unknown_total = 0 %]
[% SET perc_critical_total = 0 %]
[% SET perc_ok_known_total = 0 %]
[% SET perc_warning_known_total = 0 %]
[% SET perc_unknown_known_total = 0 %]
[% SET perc_critical_known_total = 0 %]
[% SET perc_undetermined_services_total = 0 %]
[% IF servicegroupname %]
<div align="center" class='dataTitle'>Servicegroup '[% g.name %]' Service State Breakdowns:</div>
[% ELSIF host %]
<div align="center" class='dataTitle'>State Breakdowns For Host Services:</div>
[% ELSE %]
<div align="center" class='dataTitle'>Service State Breakdowns:</div>
[% END %]
<div align="center">
<table border="1" class='data'>
<tr>
[% UNLESS host %]
<th class='data'>Host</th>
[% END %]
<th class='data'>Service</th>
<th class='data'>% Time Ok</th>
<th class='data'>% Time Warning</th>
<th class='data'>% Time Unknown</th>
<th class='data'>% Time Critical</th>
<th class='data'>% Time Undetermined</th>
</tr>
[% SET lasthost = '' %]
[% SET servicecount = 0 %]
[% FOR hostname IN services.keys.sort %]
[% FOR servicename IN services.$hostname.keys.sort %]
[% SET class = 'dataEven' IF servicecount % 2 == 0 %]
[% SET class = 'dataOdd' IF servicecount % 2 != 0 %]
[% SET servicecount = servicecount + 1 %]
[% SET
total_time_unknown =
avail_data.services.$hostname.$servicename.time_indeterminate_nodata
+ avail_data.services.$hostname.$servicename.time_indeterminate_notrunning
+ avail_data.services.$hostname.$servicename.time_indeterminate_outside_timeperiod
%]
[% SET
total_time =
avail_data.services.$hostname.$servicename.time_ok
+ avail_data.services.$hostname.$servicename.time_warning
+ avail_data.services.$hostname.$servicename.time_unknown
+ avail_data.services.$hostname.$servicename.time_critical
+ avail_data.services.$hostname.$servicename.time_indeterminate_nodata
+ avail_data.services.$hostname.$servicename.time_indeterminate_notrunning
+ avail_data.services.$hostname.$servicename.time_indeterminate_outside_timeperiod
%]
[% SET
total_time_known = total_time - total_time_unknown
%]
[% IF total_time > 0 %]
[% SET perc_ok = avail_data.services.$hostname.$servicename.time_ok / total_time * 100 %]
[% SET perc_warning = avail_data.services.$hostname.$servicename.time_warning / total_time * 100 %]
[% SET perc_unknown = avail_data.services.$hostname.$servicename.time_unknown / total_time * 100 %]
[% SET perc_critical = avail_data.services.$hostname.$servicename.time_critical / total_time * 100 %]
[% SET perc_undetermined = total_time_unknown / total_time * 100 %]
[% ELSE %]
[% SET perc_ok = 0 %]
[% SET perc_warning = 0 %]
[% SET perc_unknown = 0 %]
[% SET perc_critical = 0 %]
[% SET perc_undetermined = 0 %]
[% END %]
[% IF total_time_known > 0 %]
[% SET perc_ok_known = avail_data.services.$hostname.$servicename.time_ok / total_time_known * 100 %]
[% SET perc_warning_known = avail_data.services.$hostname.$servicename.time_warning / total_time_known * 100 %]
[% SET perc_unknown_known = avail_data.services.$hostname.$servicename.time_unknown / total_time_known * 100 %]
[% SET perc_critical_known = avail_data.services.$hostname.$servicename.time_critical / total_time_known * 100 %]
[% ELSE %]
[% SET perc_ok_known = 0 %]
[% SET perc_warning_known = 0 %]
[% SET perc_unknown_known = 0 %]
[% SET perc_critical_known = 0 %]
[% END %]
[% SET perc_ok_total = perc_ok_total + perc_ok %]
[% SET perc_warning_total = perc_warning_total + perc_warning %]
[% SET perc_unknown_total = perc_unknown_total + perc_unknown %]
[% SET perc_critical_total = perc_critical_total + perc_critical %]
[% SET perc_ok_known_total = perc_ok_known_total + perc_ok_known %]
[% SET perc_warning_known_total = perc_warning_known_total + perc_warning_known %]
[% SET perc_unknown_known_total = perc_unknown_known_total + perc_unknown_known %]
[% SET perc_critical_known_total = perc_critical_known_total + perc_critical_known %]
[% SET perc_undetermined_services_total = perc_undetermined_services_total + perc_undetermined %]
<tr class='[% class %]'>
[% UNLESS host %]
<td class='[% class %]'>[% IF lasthost != hostname %]<a href='avail.cgi?host=[% hostname | uri %][% IF show_log_entries %]&show_log_entries[% ELSIF full_log_entries %]&full_log_entries[% END %]&t1=[% start %]&t2=[% end %]&backtrack=[% backtrack %]&assumestateretention=[% assumestateretention %]&assumeinitialstates=[% assumeinitialstates %]&assumestatesduringnotrunning=[% assumestatesduringnotrunning %]&initialassumedhoststate=[% initialassumedhoststate %]&initialassumedservicestate=[% initialassumedservicestate %]&showscheduleddowntime=[% showscheduleddowntime %]&rpttimeperiod=[% rpttimeperiod %]'>[% hostname %]</a>[% END %]</td>
[% END %]
<td class='[% class %]'><a href='avail.cgi?host=[% hostname | uri %]&service=[% servicename | uri %]&t1=[% start %]&t2=[% end %]&backtrack=[% backtrack %]&assumestateretention=[% assumestateretention %]&assumeinitialstates=[% assumeinitialstates %]&assumestatesduringnotrunning=[% assumestatesduringnotrunning %]&initialassumedhoststate=[% initialassumedhoststate %]&initialassumedservicestate=[% initialassumedservicestate %][% IF show_log_entries %]&show_log_entries[% ELSIF full_log_entries %]&full_log_entries[% END %]&showscheduleddowntime=[% showscheduleddowntime %]&rpttimeperiod=[% rpttimeperiod %]'>[% servicename %]</a></td>
<td class='serviceOK'>[% sprintf('%2.3f', perc_ok) %]% ([% sprintf('%2.3f', perc_ok_known ) %]%)</td>
<td class='serviceWARNING'>[% sprintf('%2.3f', perc_warning) %]% ([% sprintf('%2.3f', perc_warning_known ) %]%)</td>
<td class='serviceUNKNOWN'>[% sprintf('%2.3f', perc_unknown) %]% ([% sprintf('%2.3f', perc_unknown_known ) %]%)</td>
<td class='serviceCRITICAL'>[% sprintf('%2.3f', perc_critical) %]% ([% sprintf('%2.3f', perc_critical_known ) %]%)</td>
<td class='[% class %]'>[% sprintf('%2.3f', perc_undetermined) %]%</td>
</tr>
[% lasthost = hostname %]
[% END %]
[% END %]
[% SET avgClass = 'dataEven' %]
[% SET avgClass = 'dataOdd' IF class == 'dataEven' %]
<tr class='[% avgClass %]'>
<td class='[% avgClass %]'[% UNLESS host %] colspan=2[% END %]>Average</td>
[% IF servicecount %]
<td class='serviceOK'>[% sprintf('%2.3f', perc_ok_total / servicecount) %]% ([% sprintf('%2.3f', perc_ok_known_total / servicecount) %]%)</td>
<td class='serviceWARNING'>[% sprintf('%2.3f', perc_warning_total / servicecount) %]% ([% sprintf('%2.3f', perc_warning_known_total / servicecount) %]%)</td>
<td class='serviceUNKNOWN'>[% sprintf('%2.3f', perc_unknown_total / servicecount) %]% ([% sprintf('%2.3f', perc_unknown_known_total / servicecount) %]%)</td>
<td class='serviceCRITICAL'>[% sprintf('%2.3f', perc_critical_total / servicecount) %]% ([% sprintf('%2.3f', perc_critical_known_total / servicecount) %]%)</td>
<td class='[% avgClass %]'>[% sprintf('%2.3f', perc_undetermined_services_total / servicecount) %]%</td>
[% ELSE %]
<td class='serviceOK'>[% sprintf('%2.3f', 0) %]% ([% sprintf('%2.3f', 0 ) %]%)</td>
<td class='serviceWARNING'>[% sprintf('%2.3f', 0 ) %]% ([% sprintf('%2.3f', 0 ) %]%)</td>
<td class='serviceUNKNOWN'>[% sprintf('%2.3f', 0 ) %]% ([% sprintf('%2.3f', 0 ) %]%)</td>
<td class='serviceCRITICAL'>[% sprintf('%2.3f', 0 ) %]% ([% sprintf('%2.3f', 0 ) %]%)</td>
<td class='[% avgClass %]'>[% sprintf('%2.3f', 0 ) %]%</td>
[% END %]
</tr>
</table>
</div>
<br>
<br>