1 <?php
defined('SYSPATH') OR die('No direct access allowed.');
3 * Helper class for alert log
5 * Copyright 2009 op5 AB
6 * op5, and the op5 logo are trademarks, servicemarks, registered servicemarks
7 * or registered trademarks of op5 AB.
8 * All other trademarks, servicemarks, registered trademarks, and registered
9 * servicemarks mentioned herein may be the property of their respective owner(s).
10 * The information contained herein is provided AS IS with NO WARRANTY OF ANY
11 * KIND, INCLUDING THE WARRANTY OF DESIGN, MERCHANTABILITY, AND FITNESS FOR A
16 * Convert all sorts of constants to user-readable strings, add html, and generally make things pretty
17 * @param $entry A database row
18 * @return An array, somewhat similar to the entry one, but with new values
20 public static function get_user_friendly_representation($entry) {
28 switch ($entry['event_type']) {
30 $ret['type'] = 'Process start';
31 $ret['state'] = "Start";
32 $ret['image'] = html
::image(ninja
::add_path('icons/16x16/'.strtolower($ret['state']).'.png'), array('alt' => _($ret['state']), 'title' => _($ret['state'])));
35 $ret['type'] = 'Process restart';
36 $ret['state'] = "Restart";
37 $ret['image'] = html
::image(ninja
::add_path('icons/16x16/'.strtolower($ret['state']).'.gif'), array('alt' => _($ret['state']), 'title' => _($ret['state'])));
40 $ret['type'] = 'Process shutdown';
41 $ret['state'] = 'Stop';
42 $ret['image'] = html
::image(ninja
::add_path('icons/16x16/'.strtolower($ret['state']).'.png'), array('alt' => _($ret['state']), 'title' => _($ret['state'])));
45 $ret['type'] = 'Service alert';
46 switch ($entry['state']) {
51 $ret['state'] = 'Warning';
54 $ret['state'] = 'Critical';
57 $ret['state'] = 'Unknown';
60 # technically, "unknown unknown, as opposed to known unknown above"
61 $ret['state'] = 'Pending';
64 $ret['image'] = html
::image(ninja
::add_path('icons/16x16/shield-'.strtolower($ret['state']).'.png'), array('alt' => _($ret['state']), 'title' => _($ret['state'])));
65 $ret['softorhard'] = $entry['hard'] ?
'Hard' : 'Soft';
68 $ret['type'] = 'Host alert';
69 switch ($entry['state']) {
74 $ret['state'] = 'Down';
77 $ret['state'] = 'Unreachable';
80 $ret['state'] = 'Pending';
83 $ret['image'] = html
::image(ninja
::add_path('icons/16x16/shield-'.strtolower($ret['state']).'.png'), array('alt' => _($ret['state']), 'title' => _($ret['state'])));
84 $ret['softorhard'] = $entry['hard'] ?
'Hard' : 'Soft';
88 if ($entry['service_description'])
89 $ret['type'] = 'Service downtime alert';
91 $ret['type'] = 'Host downtime alert';
92 $ret['softorhard'] = $entry['event_type'] == 1103 ?
'Started' : 'Stopped';
93 $ret['image'] = html
::image(ninja
::add_path('icons/16x16/scheduled-downtime.png'), array('alt' => _('Scheduled downtime'), 'title' => _('Scheduled downtime')));
96 $ret['type'] = "Unknown event #{$entry['entry_type']}";