1 <?php
defined('SYSPATH') OR die('No direct access allowed.');
4 * Requires authentication
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
14 class Config_Controller
extends Authenticated_Controller
{
15 public $current = false;
16 public $type = 'hosts';
17 const SERVICE_NOTIFICATION_COMMANDS
= 'service_notification_commands';
18 const HOST_NOTIFICATION_COMMANDS
= 'host_notification_commands';
21 * Default controller method
22 * Redirects to show_process_info() which
23 * is the equivalent of calling extinfo.cgi?type=0
25 public function index()
27 if (!Auth
::instance()->authorized_for('system_information')) {
28 return url
::redirect('extinfo/unauthorized/0');
31 $this->type
= isset($_GET['type']) ?
$_GET['type'] : $this->type
;
32 $items_per_page = $this->input
->get('items_per_page', config
::get('pagination.default.items_per_page', '*'));
33 $pagination = new CountlessPagination(array('items_per_page' => $items_per_page));
35 $filter = $this->input
->get('filterbox', null);
36 if($filter && $filter == _('Enter text to filter')) {
39 $poolname = ucfirst(substr($this->type
,0,-1)).'Pool_Model';
40 if (class_exists($poolname)) {
41 $set = $poolname::all();
42 $set->reduce_by("name", $filter, "~~");
43 $data = $set->it(false, array(), $pagination->items_per_page
, ($pagination->current_page
-1)*$pagination->items_per_page
);
46 switch ($this->type
) {
47 case 'hosts': // *****************************************************************************
50 _('Alias/Description'),
54 _('Max. Check Attempts'),
57 _('Host Check Command'),
60 _('Enable Active Checks'),
61 _('Enable Passive Checks'),
63 //_('Freshness Threshold'),
64 _('Default Contact Groups'),
65 _('Notification Interval'),
66 _('First Notification Delay'),
67 //_('Notification Options'),
68 _('Notification Period'),
70 _('Enable Event Handler'),
71 //_('Stalking Options'),
72 _('Enable Flap Detection'),
73 _('Low Flap Threshold'),
74 _('High Flap Threshold'),
75 _('Process Performance Data'),
76 //_('Enable Failure Prediction'),
77 //_('Failure Prediction Options'),
83 //_('Retention Options')
86 foreach($data as $row) {
88 $result[$i][]= '<a name="'.$row->get_name().'"></a>'.$row->get_name();
89 $result[$i][]= $row->get_alias();
90 $result[$i][]= $row->get_display_name();
91 $result[$i][]= $row->get_address();
93 foreach ($row->get_parents() as $parent) {
94 $tmp[] = html
::anchor(Router
::$controller.'/?type=hosts#'.$parent, $parent);
96 $result[$i][] = implode(', ',$tmp);
97 $result[$i][]= $row->get_max_check_attempts();
98 $result[$i][]= time
::to_string($row->get_check_interval()*60);
99 $result[$i][]= time
::to_string($row->get_retry_interval()*60);
100 $result[$i][]= html
::anchor(Router
::$controller.'/?type=commands#'.$row->get_check_command(), $row->get_check_command());
101 $result[$i][]= html
::anchor(Router
::$controller.'/?type=timeperiods#'.$row->get_check_period(), $row->get_check_period());
102 $result[$i][]= $row->get_obsess() == 1 ?
_('Yes') : _('No');
103 $result[$i][]= $row->get_active_checks_enabled() == 1 ?
_('Yes') : _('No');
104 $result[$i][]= $row->get_accept_passive_checks() == 1 ?
_('Yes') : _('No');
105 $result[$i][]= $row->get_check_freshness() == 1 ?
_('Yes') : _('No');
106 //$result[$i][]= $row->get_freshness_threshold() == 0 ? _('Auto-determined value') : $row->get_freshness_threshold().' '._('seconds');
108 foreach($row->get_contact_groups() as $cg){
109 $c_link[] = html
::anchor(Router
::$controller.'/?type=contactgroups#'.$cg, $cg);
111 foreach($row->get_contacts() as $c){
112 $c_link[] = html
::anchor(Router
::$controller.'/?type=contacts#'.$c, $c);
114 $result[$i][] = implode(', ', $c_link);
116 $result[$i][]= $row->get_notification_interval() == 0 ?
_('No Re-notification') : $row->get_notification_interval();
117 $result[$i][]= time
::to_string($row->get_first_notification_delay());
118 //$note_options = explode(',',$row->get_notification_options());
120 //foreach($note_options as $option) {
121 //$tmp[] = $options['host']['notification'][$option];
123 //$result[$i][]= implode(', ',$tmp);
124 $result[$i][]= html
::anchor(Router
::$controller.'/?type=timeperiods#'.$row->get_notification_period(), $row->get_notification_period());
125 $result[$i][]= $row->get_event_handler() == 0 ?
' ' : $row->get_event_handler();
126 $result[$i][]= $row->get_event_handler_enabled() == 1 ?
_('Yes') : _('No');
127 //$result[$i][]= $row->get_stalking_options() == 'n' ? _('None') : _('??');
128 $result[$i][]= $row->get_flap_detection_enabled() == 1 ?
_('Yes') : _('No');
129 $result[$i][]= $row->get_low_flap_threshold() == 0.0 ?
_('Program-wide value') : $row->get_low_flap_threshold();
130 $result[$i][]= $row->get_high_flap_threshold() == 0.0 ?
_('Program-wide value') : $row->get_high_flap_threshold();
131 $result[$i][]= $row->get_process_performance_data() == 1 ?
_('Yes') : _('No');
132 //$result[$i][]= $row->get_failure_prediction_enabled() == 1 ? _('Yes') : _('No');
133 //$result[$i][]= !isset($row->get_failure_prediction_options()) ? ' ' : $row->get_failure_prediction_options(); // ?
134 $result[$i][]= $row->get_notes();
135 $result[$i][]= $row->get_notes_url();
136 $result[$i][]= $row->get_action_url();
137 $result[$i][]= $row->get_icon_image();
138 $result[$i][]= $row->get_icon_image_alt();
141 //if ($row->get_retain_status_information() == true) {
142 //$ret[] = _('Status Information');
144 //if ($row->get_retain_nonstatus_information() == true) {
145 //$ret[] = _('Non-status Information');
147 //$result[$i][] = is_array($ret) ? implode(', ',$ret) : 'None';
152 case 'services': // **************************************************************************
155 _('Service Description'),
156 _('Max. Check Attempts'),
157 _('Normal Check Interval'),
158 _('Retry Check Interval'),
164 _('Enable Active Checks'),
165 _('Enable Passive Checks'),
166 _('Check Freshness'),
167 //_('Freshness Threshold'),
168 _('Default Contact Groups'),
169 _('Enable Notifications'),
170 _('Notification Interval'),
171 _('First Notification Delay'),
172 //_('Notification Options'),
173 _('Notification Period'),
175 _('Enable Event Handler'),
176 //_('Stalking Options'),
177 _('Enable Flap Detection'),
178 _('Low Flap Threshold'),
179 _('High Flap Threshold'),
180 _('Process Performance Data'),
181 //_('Enable Failure Prediction'),
182 //_('Failure Prediction Options'),
188 //_('Retention Options'),
191 foreach($data as $row) {
192 $row = (object) $row;
193 //$note_options = explode(',',$row->get_notification_options());
195 $result[$i][]= '<a name="'.$row->get_host()->get_name().'"></a>'.$row->get_host()->get_name();
196 $result[$i][]= '<a name="'.$row->get_description().'"></a>'.$row->get_description();
197 $result[$i][]= $row->get_max_check_attempts();
198 $result[$i][]= time
::to_string($row->get_check_interval()*60);
199 $result[$i][]= time
::to_string($row->get_retry_interval()*60);
200 $result[$i][]= $row->get_check_command();
201 $result[$i][]= html
::anchor(Router
::$controller.'/?type=timeperiods#'.$row->get_check_period(), $row->get_check_period());
202 //$result[$i][]= $row->get_parallelize_check() == 1 ? _('Yes') : _('No');
203 //$result[$i][]= $row->get_is_volatile() == 1 ? _('Yes') : _('No');
204 $result[$i][]= $row->get_obsess() == 1 ?
_('Yes') : _('No');
205 $result[$i][]= $row->get_active_checks_enabled() == 1 ?
_('Yes') : _('No');
206 $result[$i][]= $row->get_accept_passive_checks() == 1 ?
_('Yes') : _('No');
207 $result[$i][]= $row->get_check_freshness() == 1 ?
_('Yes') : _('No');
208 //$result[$i][]= $row->get_freshness_threshold() == 0 ? _('Auto-determined value') : $row->get_freshness_threshold().' '._('seconds');
211 foreach($row->get_contact_groups() as $cg){
212 $c_link[] = html
::anchor(Router
::$controller.'/?type=contactgroups#'.$cg, $cg);
214 foreach($row->get_contacts() as $c){
215 $c_link[] = html
::anchor(Router
::$controller.'/?type=contacts#'.$c, $c);
217 $result[$i][] = implode(', ', $c_link);
219 $result[$i][]= $row->get_notifications_enabled() == 1 ?
_('Yes') : _('No');
220 $result[$i][]= $row->get_notification_interval() == 0 ?
_('No Re-notification') : $row->get_notification_interval();
221 $result[$i][]= time
::to_string($row->get_first_notification_delay());
222 //$notification_options = explode(',',$row->get_notification_options());
224 //foreach($notification_options as $option) {
225 //$tmp[] = $options['service']['notification'][$option];
227 //$result[$i][]= is_array($tmp) ? implode(', ',$tmp) : '';
228 $result[$i][]= html
::anchor(Router
::$controller.'/?type=timeperiods#'.$row->get_notification_period(), $row->get_notification_period());
229 $result[$i][]= $row->get_event_handler() == 0 ?
' ' : $row->get_event_handler();
230 $result[$i][]= $row->get_event_handler_enabled() == 1 ?
_('Yes') : _('No');
231 //$result[$i][]= $row->get_stalking_options() == 'n' ? _('None') : _('??');
232 $result[$i][]= $row->get_flap_detection_enabled() == 1 ?
_('Yes') : _('No');
233 $result[$i][]= $row->get_low_flap_threshold() == 0.0 ?
_('Program-wide value') : $row->get_low_flap_threshold();
234 $result[$i][]= $row->get_high_flap_threshold() == 0.0 ?
_('Program-wide value') : $row->get_high_flap_threshold();
235 $result[$i][]= $row->get_process_performance_data() == 1 ?
_('Yes') : _('No');
236 //$result[$i][]= $row->get_failure_prediction_enabled() == 1 ? _('Yes') : _('No');
237 //$result[$i][]= !isset($row->get_failure_prediction_options()) ? ' ' : $row->get_failure_prediction_options(); // ?
238 $result[$i][]= $row->get_notes();
239 $result[$i][]= $row->get_notes_url();
240 $result[$i][]= $row->get_action_url();
241 $result[$i][]= $row->get_icon_image();
242 $result[$i][]= $row->get_icon_image_alt();
245 //if ($row->get_retain_status_information() == true) {
246 //$ret[] = _('Status Information');
248 //if ($row->get_retain_nonstatus_information() == true) {
249 //$ret[] = _('Non-status Information');
251 //$result[$i][] = is_array($ret) ? implode(', ',$ret) : 'None';
256 case 'contacts': // **************************************************************************
261 _('Pager Address/Number'),
262 //_('Service Notification Options'),
263 //_('Host Notification Options'),
264 _('Service Notification Period'),
265 _('Host Notification Period'),
266 //_('Service Notification Commands'),
267 //_('Host Notification Commands'),
268 //_('Retention Options'),
271 foreach($data as $row) {
272 $row = (object) $row;
273 $result[$i][]= '<a name="'.$row->get_name().'"></a>'.$row->get_name();
274 $result[$i][]= $row->get_alias();
275 $result[$i][]= '<a href="mailto:'.$row->get_email().'">'.$row->get_email().'</a>';
276 $result[$i][]= $row->get_pager();
278 //$s_notification_options = explode(',',$row->get_service_notification_options());
280 //foreach($s_notification_options as $s_option) {
281 //$s_tmp[] = $options['service']['notification'][$s_option];
283 //$result[$i][]= implode(', ',$s_tmp);
285 //$h_notification_options = explode(',',$row->get_host_notification_options());
287 //foreach($h_notification_options as $h_option) {
288 //$h_tmp[] = $options['host']['notification'][$h_option];
290 //$result[$i][]= implode(', ',$h_tmp);
292 $result[$i][]= html
::anchor(Router
::$controller.'/?type=timeperiods#'.($row->get_host_notification_period() == 0 ?
_('None') : $row->get_host_notification_period()), $row->get_service_notification_period() == 0 ?
_('None') : $row->get_service_notification_period());
293 $result[$i][]= html
::anchor(Router
::$controller.'/?type=timeperiods#'.($row->get_host_notification_period() == 0 ?
_('None') : $row->get_host_notification_period()), $row->get_host_notification_period() == 0 ?
_('None') : $row->get_host_notification_period());
294 //$result[$i][]= html::anchor(Router::$controller.'/?type=commands#'.$row->{self::SERVICE_NOTIFICATION_COMMANDS}, $row->{self::SERVICE_NOTIFICATION_COMMANDS});
295 //$result[$i][]= html::anchor(Router::$controller.'/?type=commands#'.$row->{self::HOST_NOTIFICATION_COMMANDS}, $row->{self::HOST_NOTIFICATION_COMMANDS});
298 //if ($row->get_retain_status_information() == true) {
299 //$ret[] = _('Status Information');
301 //if ($row->get_retain_nonstatus_information() == true) {
302 //$ret[] = _('Non-status Information');
304 //$result[$i][] = is_array($ret) ? implode(', ',$ret) : 'None';
309 case 'contactgroups': // ********************************************************************
313 _('Contact Members'),
316 foreach($data as $row) {
317 $row = (object) $row;
319 $result[$i][]= '<a name="'.$row->get_name().'"></a>'.$row->get_name();
320 $result[$i][]= $row->get_alias();
323 foreach ($row->get_members() as $trip) {
324 $temp[] = html
::anchor(Router
::$controller.'/?type=contacts#'.$trip, $trip);
327 $result[$i][]= implode(', ',$temp);
335 case 'timeperiods': // ***********************************************************************
338 _('Alias/Description'),
342 foreach($data as $row) {
343 $result[$i][] = $row->get_name();
344 $result[$i][] = $row->get_alias();
345 $result[$i][] = $row->get_in() ?
_('Yes') : _('No');
350 case 'commands': // **************************************************************************
356 foreach($data as $row) {
357 $result[$i][] = $row->get_name();
358 $result[$i][] = $row->get_line();
363 case 'hostgroups': // ***********************************************************************
373 foreach($data as $row) {
374 $row = (object) $row;
375 $result[$i][]= '<a name="'.$row->get_name().'"></a>'.$row->get_name();
376 $result[$i][]= $row->get_alias();
379 foreach ($row->get_members() as $trip) {
380 $temp[] = html
::anchor(Router
::$controller.'/?type=hosts#'.$trip, $trip);
382 $result[$i][]= implode(', ',$temp);
384 $result[$i][]= $row->get_notes();
385 $result[$i][]= $row->get_notes_url();
386 $result[$i][]= $row->get_action_url();
392 case 'servicegroups': // ********************************************************************
396 _('Service Members'),
402 foreach($data as $row) {
403 $row = (object) $row;
404 $result[$i][]= '<a name="'.$row->get_name().'"></a>'.$row->get_name();
405 $result[$i][]= $row->get_alias();
408 foreach ($row->get_members() as $host_service) {
409 $temp[] = html
::anchor(Router
::$controller.'/?type=hosts#'.$host_service[0], $host_service[0]).' / '.html
::anchor(Router
::$controller.'/?type=services#'.$host_service[1], $host_service[1]);
412 $result[$i][]= implode(', ',$temp);
417 $result[$i][]= $row->get_notes();
418 $result[$i][]= $row->get_notes_url();
419 $result[$i][]= $row->get_action_url();
429 $this->template
->title
= _('Configuration').' ยป '._('View config');
430 $this->template
->content
= $this->add_view('config/index');
432 $this->xtra_js
[] = 'application/media/js/jquery.tablesorter.min.js';
433 $this->template
->js_header
= $this->add_view('js_header');
434 $this->js_strings
.= "var _filter_label = '"._('Enter text to filter')."';";
435 $this->template
->js_strings
= $this->js_strings
;
436 $this->template
->js_header
->js
= $this->xtra_js
;
437 $this->template
->content
->header
= $header;
438 $this->template
->content
->data
= $result;
439 if(!$result ||
count($result) < $pagination->items_per_page
) {
440 $pagination->hide_next
= true;
442 $this->template
->content
->pagination
= $pagination;
443 $this->template
->content
->filter_string
= $this->input
->get('filterbox', _('Enter text to filter'));
444 $this->template
->content
->type
= $this->type
;
447 public function unauthorized()
449 $this->template
->content
= $this->add_view('extinfo/unauthorized');
450 $this->template
->disable_refresh
= true;
452 $this->template
->content
->error_description
= _('If you believe this is an error, check the HTTP server authentication requirements for accessing this page and check the authorization options in your CGI configuration file.');