histogram: Make histograms crash less
[ninja.git] / application / views / extinfo / index.php
blob55ba3a53d19fcb8ae3abbf8dd3f67c4110ecb86e
1 <?php defined('SYSPATH') OR die('No direct access allowed.');
2 $notes_url_target = config::get('nagdefault.notes_url_target', '*');
3 $action_url_target = config::get('nagdefault.action_url_target', '*');
4 $date_format_str = nagstat::date_format();
6 $green_shield = '<span class="icon-16 x16-shield-up"></span>';
7 $red_shield = '<span class="icon-16 x16-shield-down"></span>';
8 $enabled = $green_shield.' '._('Enabled');
9 $disabled = $red_shield.' '._('Disabled');
10 $yes = _('Yes');
11 $no = _('No');
12 $logos_path = Kohana::config('config.logos_path');
13 $logos_path.= substr($logos_path, -1) == '/' ? '' : '/';
14 $table = 'unknown';
16 if( $object instanceof Host_Model ) {
17 $host = $object;
18 $service = false;
19 $type = 'host';
20 $table = 'hosts';
21 } else if( $object instanceof Service_Model ) {
22 $host = $object->get_host();
23 $service = $object;
24 $type = 'service';
25 $table = 'services';
27 /* @var $host Host_Model */
28 /* @var $service Service_Model */
29 /* @var $object Service_Model */
32 if (isset($page_links)) {
35 <div id="page_links">
36 <em class="page-links-label"><?php echo _('View').', '.$label_view_for.':'; ?></em>
37 <ul>
38 <?php foreach ($page_links as $label => $link) { ?>
39 <li><?php echo html::anchor($link, $label) ?></li>
40 <?php } ?>
41 </ul>
42 <div class="clear"></div>
43 </div>
44 <?php
46 if (!empty($widgets)) {
47 foreach ($widgets as $widget) {
48 echo $widget;
53 <div id="extinfo_host-info">
54 <table>
55 <tr>
57 <?php if ($service !== false) {
58 echo "<th>" . _("On host") . "</th>";
59 } ?>
61 <th><?php echo _("Address"); ?> </th>
63 <?php if ($host->get_parents()) { ?>
64 <th><?php echo _("Parents"); ?> </th>
65 <?php } ?>
67 <th><?php echo _('Member of'); ?></th>
68 <th><?php echo _('Contact groups') ?></th>
69 <th><?php echo _('Contacts') ?></th>
71 </tr>
72 <tr>
74 <?php
75 if ($service !== false) {
76 echo '<td style="max-width: 300px">';
77 echo html::anchor('extinfo/details/?host='.urlencode($host->get_name()), html::specialchars($host->get_display_name()));
78 echo $host->get_alias() ? ' ('.html::specialchars($host->get_alias()).')' : '';
79 echo '</td>';
82 <td><?php echo $host->get_address(); ?></td>
84 <?php if ($host->get_parents()) { ?>
85 <td>
86 <?php
87 echo implode(
88 ',',
89 array_map(
90 function($parent) {
91 return html::anchor('status/service/'.$parent, $parent);
93 $host->get_parents()
97 </td>
98 <?php } ?>
100 <td style="white-space: normal">
101 <?php $groups=$object->get_groups();
102 if( count($groups) == 0 ) {
103 echo _('No '.$type.'groups');
105 $delim = "";
106 foreach( $groups as $group ) {
107 print $delim;
108 print "<a href=\"" . htmlentities(url::base(true) . "listview/?q=[" . $table . "] groups >= \"" . urlencode(addslashes($group)) . "\"") . "\">";
109 print html::specialchars( $group );
110 print "</a>";
111 $delim = ", ";
114 </td>
115 <td>
116 <?php
117 $c = 0;
118 $groups = $object->get_contact_groups();
119 $contacts = $object->get_contacts();
121 foreach ($groups as $group) {
122 echo '<a href="#" title="'._('Contactgroup').': '.$group.', '._('Click to view contacts').'" class="extinfo_contactgroup" id="extinfo_contactgroup_'.(++$c).'">';
123 echo $group.'</a>';
125 <table id="extinfo_contacts_<?php echo $c ?>" style="display:none" class="extinfo_contacts">
126 <tr>
127 <th><?php echo _('Contact name') ?></th>
128 <th><?php echo _('Alias') ?></th>
129 <th><?php echo _('Email') ?></th>
130 <th><?php echo _('Pager') ?></th>
131 </tr>
132 <?php
133 $gobj = ContactGroupPool_Model::all()->reduce_by('name',$group,'=')->one(array('members'));
135 $gmembers = ContactPool_Model::none();
136 $allcontacts = ContactPool_Model::all();
138 $group_member_names = $gobj->get_members();
139 $contacts = array_diff( $contacts, $group_member_names );
141 foreach( $group_member_names as $member ) {
142 $gmembers = $gmembers->union($allcontacts->reduce_by('name', $member, '='));
145 foreach ($gmembers as $member) { ?>
146 <tr class="<?php echo ($c%2 == 0) ? 'even' : 'odd' ?>">
147 <td><?php echo $member->get_name(); ?></td>
148 <td><?php echo $member->get_alias(); ?></td>
149 <td><?php echo $member->get_email(); ?></td>
150 <td><?php echo $member->get_pager(); ?></td>
151 </tr>
152 <?php } ?>
153 </table>
154 <?php } ?>
155 </td>
156 <td style="padding: 0">
157 <?php if( count( $contacts ) ) { ?>
158 <table class="extinfo_contacts" style="display: table; border: none">
159 <tr>
160 <td style="border-top: none"><?php echo _('Name') ?></td>
161 <td style="border-top: none"><?php echo _('Alias') ?></td>
162 <td style="border-top: none"><?php echo _('Email') ?></td>
163 <td style="border-top: none"><?php echo _('Pager') ?></td>
164 </tr>
165 <?php
167 $gmembers = ContactPool_Model::none();
168 $allcontacts = ContactPool_Model::all();
169 foreach( $contacts as $member ) {
170 $gmembers = $gmembers->union($allcontacts->reduce_by('name', $member, '='));
173 foreach ($gmembers as $member) { ?>
174 <tr class="<?php echo ($c%2 == 0) ? 'even' : 'odd' ?>">
175 <td><?php echo $member->get_name(); ?></td>
176 <td><?php echo $member->get_alias(); ?></td>
177 <td><?php echo $member->get_email(); ?></td>
178 <td><?php echo $member->get_pager(); ?></td>
179 </tr>
180 <?php } ?>
181 </table>
182 <?php } ?>
183 </td>
184 </tr>
185 <tr>
186 <?php if ($object->get_notes()) {?>
187 <td><strong><?php echo _('Notes') ?></strong></td>
188 <td><?php echo $object->get_notes() ?></td>
189 <?php } ?>
190 <td colspan="5" style="padding-top: 7px; border-bottom: none">
191 <?php
192 if ($url = $object->get_action_url()) {
193 echo '<a href="'.$url.'" target="'.$action_url_target.'">';
194 echo '<span class="icon-16 x16-host-actions" title="'. _('Perform extra '.$type.' actions').'"></span>';
195 echo _('Extra actions').'</a>';
197 if ($url = $object->get_notes_url()) {
198 echo '&nbsp; <a target="'.$notes_url_target.'" href="'.$url.'">';
199 echo '<span class="icon-16 x16-host-notes" title="'. _('View extra '.$type.' notes').'"></span>';
200 echo _('Extra notes').'</a>';
202 if ($url = $object->get_config_url()) {
203 echo '&nbsp; <a href="'.$url.'">';
204 echo '<span class="icon-16 x16-nacoma" title="'. _('Configure '.$type).'"></span>';
205 echo _('Configure').'</a>';
207 if (0<$object->get_pnpgraph_present()) {
208 $url = url::site() . 'pnp/?host=' . rawurlencode($host->get_name());
209 $pnp_host = $host->get_name();
210 $pnp_service = "_HOST_";
211 if($service!==false) {
212 $url .= '&srv=' . rawurlencode($service->get_description());
213 $pnp_service = $service->get_description();
214 } else {
215 $url .= '&srv=_HOST_';
217 echo '&nbsp; <a class="pnp_graph" data-host="'.$pnp_host.'" data-srv="'.$pnp_service.'" href="'.$url.'">';
218 echo '<span class="icon-16 x16-pnp"></span>';
219 echo _('Show performance graph').'</a>';
222 </td>
223 </tr>
224 </table>
225 </div>
227 <div class="clear"></div>
229 <div class="left width-66" id="extinfo_current">
230 <table class="ext">
231 <tr>
232 <th colspan="2"><?php echo $object->get_key() ?></th>
233 </tr>
234 <tr>
235 <td style="width: 160px" class="dark bt"><?php echo _('Current status'); ?></td>
236 <td class="bt" id="field_current_status">
237 <span class="status-<?php echo strtolower($object->get_state_text()) ?>"><span class="icon-16 x16-shield-<?php echo strtolower($object->get_state_text()); ?>"></span><?php echo ucfirst(strtolower($object->get_state_text())) ?></span>
238 (<?php echo _('for'); ?> <?php echo $object->get_duration()>=0 ? time::to_string($object->get_duration()) : _('N/A') ?>)
239 </td>
240 </tr>
241 <?php
242 $output = $object->get_plugin_output();
243 $long_plugin_output = $object->get_long_plugin_output();
244 if($long_plugin_output) {
245 $output .= '<br />'.nl2br($long_plugin_output);
248 <tr>
249 <td class="dark"><?php echo _('Status information'); ?></td>
250 <td class="long_output" style="white-space: normal" id="field_plugin_output"><?php echo security::xss_clean($output) ?></td>
251 </tr>
252 <tr>
253 <td class="dark"><?php echo _('Performance data'); ?></td>
254 <td style="white-space: normal" id="field_perf_data">
255 <?php
256 $perf_data = $object->get_perf_data();
257 if(count($perf_data)):
259 <table>
260 <thead>
261 <tr>
262 <th><?php echo _('Data source');?></th>
263 <th><?php echo _('Value');?></th>
264 <th><?php echo _('Warn');?></th>
265 <th><?php echo _('Crit');?></th>
266 <th><?php echo _('Min');?></th>
267 <th><?php echo _('Max');?></th>
268 </tr>
269 </thead>
270 <tbody>
271 <?php foreach($perf_data as $ds_name => $ds): ?>
272 <tr>
273 <td><?php echo html::specialchars($ds_name); ?></td>
274 <td><?php echo isset($ds['value']) ? html::specialchars($ds['value'] . (isset($ds['unit'])?' '.$ds['unit']:'')) : ''; ?></td>
275 <td><?php echo isset($ds['warn']) ? html::specialchars($ds['warn']) : ''; ?></td>
276 <td><?php echo isset($ds['crit']) ? html::specialchars($ds['crit']) : ''; ?></td>
277 <td><?php echo isset($ds['min']) ? html::specialchars($ds['min'] . (isset($ds['unit'])?' '.$ds['unit']:'')) : ''; ?></td>
278 <td><?php echo isset($ds['max']) ? html::specialchars($ds['max'] . (isset($ds['unit'])?' '.$ds['unit']:'')) : ''; ?></td>
279 </tr>
280 <?php endforeach; ?>
281 </tbody>
282 </table>
283 <?php else:
284 echo _('No performance data');
285 endif; ?>
286 </td>
287 </tr>
288 <tr>
289 <td class="dark"><?php echo _('Current attempt'); ?></td>
290 <td id="field_current_attempt"><?php echo $object->get_current_attempt() ?>/<?php echo $object->get_max_check_attempts() ?> (<?php echo $object->get_state_type_text() ?>)</td>
291 </tr>
292 <tr>
293 <td class="dark"><?php echo _('Last check time'); ?></td>
294 <td id="field_last_check"><?php echo $object->get_last_check() ? date($date_format_str, $object->get_last_check()) : _('N/A') ?></td>
295 </tr>
296 <tr>
297 <td class="dark"><?php echo _('Check source'); ?></td>
298 <td id="field_check_source"><?php echo $object->get_source_node(); ?> (<?php echo $object->get_source_type(); ?>)</td>
299 </tr>
300 <tr>
301 <td class="dark"><?php echo _('Check type'); ?></td>
302 <td id="field_check_type">
303 <span class="<?php echo $object->get_check_type_str() ?>"><?php echo ($object->get_check_type_str() == 'active' ? $green_shield : $red_shield).' '.ucfirst($object->get_check_type_str()) ?></span>
304 </td>
305 </tr>
306 <tr>
307 <td class="dark"><?php echo _('Check latency / duration'); ?></td>
308 <td id="field_latency"><?php echo number_format($object->get_latency(), 3) ?> / <?php echo number_format($object->get_execution_time(), 3) ?> <?php echo _('seconds'); ?></td>
309 </tr>
310 <tr>
311 <td class="dark"><?php echo $service!==false?_('Next scheduled active check'):_('Next scheduled check') ?></td>
312 <td id="field_next_check"><?php echo $object->get_next_check() && $object->get_active_checks_enabled() ? date($date_format_str, $object->get_next_check()) : _('N/A') ?></td>
313 </tr>
314 <tr>
315 <td class="dark"><?php echo _('Last state change'); ?></td>
316 <td id="field_last_state_change"><?php echo $object->get_last_state_change() ? date($date_format_str, $object->get_last_state_change()) : _('N/A') ?></td>
317 </tr>
318 <tr>
319 <td class="dark"><?php echo _('Last notification'); ?></td>
320 <?php $last_notification = $object->get_last_notification()!=0 ? date(nagstat::date_format(), $object->get_last_notification()) : _('N/A'); ?>
321 <td id="field_last_notification"><?php echo $last_notification ?>&nbsp;(<?php echo _('Notifications'); ?>: <?php echo $object->get_current_notification_number() ?>)</td>
322 </tr>
323 <tr>
324 <td class="dark"><?php echo _('Is this '.$type.' flapping?') ?></td>
325 <td id="field_flap_detection_enabled">
326 <?php
327 $flap_value = $object->get_flap_detection_enabled() && $object->get_is_flapping() ? $red_shield.' '.$yes : $green_shield.' '.$no;
328 $percent_state_change_str = '('.number_format((int)$object->get_percent_state_change(), 2).'% '._('state change').')';
329 echo $flap_value.' '.$percent_state_change_str; ?>
330 </td>
331 </tr>
332 <tr>
333 <td class="dark"><?php echo _('In scheduled downtime?'); ?></td>
334 <td id="field_scheduled_downtime">
335 <?php
336 $in_downtime = $object->get_scheduled_downtime_depth();
337 $host_in_downtime = false;
338 if( $type == 'service' && $host->get_scheduled_downtime_depth() ) {
339 $in_downtime = true;
340 $host_in_downtime = true;
342 echo $in_downtime ? $red_shield.' '.$yes : $green_shield.' '.$no;
343 if( $host_in_downtime ) {
344 echo ' (' . _('host in downtime') . ')';
347 </td>
348 </tr>
349 <tr>
350 <td class="dark" style="width: 160px"><?php echo _('Active checks'); ?></td>
351 <td id="field_active_checks_enabled">
352 <span class="<?php echo $object->get_active_checks_enabled() ? _('enabled') : _('disabled'); ?>"><?php echo $object->get_active_checks_enabled() ? $enabled : $disabled; ?></span>
353 </td>
354 </tr>
355 <tr>
356 <td class="dark"><?php echo _('Passive checks'); ?></td>
357 <td id="field_accept_passive_checks">
358 <span class="<?php echo $object->get_accept_passive_checks() ? _('enabled') : _('disabled'); ?>"><?php echo $object->get_accept_passive_checks() ? $enabled : $disabled; ?></span>
359 </td>
360 </tr>
361 <tr>
362 <td class="dark"><?php echo _('Obsessing'); ?></td>
363 <td id="field_obsess">
364 <span class="<?php echo $object->get_obsess() ? _('enabled') : _('disabled'); ?>"><?php echo $object->get_obsess() ? $enabled : $disabled; ?></span>
365 </td>
366 </tr>
367 <tr>
368 <td class="dark"><?php echo _('Notifications'); ?></td>
369 <td id="field_notifications">
370 <span class="<?php echo $object->get_notifications_enabled() ? _('enabled') : _('disabled'); ?>"><?php echo $object->get_notifications_enabled() ? $enabled : $disabled; ?></span>
371 </td>
372 </tr>
373 <tr>
374 <td class="dark"><?php echo _('Event handler'); ?></td>
375 <td id="field_event_handler">
376 <span class="<?php echo $object->get_event_handler_enabled() ? _('enabled') : _('disabled'); ?>"><?php echo $object->get_event_handler_enabled() ? $enabled : $disabled; ?></span>
377 </td>
378 </tr>
379 <tr>
381 <td class="dark"><?php echo _('Flap detection') ?></td>
382 <td id="field_flap_detection">
383 <span class="<?php echo $object->get_flap_detection_enabled() ? _('enabled') : _('disabled'); ?>"><?php echo $object->get_flap_detection_enabled() ? $enabled : $disabled; ?></span>
384 </td>
385 </tr>
386 <?php if($object->get_custom_variables()) {
387 foreach($object->get_custom_variables() as $variable => $value) {
388 if (substr($variable, 0, 6) !== 'OP5H__') { ?>
389 <tr>
390 <td class="dark">_<?php echo html::specialchars($variable); ?></td>
391 <td><?php echo link::linkify(security::xss_clean($value)) ?></td>
392 </tr>
393 <?php
396 } ?>
397 </table>
398 </div>
400 <?php
401 if (!empty($commands))
402 echo $commands;
405 <div class="clear"></div>
406 <br />
408 <?php
409 if (isset($comments)) {
411 echo "<div style=\"padding: 0 8px\">";
413 $label = _("Submit a $type comment");
414 $cmd = $type == 'host' ? nagioscmd::command_id('ADD_HOST_COMMENT') : nagioscmd::command_id('ADD_SVC_COMMENT');
415 echo '<span class="icon-16 x16-add-comment" title="' . html::specialchars($label) . '"></span>';
416 echo nagioscmd::command_link($cmd, $host->get_name(), $service === false ? false : $service->get_description(), $label, 'submit', false, array('id'=>'submit_comment_button'));
418 $label = _("Delete all $type comments");
419 $cmd = $type == 'host' ? nagioscmd::command_id('DEL_ALL_HOST_COMMENTS') : nagioscmd::command_id('DEL_ALL_SVC_COMMENTS');
420 echo '<span class="icon-16 x16-delete-comment" title="' . html::specialchars($label) . '"></span>';
421 echo nagioscmd::command_link($cmd, $host->get_name(), $service === false ? false : $service->get_description(), $label, 'submit', false, array('id'=>'delete_all_comments_button'));
423 echo "</div>";
425 echo $comments;
428 if (isset($downtimes))
429 echo $downtimes;