1 | <?php |
---|
2 | /* template head */ |
---|
3 | if (function_exists('Dwoo_Plugin_include')===false) |
---|
4 | $this->getLoader()->loadPlugin('include'); |
---|
5 | if (function_exists('Dwoo_Plugin_regex_replace')===false) |
---|
6 | $this->getLoader()->loadPlugin('regex_replace'); |
---|
7 | /* end template head */ ob_start(); /* template body */ ?><!-- Begin host_view.tpl --> |
---|
8 | <style type="text/css"> |
---|
9 | /* don't display legends for these small graphs */ |
---|
10 | .flotlegend, .flotlegendtoplabel { |
---|
11 | display: none !important; |
---|
12 | } |
---|
13 | .flotheader { |
---|
14 | margin-top: 2em; |
---|
15 | } |
---|
16 | .flottitle { |
---|
17 | padding-right: 4em; |
---|
18 | font-weight: bold; |
---|
19 | } |
---|
20 | .img_view { |
---|
21 | float: left; |
---|
22 | margin: 0 0 10px 10px; |
---|
23 | } |
---|
24 | </style> |
---|
25 | <script type="text/javascript"> |
---|
26 | var SEPARATOR = "_|_"; |
---|
27 | var ALL_GROUPS = "ALLGROUPS"; |
---|
28 | var NO_GROUPS = "NOGROUPS"; |
---|
29 | // Map metric group id to name |
---|
30 | var g_mgMap = new Object(); |
---|
31 | |
---|
32 | function clearStoredMetricGroups() { |
---|
33 | var stored_groups = $('input[name="metric_group"]'); |
---|
34 | stored_groups.val(NO_GROUPS); |
---|
35 | } |
---|
36 | |
---|
37 | function selectAllMetricGroups() { |
---|
38 | var stored_groups = $('input[name="metric_group"]'); |
---|
39 | stored_groups.val(ALL_GROUPS); |
---|
40 | } |
---|
41 | |
---|
42 | function addMetricGroup(mgName) { |
---|
43 | var stored_groups = $('input[name="metric_group"]'); |
---|
44 | |
---|
45 | var open_groups = stored_groups.val(); |
---|
46 | if (open_groups == ALL_GROUPS) |
---|
47 | return; // no exceptions |
---|
48 | |
---|
49 | var groups = open_groups.split(SEPARATOR); |
---|
50 | switch (groups[0]) { |
---|
51 | case ALL_GROUPS: |
---|
52 | // Remove from except list |
---|
53 | for (var i = 1; i < groups.length; i++) { |
---|
54 | if (groups[i] == mgName) { |
---|
55 | groups.splice(i, 1); |
---|
56 | break; |
---|
57 | } |
---|
58 | } |
---|
59 | open_groups = groups.join(SEPARATOR); |
---|
60 | break; |
---|
61 | case NO_GROUPS: |
---|
62 | // Add to list if not already there |
---|
63 | var inList = false; |
---|
64 | for (var i = 1; i < groups.length; i++) { |
---|
65 | if (groups[i] == mgName) { |
---|
66 | inList = true; |
---|
67 | break; |
---|
68 | } |
---|
69 | } |
---|
70 | if (!inList) { |
---|
71 | open_groups += SEPARATOR; |
---|
72 | open_groups += mgName; |
---|
73 | } |
---|
74 | break; |
---|
75 | default: |
---|
76 | alert("Unrecognized group option - " + groups[0]); |
---|
77 | } |
---|
78 | stored_groups.val(open_groups); |
---|
79 | } |
---|
80 | |
---|
81 | function removeMetricGroup(mgName) { |
---|
82 | var stored_groups = $('input[name="metric_group"]'); |
---|
83 | |
---|
84 | var open_groups = stored_groups.val(); |
---|
85 | if (open_groups == NO_GROUPS) |
---|
86 | return; // no exceptions |
---|
87 | |
---|
88 | var groups = open_groups.split(SEPARATOR); |
---|
89 | switch (groups[0]) { |
---|
90 | case ALL_GROUPS: |
---|
91 | var inList = false; |
---|
92 | for (var i = 1; i < groups.length; i++) { |
---|
93 | if (groups[i] == mgName) { |
---|
94 | inList = true; |
---|
95 | break; |
---|
96 | } |
---|
97 | } |
---|
98 | if (!inList) { |
---|
99 | open_groups += SEPARATOR; |
---|
100 | open_groups += mgName; |
---|
101 | } |
---|
102 | break; |
---|
103 | case NO_GROUPS: |
---|
104 | for (var i = 1; i < groups.length; i++) { |
---|
105 | if (groups[i] == mgName) { |
---|
106 | groups.splice(i, 1); |
---|
107 | break; |
---|
108 | } |
---|
109 | } |
---|
110 | open_groups = groups.join(SEPARATOR); |
---|
111 | break; |
---|
112 | default: |
---|
113 | alert("Unrecognized group option - " + groups[0]); |
---|
114 | } |
---|
115 | stored_groups.val(open_groups); |
---|
116 | } |
---|
117 | |
---|
118 | function toggleMetricGroup(mgId, mgDiv) { |
---|
119 | var mgName = g_mgMap[mgId]; |
---|
120 | if (mgDiv.is(":visible")) { |
---|
121 | // metric group is being closed |
---|
122 | removeMetricGroup(mgName); |
---|
123 | mgDiv.html(""); |
---|
124 | mgDiv.hide(); |
---|
125 | } else { |
---|
126 | addMetricGroup(mgName); |
---|
127 | var url = 'metric_group_view.php?<?php echo $this->scope["baseGraphArgs"];?>&metric_group=' + mgName; |
---|
128 | url += "&event="; |
---|
129 | url += ($("#show_all_events").attr("checked") == "checked") ? "show" : "hide"; |
---|
130 | url += "&ts="; |
---|
131 | url += ($("#timeshift_overlay").attr("checked") == "checked") ? "1" : "0"; |
---|
132 | |
---|
133 | $.get(url, |
---|
134 | function(data) { |
---|
135 | mgDiv.html(data); |
---|
136 | mgInitEventBtns(mgDiv); |
---|
137 | mgInitTimeshiftBtns(mgDiv); |
---|
138 | mgDiv.show(); |
---|
139 | }); |
---|
140 | } |
---|
141 | } |
---|
142 | |
---|
143 | function jumpToMetricGroup(mgId) { |
---|
144 | //alert("jumping to " + mgId); |
---|
145 | $.scrollTo($('#' + mgId)); |
---|
146 | } |
---|
147 | |
---|
148 | function refreshHostView() { |
---|
149 | $.get('host_overview.php?h=<?php echo $this->scope["hostname"];?>&c=<?php echo $this->scope["cluster"];?>', function(data) { |
---|
150 | $('#host_overview_div').html(data); |
---|
151 | }); |
---|
152 | |
---|
153 | $("#optional_graphs img").each(function (index) { |
---|
154 | var src = $(this).attr("src"); |
---|
155 | if ((src.indexOf("graph.php") == 0) || |
---|
156 | (src.indexOf("./graph.php") == 0)) { |
---|
157 | var d = new Date(); |
---|
158 | $(this).attr("src", jQuery.param.querystring(src, "&_=" + d.getTime())); |
---|
159 | } |
---|
160 | }); |
---|
161 | |
---|
162 | $("#metrics img").each(function (index) { |
---|
163 | var src = $(this).attr("src"); |
---|
164 | if ((src.indexOf("graph.php") == 0) || |
---|
165 | (src.indexOf("./graph.php") == 0)) { |
---|
166 | var d = new Date(); |
---|
167 | $(this).attr("src", jQuery.param.querystring(src, "&_=" + d.getTime())); |
---|
168 | } |
---|
169 | }); |
---|
170 | } |
---|
171 | |
---|
172 | function mgInitEventBtns(mgDiv) { |
---|
173 | var checked = $("#show_all_events").attr("checked"); |
---|
174 | mgDiv.find("[id^=" + SHOW_EVENTS_BASE_ID + "]").each(function() { |
---|
175 | $(this).button(); |
---|
176 | if (checked == "checked") |
---|
177 | $(this).attr("checked", 'checked'); |
---|
178 | else |
---|
179 | $(this).removeAttr("checked"); |
---|
180 | $(this).button('refresh'); |
---|
181 | }); |
---|
182 | } |
---|
183 | |
---|
184 | function mgInitTimeshiftBtns(mgDiv) { |
---|
185 | var checked = $("#timeshift_overlay").attr("checked"); |
---|
186 | mgDiv.find("[id^=" + TIME_SHIFT_BASE_ID + "]").each(function() { |
---|
187 | $(this).button(); |
---|
188 | if (checked == "checked") |
---|
189 | $(this).attr("checked", 'checked'); |
---|
190 | else |
---|
191 | $(this).removeAttr("checked"); |
---|
192 | $(this).button('refresh'); |
---|
193 | }); |
---|
194 | } |
---|
195 | |
---|
196 | $(function() { |
---|
197 | var stored_groups = $('input[name="metric_group"]'); |
---|
198 | stored_groups.val("<?php echo $this->scope["g_open_metric_groups"];?>"); |
---|
199 | |
---|
200 | $("#edit_optional_graphs").dialog({ autoOpen: false, minWidth: 550, |
---|
201 | beforeClose: function(event, ui) { location.reload(true); } }); |
---|
202 | |
---|
203 | $("#close_edit_optional_graphs_link").button(); |
---|
204 | $("#popup-dialog").dialog({ autoOpen: false, minWidth: 850 }); |
---|
205 | |
---|
206 | $("#edit_optional_graphs_button").button(); |
---|
207 | $("#edit_optional_graphs_button").click(function(event) { |
---|
208 | $("#edit_optional_graphs").dialog('open'); |
---|
209 | $('#edit_optional_graphs_content').html('<img src="img/spinner.gif" />'); |
---|
210 | $.get('edit_optional_graphs.php', "hostname=<?php echo $this->scope["hostname"];?>", function(data) { |
---|
211 | $('#edit_optional_graphs_content').html(data); |
---|
212 | }) |
---|
213 | return false; |
---|
214 | }); |
---|
215 | |
---|
216 | $("#save_optional_graphs_button").button(); |
---|
217 | $("#save_optional_graphs_button").click(function(event) { |
---|
218 | $.get('edit_optional_graphs.php', $("#edit_optional_reports_form").serialize(), function(data) { |
---|
219 | $('#edit_optional_graphs_content').html(data); |
---|
220 | $("#save_optional_graphs_button").hide(); |
---|
221 | }); |
---|
222 | return false; |
---|
223 | }); |
---|
224 | |
---|
225 | $("#expand_all_metric_groups").button(); |
---|
226 | $("#expand_all_metric_groups").click(function(event) { |
---|
227 | selectAllMetricGroups(); |
---|
228 | document.ganglia_form.submit(); |
---|
229 | return false; |
---|
230 | }); |
---|
231 | |
---|
232 | $("#collapse_all_metric_groups").button(); |
---|
233 | $("#collapse_all_metric_groups").click(function(event) { |
---|
234 | clearStoredMetricGroups(); |
---|
235 | document.ganglia_form.submit(); |
---|
236 | return false; |
---|
237 | }); |
---|
238 | |
---|
239 | $("#host_overview").button(); |
---|
240 | $('#host_overview').click(function() { |
---|
241 | var options = { to: { width: 200, height: 60 } }; |
---|
242 | $("#host_overview_div").toggle("blind", options, 500); |
---|
243 | return false; |
---|
244 | }); |
---|
245 | |
---|
246 | $('.metric-group').each(function() { |
---|
247 | $(this).button(); |
---|
248 | $(this).click(function() { |
---|
249 | var id = $(this).attr('id'); |
---|
250 | toggleMetricGroup(id, $("#"+id+"_div")); |
---|
251 | return false; |
---|
252 | }); |
---|
253 | }); |
---|
254 | }); |
---|
255 | </script> |
---|
256 | |
---|
257 | <?php if ((isset($this->scope["graph_engine"]) ? $this->scope["graph_engine"] : null) == "flot") { |
---|
258 | ?> |
---|
259 | <script language="javascript" type="text/javascript" src="js/jquery.flot.min.js"></script> |
---|
260 | <script type="text/javascript" src="js/create-flot-graphs.js"></script> |
---|
261 | <style type="text/css"> |
---|
262 | .flotgraph2 { |
---|
263 | height: <?php echo $this->scope["graph_height"];?>px; |
---|
264 | width: <?php echo $this->scope["graph_width"];?>px; |
---|
265 | } |
---|
266 | </style> |
---|
267 | <?php |
---|
268 | }?> |
---|
269 | |
---|
270 | |
---|
271 | <style type="text/css"> |
---|
272 | .toggler { width: 500px; height: 200px; } |
---|
273 | #effect { width: 240px; height: 135px; padding: 0.4em; position: relative; } |
---|
274 | #effect h3 { margin: 0; padding: 0.4em; text-align: center; } |
---|
275 | </style> |
---|
276 | |
---|
277 | <div id="metric-actions-dialog" title="Metric Actions"> |
---|
278 | <div id="metric-actions-dialog-content"> |
---|
279 | Available Metric actions. |
---|
280 | </div> |
---|
281 | </div> |
---|
282 | <div id="popup-dialog" title="Inspect Graph"> |
---|
283 | <div id="popup-dialog-navigation"></div> |
---|
284 | <div id="popup-dialog-content"> |
---|
285 | </div> |
---|
286 | </div> |
---|
287 | |
---|
288 | <div> |
---|
289 | <button id="host_overview" class="button">Host Overview</button> |
---|
290 | </div> |
---|
291 | |
---|
292 | <div style="display: none;" id="host_overview_div"> |
---|
293 | <?php echo Dwoo_Plugin_include($this, 'host_overview.tpl', null, null, null, '_root', null);?> |
---|
294 | |
---|
295 | </div> |
---|
296 | |
---|
297 | <div id="edit_optional_graphs"> |
---|
298 | <div style="text-align:center"> |
---|
299 | <button id="save_optional_graphs_button">Save</button> |
---|
300 | </div> |
---|
301 | <div id="edit_optional_graphs_content" style="padding: .4em 1em .4em 10px;">Empty</div> |
---|
302 | </div> |
---|
303 | |
---|
304 | <div id="optional_graphs" style="padding-top:5px;"> |
---|
305 | <?php echo $this->scope["optional_reports"];?> |
---|
306 | |
---|
307 | <div style='clear: left'></div> |
---|
308 | <?php if ((isset($this->scope["may_edit_cluster"]) ? $this->scope["may_edit_cluster"] : null)) { |
---|
309 | ?> |
---|
310 | <div style="text-align:center"><button id="edit_optional_graphs_button">Edit Optional Graphs</button></div> |
---|
311 | <?php |
---|
312 | }?> |
---|
313 | |
---|
314 | </div> |
---|
315 | |
---|
316 | <div id="sort_column_dropdowns" style="padding-top:5px;"> |
---|
317 | <table border="0" width="100%"> |
---|
318 | <tr> |
---|
319 | <td style="text-align:center;background-color:rgb(238,238,238);"> |
---|
320 | <?php echo $this->scope["host"];?> <strong>graphs</strong> (<?php echo $this->scope["host_metrics_count"];?>) |
---|
321 | last <strong><?php echo $this->scope["range"];?></strong> |
---|
322 | sorted <strong><?php echo $this->scope["sort"];?></strong> |
---|
323 | <?php if (((isset($this->scope["columns_dropdown"]) ? $this->scope["columns_dropdown"] : null) !== null)) { |
---|
324 | ?> |
---|
325 | <font> |
---|
326 | Columns <?php echo $this->scope["metric_cols_menu"];?> |
---|
327 | |
---|
328 | Size <?php echo $this->scope["size_menu"];?> |
---|
329 | |
---|
330 | </font> |
---|
331 | <?php |
---|
332 | }?> |
---|
333 | |
---|
334 | </td> |
---|
335 | </tr> |
---|
336 | </table> |
---|
337 | |
---|
338 | </div> |
---|
339 | |
---|
340 | <div id=metrics style="padding-top:5px"> |
---|
341 | <center> |
---|
342 | <div style="padding-bottom:5px;"> |
---|
343 | <button id="expand_all_metric_groups">Expand All Metric Groups</button> |
---|
344 | <button id="collapse_all_metric_groups">Collapse All Metric Groups</button> |
---|
345 | <input title="Time Shift Overlay - overlays previous period on all graphs" type="checkbox" id="timeshift_overlay" onclick="showTimeshiftOverlay(this.checked)"/><label for="timeshift_overlay">Timeshift Overlay</label> |
---|
346 | <select id="jump_to_metric_group" class="ui-corner-all" onchange="jumpToMetricGroup(this.options[this.selectedIndex].value);"> |
---|
347 | <option disabled="disabled" selected="selected">Jump To Metric Group...</option> |
---|
348 | <?php |
---|
349 | $_fh0_data = (isset($this->scope["g_metrics_group_data"]) ? $this->scope["g_metrics_group_data"] : null); |
---|
350 | if ($this->isTraversable($_fh0_data) == true) |
---|
351 | { |
---|
352 | foreach ($_fh0_data as $this->scope['group']=>$this->scope['g_metrics']) |
---|
353 | { |
---|
354 | /* -- foreach start output */ |
---|
355 | ?> |
---|
356 | <?php $this->scope["mgId"]="mg_"; |
---|
357 | $this->scope["mgId"].=Dwoo_Plugin_regex_replace($this, (isset($this->scope["group"]) ? $this->scope["group"] : null), '/[^a-zA-Z0-9_]/', '_')?> |
---|
358 | |
---|
359 | <option value="<?php echo $this->scope["mgId"];?>"><?php echo $this->scope["group"];?></a> |
---|
360 | <?php |
---|
361 | /* -- foreach end output */ |
---|
362 | } |
---|
363 | }?> |
---|
364 | |
---|
365 | </select> |
---|
366 | </div> |
---|
367 | <table> |
---|
368 | <tr> |
---|
369 | <td> |
---|
370 | |
---|
371 | <?php |
---|
372 | $_fh1_data = (isset($this->scope["g_metrics_group_data"]) ? $this->scope["g_metrics_group_data"] : null); |
---|
373 | if ($this->isTraversable($_fh1_data) == true) |
---|
374 | { |
---|
375 | foreach ($_fh1_data as $this->scope['group']=>$this->scope['g_metrics']) |
---|
376 | { |
---|
377 | /* -- foreach start output */ |
---|
378 | ?> |
---|
379 | <?php $this->scope["mgId"]="mg_"; |
---|
380 | $this->scope["mgId"].=Dwoo_Plugin_regex_replace($this, (isset($this->scope["group"]) ? $this->scope["group"] : null), '/[^a-zA-Z0-9_]/', '_')?> |
---|
381 | |
---|
382 | <table border="0" width="100%"> |
---|
383 | <tr> |
---|
384 | <td class="metric"> |
---|
385 | <button id="<?php echo $this->scope["mgId"];?>" class="metric-group" title="Toggle <?php echo $this->scope["group"];?> metrics group on/off"><?php echo $this->scope["group"];?> metrics (<?php echo $this->scope["g_metrics"]["group_metric_count"];?>)</button> |
---|
386 | <script type="text/javascript">$(function() { |
---|
387 | g_mgMap["<?php echo $this->scope["mgId"];?>"] = "<?php echo $this->scope["group"];?>"; |
---|
388 | })</script> |
---|
389 | </td> |
---|
390 | </tr> |
---|
391 | </table> |
---|
392 | |
---|
393 | <?php if ((isset($this->scope["g_metrics"]["visible"]) ? $this->scope["g_metrics"]["visible"]:null)) { |
---|
394 | ?> |
---|
395 | <div id="<?php echo $this->scope["mgId"];?>_div"> |
---|
396 | <?php |
---|
397 | } |
---|
398 | else { |
---|
399 | ?> |
---|
400 | <div id="<?php echo $this->scope["mgId"];?>_div" class="ui-helper-hidden"> |
---|
401 | <?php |
---|
402 | }?> |
---|
403 | |
---|
404 | <?php if ((isset($this->scope["g_metrics"]["visible"]) ? $this->scope["g_metrics"]["visible"]:null)) { |
---|
405 | ?> |
---|
406 | <?php echo Dwoo_Plugin_include($this, 'metric_group_view.tpl', null, null, null, '_root', null);?> |
---|
407 | |
---|
408 | <?php |
---|
409 | }?> |
---|
410 | |
---|
411 | </div> |
---|
412 | <?php |
---|
413 | /* -- foreach end output */ |
---|
414 | } |
---|
415 | }?> |
---|
416 | |
---|
417 | </td> |
---|
418 | </tr> |
---|
419 | </table> |
---|
420 | </center> |
---|
421 | </div> |
---|
422 | <input type="hidden" name="metric_group" value=""> |
---|
423 | <!-- End host_view.tpl --> |
---|
424 | <?php /* end template body */ |
---|
425 | return $this->buffer . ob_get_clean(); |
---|
426 | ?> |
---|