1 <?php
defined('SYSPATH') OR die('No direct access allowed.');
5 * op5, and the op5 logo are trademarks, servicemarks, registered servicemarks
6 * or registered trademarks of op5 AB.
7 * All other trademarks, servicemarks, registered trademarks, and registered
8 * servicemarks mentioned herein may be the property of their respective owner(s).
9 * The information contained herein is provided AS IS with NO WARRANTY OF ANY
10 * KIND, INCLUDING THE WARRANTY OF DESIGN, MERCHANTABILITY, AND FITNESS FOR A
13 class Extinfo_Controller
extends Authenticated_Controller
{
14 public $current = false;
17 * Default controller method
18 * Redirects to show_process_info() which
19 * is the equivalent of calling extinfo.cgi?type=0
21 public function index()
23 return url
::redirect(Router
::$controller.'/show_process_info');
27 * @param $type string = host
28 * @param $host boolean = false
29 * @param $service boolean = false
31 public function details($type='host', $host=false, $service=false)
33 $host = $this->input
->get('host', $host);
34 $service = $this->input
->get('service', $service);
35 $hostgroup = $this->input
->get('hostgroup', false);
36 $servicegroup = $this->input
->get('servicegroup', false);
38 $this->template
->title
= 'Monitoring » Extinfo';
40 # load current status for host/service status totals
41 //$this->current = new Current_status_Model();
44 $service = trim($service);
45 $hostgroup = trim($hostgroup);
46 $servicegroup = trim($servicegroup);
48 $ls = Livestatus
::instance();
49 if(!empty($host) && empty($service)) {
50 $set = HostPool_Model
::all()->reduce_by('name', $host, '=');
52 else if(!empty($host) && !empty($service)) {
53 $set = ServicePool_Model
::all()
54 ->reduce_by('host.name', $host, '=')
55 ->reduce_by('description', $service, '=');
58 else if(!empty($hostgroup)) {
59 return $this->group_details('hostgroup', $hostgroup);
61 else if(!empty($servicegroup)) {
62 return $this->group_details('servicegroup', $servicegroup);
68 $this->template
->content
= $this->add_view('extinfo/index');
69 $this->js_strings
.= "var _pnp_web_path = '".Kohana
::config('config.pnp4nagios_path')."';\n";
70 $this->template
->js_strings
= $this->js_strings
;
71 $this->xtra_js
[] = $this->add_path('extinfo/js/extinfo.js');
74 $this->template
->content
->widgets
= array();
75 $this->xtra_js
[] = $this->add_path('/js/widgets.js');
78 $content = $this->template
->content
;
80 if (count($set) != 1) {
81 return url
::redirect('extinfo/unauthorized/'.$type);
83 $it = $set->it(false, array(), 1, 0);
84 $object = $it->current();
86 $content->object = $object;
88 $username = Auth
::instance()->get_user()->username
;
91 'query'=>$set->get_comments()->get_query(),
92 'columns'=>'all, -host_state, -host_name, -service_state, -service_description'
94 $model = new Ninja_widget_Model(array(
95 'page' => Router
::$controller,
97 'widget' => 'listview',
98 'username' => $username,
99 'friendly_name' => 'Comments',
100 'setting' => $setting
103 $widget = widget
::get($model, $this);
104 widget
::set_resources($widget, $this);
106 $widget->set_fixed($set->get_comments()->get_query());
107 $widget->extra_data_attributes
['text-if-empty'] = _("No comments yet");
109 $this->template
->content
->comments
= $widget->render();
111 if ($object->get_scheduled_downtime_depth()) {
113 'query'=>$set->get_downtimes()->get_query(),
114 'columns'=>'all, -host_state, -host_name, -service_state, -service_description'
116 $model = new Ninja_widget_Model(array(
117 'page' => Router
::$controller,
118 'name' => 'listview',
119 'widget' => 'listview',
120 'username' => $username,
121 'friendly_name' => 'Downtimes',
122 'setting' => $setting
125 $widget = widget
::get($model, $this);
126 widget
::set_resources($widget, $this);
128 $widget->set_fixed($set->get_downtimes()->get_query());
130 $this->template
->content
->downtimes
= $widget->render();
133 $this->template
->inline_js
= $this->inline_js
;
135 if (nagioscmd
::is_authorized_for(array('host_name' => $host, 'service' => $service)) === true) {
136 $this->template
->content
->commands
= $this->add_view('extinfo/commands');
137 $this->template
->content
->commands
->set
= $set;
139 $this->template
->content
->commands
= $this->add_view('extinfo/not_running');
140 $this->template
->content
->commands
->info_message
= _("You're not authorized to run commands");
143 $this->template
->toolbar
= new Toolbar_Controller();
144 $toolbar = &$this->template
->toolbar
;
150 $toolbar->title
= "Host";
152 if ( $object->get_icon_image() ) {
155 'alt' => $object->get_icon_image_alt(),
156 'title' => $object->get_icon_image_alt(),
157 'style' => 'width: 16px; vertical-align: middle; display: inline-block; margin-right: 4px'
160 $logos_path = Kohana
::config('config.logos_path');
161 $logos_path.= substr($logos_path, -1) == '/' ?
'' : '/';
162 $toolbar->subtitle
= html
::image( $logos_path.$object->get_icon_image(), $attributes ) . " " . $object->get_display_name();
166 $toolbar->subtitle
= $object->get_display_name();
170 $toolbar->info( html
::anchor( listview
::link('services',array('host.name'=>$host)) , _('Status detail') ) );
171 $toolbar->info( html
::anchor( 'alert_history/generate?include_long_output=1&report_type=hosts&objects[]='.urlencode($host) , _('Alert history') ) );
172 $toolbar->info( html
::anchor( 'showlog/showlog?hide_initial=1&hide_process=1&hide_logrotation=1&hide_commands=1&host_state_options[d]=1&host_state_options[u]=1&host_state_options[r]=1&host[]='.urlencode($host) , _('Event log') ) );
173 $toolbar->info( html
::anchor( 'histogram/generate?report_type=hosts&objects[]='.urlencode($host) , _('Alert histogram') ) );
174 $toolbar->info( html
::anchor( 'avail/generate/?report_type=hosts&objects[]='.urlencode($host) , _('Availability report') ) );
175 $toolbar->info( html
::anchor( listview
::link('notifications',array('host_name'=>$host)) , _('Notifications') ) );
180 $toolbar->title
= "Service";
181 $toolbar->subtitle
= $object->get_display_name();
183 $toolbar->info( html
::anchor( 'extinfo/details?host='.urlencode($host) , _('Information for host') ) );
184 $toolbar->info( html
::anchor( listview
::link('services',array('host.name'=>$host)) , _('Status detail for host') ) );
185 $toolbar->info( html
::anchor( 'alert_history/generate?include_long_output=1&report_type=services&objects[]='.$host.';'.urlencode($service) , _('Alert history') ) );
186 $toolbar->info( html
::anchor( 'showlog/showlog?hide_initial=1&hide_process=1&hide_logrotation=1&hide_commands=1&service_state_options[w]=1&service_state_options[u]=1&service_state_options[c]=1&service_state_options[r]=1&service[]='.urlencode($host).';'.urlencode($service), _('Event log') ) );
187 $toolbar->info( html
::anchor( 'histogram/generate?report_type=services&objects[]='.$host.';'.urlencode($service) , _('Alert histogram') ) );
188 $toolbar->info( html
::anchor( 'avail/generate/?report_type=services&objects[]='.$host.';'.urlencode($service).'&report_type=services' , _('Availability report') ) );
189 $toolbar->info( html
::anchor( listview
::link('notifications',array('host_name'=>$host, 'service_description'=>$service)) , _('Notifications') ) );
193 if (isset($page_links)) {
194 $this->template
->content
->page_links
= $page_links;
195 $this->template
->content
->label_view_for
= _("for this $type");
200 * Show Nagios process info
202 public function show_process_info()
204 if (!Auth
::instance()->authorized_for('system_information')) {
205 return url
::redirect('extinfo/unauthorized/0');
208 $this->template
->content
= $this->add_view('extinfo/process_info');
210 $this->template
->toolbar
= new Toolbar_Controller( _("Process Information") );
211 $this->template
->title
= _('Monitoring » Process info');
213 # save us some typing
214 $content = $this->template
->content
;
215 $content->info
= array();
217 # Lables to translate
222 $date_format_str = nagstat
::date_format();
223 $content->date_format_str
= $date_format_str;
225 # fetch program status from program_status_model; uses ORM
226 $status = Current_status_Model
::instance()->program_status();
227 $content->program_status
= $status;
229 $commands->label_shutdown_nagios
= sprintf(_('Shutdown the %s process'), Kohana
::config('config.product_name'));
230 $commands->label_restart_nagios
= sprintf(_('Restart the %s process'), Kohana
::config('config.product_name'));
232 $content->info
[] = array(
233 "title" => "Program version",
234 "value" => $status->program_version
,
236 nagioscmd
::command_ajax_button(nagioscmd
::command_id('SHUTDOWN_PROCESS'), $commands->label_shutdown_nagios
),
237 nagioscmd
::command_ajax_button(nagioscmd
::command_id('RESTART_PROCESS'), $commands->label_restart_nagios
)
241 $content->info
[] = array( "title" => "Program Starttime", "value" => date($date_format_str, $status->program_start
) );
242 $content->info
[] = array( "title" => "Running Time", "value" => time
::to_string(time() - $status->program_start
) );
243 $content->info
[] = array( "title" => "Last logfile rotation", "value" => $status->last_log_rotation ?
date($date_format_str, $status->last_log_rotation
) : 'never' );
244 $content->info
[] = array( "title" => "Nagios PID", "value" => $status->nagios_pid
);
246 $content->info
[] = array(
247 "title" => _("Notifications enabled?"),
248 "command" => nagioscmd
::command_ajax_button(
249 ($status->enable_notifications
) ? nagioscmd
::command_id('DISABLE_NOTIFICATIONS') : nagioscmd
::command_id('ENABLE_NOTIFICATIONS'),
250 ($status->enable_notifications
) ?
_('Disable notifications') : _('Enable notifications'),
251 false, $status->enable_notifications
255 $content->info
[] = array(
256 "title" => _("Service checks being executed?"),
257 "command" => nagioscmd
::command_ajax_button(
258 ($status->execute_service_checks
) ? nagioscmd
::command_id('STOP_EXECUTING_SVC_CHECKS') : nagioscmd
::command_id('START_EXECUTING_SVC_CHECKS'),
259 ($status->execute_service_checks
) ?
_('Stop executing service checks') : _('Start executing service checks'),
260 false, $status->execute_service_checks
264 $content->info
[] = array(
265 "title" => _("Passive service checks being accepted?"),
266 "command" => nagioscmd
::command_ajax_button(
267 ($status->accept_passive_service_checks
) ? nagioscmd
::command_id('STOP_ACCEPTING_PASSIVE_SVC_CHECKS') : nagioscmd
::command_id('START_ACCEPTING_PASSIVE_SVC_CHECKS'),
268 ($status->accept_passive_service_checks
) ?
_('Stop accepting passive service checks') : _('Start accepting passive service checks'),
269 false, $status->accept_passive_service_checks
273 $content->info
[] = array(
274 "title" => _("Host checks being executed?"),
275 "command" => nagioscmd
::command_ajax_button(
276 ($status->execute_host_checks
) ? nagioscmd
::command_id('STOP_EXECUTING_HOST_CHECKS') : nagioscmd
::command_id('START_EXECUTING_HOST_CHECKS'),
277 ($status->execute_host_checks
) ?
_('Stop executing host checks') : _('Start executing host checks'),
278 false, $status->execute_host_checks
282 $content->info
[] = array(
283 "title" => _("Passive host checks being accepted?"),
284 "command" => nagioscmd
::command_ajax_button(
285 ($status->accept_passive_host_checks
) ? nagioscmd
::command_id('STOP_ACCEPTING_PASSIVE_HOST_CHECKS') : nagioscmd
::command_id('START_ACCEPTING_PASSIVE_HOST_CHECKS'),
286 ($status->accept_passive_host_checks
) ?
_('Stop accepting passive host checks') : _('Start accepting passive host checks'),
287 false, $status->accept_passive_host_checks
291 $content->info
[] = array(
292 "title" => _("Event handlers enabled?"),
293 "command" => nagioscmd
::command_ajax_button(
294 ($status->enable_event_handlers
) ? nagioscmd
::command_id('DISABLE_EVENT_HANDLERS') : nagioscmd
::command_id('ENABLE_EVENT_HANDLERS'),
295 ($status->enable_event_handlers
) ?
_('Disable event handlers') : _('Enable event handlers'),
296 false, $status->enable_event_handlers
300 $content->info
[] = array(
301 "title" => _("Obsessing over services?"),
302 "command" => nagioscmd
::command_ajax_button(
303 ($status->obsess_over_services
) ? nagioscmd
::command_id('STOP_OBSESSING_OVER_SVC_CHECKS') : nagioscmd
::command_id('START_OBSESSING_OVER_SVC_CHECKS'),
304 ($status->obsess_over_services
) ?
_('Stop obsessing over services') : _('Start obsessing over services'),
305 false, $status->obsess_over_services
309 $content->info
[] = array(
310 "title" => _('Obsessing over hosts?'),
311 "command" => nagioscmd
::command_ajax_button(
312 ($status->obsess_over_hosts
) ? nagioscmd
::command_id('STOP_OBSESSING_OVER_HOST_CHECKS') : nagioscmd
::command_id('START_OBSESSING_OVER_HOST_CHECKS'),
313 ($status->obsess_over_hosts
) ?
_('Stop obsessing over hosts') : _('Start obsessing over hosts'),
314 false, $status->obsess_over_hosts
318 $content->info
[] = array(
319 "title" => _('Flap detection enabled?'),
320 "command" => nagioscmd
::command_ajax_button(
321 ($status->enable_flap_detection
) ? nagioscmd
::command_id('DISABLE_FLAP_DETECTION') : nagioscmd
::command_id('ENABLE_FLAP_DETECTION'),
322 ($status->enable_flap_detection
) ?
_('Disable flap detection') : _('Enable flap detection'),
323 false, $status->enable_flap_detection
327 $content->info
[] = array(
328 "title" => _('Performance data being processed?'),
329 "command" => nagioscmd
::command_ajax_button(
330 ($status->process_performance_data
) ? nagioscmd
::command_id('DISABLE_PERFORMANCE_DATA') : nagioscmd
::command_id('ENABLE_PERFORMANCE_DATA'),
331 ($status->process_performance_data
) ?
_('Disable performance data') : _('Enable performance data'),
332 false, $status->process_performance_data
339 * Display message to user when they lack proper
340 * credentials to view info on an object
342 public function unauthorized($type='host')
344 $type = trim(strtolower($type));
345 $this->template
->content
= $this->add_view('unauthorized');
346 $this->template
->disable_refresh
= true;
348 $this->template
->content
->error_description
= _('If you believe this is an error, check the authorization requirements for accessing this page and your given authorization points.');
351 $this->template
->content
->error_message
= _('It appears as though you do not have permission to view information for this host or it doesn\'t exist...');
354 $this->template
->content
->error_message
= _('It appears as though you do not have permission to view information for this hostgroup or it doesn\'t exist...');
357 $this->template
->content
->error_message
= _('It appears as though you do not have permission to view information for this servicegroup or it doesn\'t exist...');
360 $this->template
->content
->error_message
= _('It appears as though you do not have permission to view information for this service or it doesn\'t exist...');
363 $this->template
->content
->error_message
= _('It appears as though you do not have permission to view process information...');
368 * Display extinfo for host- and servicegroups
371 public function group_details($grouptype='servicegroup', $group=false)
373 $grouptype = $this->input
->get('grouptype', $grouptype);
374 $group = $this->input
->get('group', $group);
376 $this->template
->content
= $this->add_view('error');
377 $this->template
->content
->error_message
= _("Error: No group name specified");
381 $this->js_strings
.= "var _pnp_web_path = '".Kohana
::config('config.pnp4nagios_path')."';\n";
382 $this->template
->js_strings
= $this->js_strings
;
383 $this->xtra_js
[] = $this->add_path('extinfo/js/extinfo.js');
385 $this->template
->title
= _('Monitoring » Group detail');
387 $ls = Livestatus
::instance();
389 $group_info_res = $grouptype == 'servicegroup' ?
390 $ls->getServicegroups(array('filter' => array('name' => $group))) :
391 $ls->getHostgroups(array('filter' => array('name' => $group)));
393 if ($group_info_res === false ||
count($group_info_res)==0) {
394 $this->template
->content
= $this->add_view('error');
395 $this->template
->content
->error_message
= sprintf(_("The requested %s ('%s') wasn't found"), $grouptype, $group);
398 $group_info_res = (object)$group_info_res[0];
400 $this->template
->content
= $this->add_view('extinfo/groups');
401 $content = $this->template
->content
;
403 $content->label_grouptype
= $grouptype=='servicegroup' ?
_('servicegroup') : _('hostgroup');
404 $content->group_alias
= $group_info_res->alias
;
405 $content->groupname
= $group;
406 $content->grouptype
= $grouptype;
407 $content->cmd_schedule_downtime_hosts
= nagioscmd
::command_id('SCHEDULE_'.strtoupper($grouptype).'_HOST_DOWNTIME');
408 $content->cmd_schedule_downtime_services
= nagioscmd
::command_id('SCHEDULE_'.strtoupper($grouptype).'_SVC_DOWNTIME');
409 $content->cmd_enable_notifications_hosts
= nagioscmd
::command_id('ENABLE_'.strtoupper($grouptype).'_HOST_NOTIFICATIONS');
410 $content->cmd_disable_notifications_hosts
= nagioscmd
::command_id('DISABLE_'.strtoupper($grouptype).'_HOST_NOTIFICATIONS');
411 $content->cmd_disable_notifications_services
= nagioscmd
::command_id('DISABLE_'.strtoupper($grouptype).'_SVC_NOTIFICATIONS');
412 $content->cmd_enable_notifications_services
= nagioscmd
::command_id('ENABLE_'.strtoupper($grouptype).'_SVC_NOTIFICATIONS');
413 $content->cmd_disable_active_svc_checks
= nagioscmd
::command_id('DISABLE_'.strtoupper($grouptype).'_SVC_CHECKS');
414 $content->cmd_enable_active_svc_checks
= nagioscmd
::command_id('ENABLE_'.strtoupper($grouptype).'_SVC_CHECKS');
416 $content->cmd_disable_active_host_checks
= nagioscmd
::command_id('DISABLE_'.strtoupper($grouptype).'_HOST_CHECKS');
417 $content->cmd_enable_active_host_checks
= nagioscmd
::command_id('ENABLE_'.strtoupper($grouptype).'_HOST_CHECKS');
419 $content->notes_url
= $group_info_res->notes_url
!='' ? nagstat
::process_macros($group_info_res->notes_url
, $group_info_res, $grouptype) : false;
420 $content->action_url
=$group_info_res->action_url
!='' ? nagstat
::process_macros($group_info_res->action_url
, $group_info_res, $grouptype) : false;
421 $content->notes
= $group_info_res->notes
!='' ? nagstat
::process_macros($group_info_res->notes
, $group_info_res, $grouptype) : false;
423 $this->template
->toolbar
= new Toolbar_Controller( );
424 $toolbar = &$this->template
->toolbar
;
426 switch ($grouptype) {
429 $toolbar->title
= "Servicegroup";
430 $toolbar->subtitle
= security
::xss_clean( $content->group_alias
);
432 $label_view_for = _('for this servicegroup');
433 $toolbar->info( html
::anchor( 'status/service/'.$group.'?group_type='.$grouptype , _('Status detail') ) );
434 $toolbar->info( html
::anchor( 'status/'.$grouptype.'/'.$group , _('Status overview') ) );
435 $toolbar->info( html
::anchor( 'avail/generate/?report_type='.$grouptype.'s&'.$grouptype.'[]='.$group , _('Availability') ) );
436 $toolbar->info( html
::anchor( 'alert_history/generate?include_long_output=1&'.$grouptype.'[]='.$group , _('Alert history') ) );
441 $toolbar->title
= "Hostgroup";
442 $toolbar->subtitle
= security
::xss_clean( $content->group_alias
);
444 $label_view_for = _('for this hostgroup');
445 $toolbar->info( html
::anchor( 'status/service/'.$group.'?group_type='.$grouptype , _('Status detail') ) );
446 $toolbar->info( html
::anchor( 'status/'.$grouptype.'/'.$group , _('Status overview') ) );
447 $toolbar->info( html
::anchor( 'avail/generate/?report_type='.$grouptype.'s&'.$grouptype.'[]='.$group , _('Availability') ) );
448 $toolbar->info( html
::anchor( 'alert_history/generate?include_long_output=1&'.$grouptype.'[]='.$group , _('Alert history') ) );
452 if (isset($page_links)) {
453 $content->page_links
= $page_links;
454 $content->label_view_for
= $label_view_for;
460 * Show Program-Wide Performance Information
463 public function performance()
465 $this->template
->content
= $this->add_view('extinfo/performance');
466 $this->template
->title
= _('Monitoring').' » '._('Performance info');
467 $content = $this->template
->content
;
469 $this->template
->toolbar
= new Toolbar_Controller( _("Performance Information"), _("Program-wide") );
471 $content->title
= _("Program-wide performance information");
474 $program_status = Current_status_Model
::instance()->program_status();
475 $ls = Livestatus
::instance();
476 $hoststats = $ls->getHostPerformance($program_status->program_start
);
477 $servicestats = $ls->getServicePerformance($program_status->program_start
);
479 $content->program_status
= $program_status;
481 # active service checks
482 $content->svc_active_1min
= $servicestats->active_1_sum
;
483 $content->svc_active_5min
= $servicestats->active_5_sum
;
484 $content->svc_active_15min
= $servicestats->active_15_sum
;
485 $content->svc_active_1hour
= $servicestats->active_60_sum
;
486 $content->svc_active_start
= $servicestats->active_all_sum
;
487 $content->svc_active_ever
= $servicestats->active_sum
;
489 # active service checks, percentages
490 $content->svc_active_1min_perc
= $servicestats->active_sum
> 0 ?
491 number_format(($servicestats->active_1_sum
*100)/$servicestats->active_sum
, 1) : '0.0';
492 $content->svc_active_5min_perc
= $servicestats->active_sum
> 0 ?
493 number_format(($servicestats->active_5_sum
*100)/$servicestats->active_sum
, 1) : '0.0';
494 $content->svc_active_15min_perc
= $servicestats->active_sum
> 0 ?
495 number_format(($servicestats->active_15_sum
*100)/$servicestats->active_sum
, 1) : '0.0';
496 $content->svc_active_1hour_perc
= $servicestats->active_sum
> 0 ?
497 number_format(($servicestats->active_60_sum
*100)/$servicestats->active_sum
, 1) : '0.0';
498 $content->svc_active_start_perc
= $servicestats->active_sum
> 0 ?
499 number_format(($servicestats->active_all_sum
*100)/$servicestats->active_sum
, 1) : '0.0';
501 # passive service checks
502 $content->svc_passive_1min
= $servicestats->passive_1_sum
;
503 $content->svc_passive_5min
= $servicestats->passive_5_sum
;
504 $content->svc_passive_15min
= $servicestats->passive_15_sum
;
505 $content->svc_passive_1hour
= $servicestats->passive_60_sum
;
506 $content->svc_passive_start
= $servicestats->passive_all_sum
;
507 $content->svc_passive_ever
= $servicestats->passive_sum
;
509 # passive service checks, percentages
510 $content->svc_passive_1min_perc
= $servicestats->passive_sum
> 0 ?
511 number_format(($servicestats->passive_1_sum
*100)/$servicestats->passive_sum
, 1) : '0.0';
512 $content->svc_passive_5min_perc
= $servicestats->passive_sum
> 0 ?
513 number_format(($servicestats->passive_5_sum
*100)/$servicestats->passive_sum
, 1) : '0.0';
514 $content->svc_passive_15min_perc
= $servicestats->passive_sum
> 0 ?
515 number_format(($servicestats->passive_15_sum
*100)/$servicestats->passive_sum
, 1) : '0.0';
516 $content->svc_passive_1hour_perc
= $servicestats->passive_sum
> 0 ?
517 number_format(($servicestats->passive_60_sum
*100)/$servicestats->passive_sum
, 1) : '0.0';
518 $content->svc_passive_start_perc
= $servicestats->passive_sum
> 0 ?
519 number_format(($servicestats->passive_all_sum
*100)/$servicestats->passive_sum
, 1) : '0.0';
521 # service execution time
522 $content->min_service_execution_time
= number_format($servicestats->execution_time_min
, 2);
523 $content->max_service_execution_time
= number_format($servicestats->execution_time_max
, 2);
524 $content->svc_average_execution_time
= number_format($servicestats->execution_time_avg
, 3);
527 $content->min_service_latency
= number_format($servicestats->latency_min
, 2);
528 $content->max_service_latency
= number_format($servicestats->latency_max
, 2);
529 $content->average_service_latency
= number_format($servicestats->latency_avg
, 3);
531 # service state change - active
532 $content->min_service_percent_change_a
= number_format($servicestats->active_state_change_min
, 2);
533 $content->max_service_percent_change_a
= number_format($servicestats->active_state_change_max
, 2);
534 $content->average_service_percent_change
= number_format($servicestats->active_state_change_avg
, 3);
536 # service state change - passive
537 $content->min_service_percent_change_b
= number_format($servicestats->passive_state_change_min
, 2);
538 $content->max_service_percent_change_b
= number_format($servicestats->passive_state_change_max
, 2);
539 $content->average_service_percent_change
= number_format($servicestats->passive_state_change_avg
, 3);
542 $content->hst_active_1min
= $hoststats->active_1_sum
;
543 $content->hst_active_5min
= $hoststats->active_5_sum
;
544 $content->hst_active_15min
= $hoststats->active_15_sum
;
545 $content->hst_active_1hour
= $hoststats->active_60_sum
;
546 $content->hst_active_start
= $hoststats->active_all_sum
;
547 $content->hst_active_ever
= $hoststats->active_sum
;
549 # active host checks, percentages
550 $content->hst_active_1min_perc
= $hoststats->active_sum
> 0 ?
551 number_format(($hoststats->active_1_sum
*100)/$hoststats->active_sum
, 1) : '0.0';
552 $content->hst_active_5min_perc
= $hoststats->active_sum
> 0 ?
553 number_format(($hoststats->active_5_sum
*100)/$hoststats->active_sum
, 1) : '0.0';
554 $content->hst_active_15min_perc
= $hoststats->active_sum
> 0 ?
555 number_format(($hoststats->active_15_sum
*100)/$hoststats->active_sum
, 1) : '0.0';
556 $content->hst_active_1hour_perc
= $hoststats->active_sum
> 0 ?
557 number_format(($hoststats->active_60_sum
*100)/$hoststats->active_sum
, 1) : '0.0';
558 $content->hst_active_start_perc
= $hoststats->active_sum
> 0 ?
559 number_format(($hoststats->active_all_sum
*100)/$hoststats->active_sum
, 1) : '0.0';
561 # passive host checks
562 $content->hst_passive_1min
= $hoststats->passive_1_sum
;
563 $content->hst_passive_5min
= $hoststats->passive_5_sum
;
564 $content->hst_passive_15min
= $hoststats->passive_15_sum
;
565 $content->hst_passive_1hour
= $hoststats->passive_60_sum
;
566 $content->hst_passive_start
= $hoststats->passive_all_sum
;
567 $content->hst_passive_ever
= $hoststats->passive_sum
;
569 # passive host checks, percentages
570 $content->hst_passive_1min_perc
= $hoststats->passive_sum
> 0 ?
571 number_format(($hoststats->passive_1_sum
*100)/$hoststats->passive_sum
, 1) : '0.0';
572 $content->hst_passive_5min_perc
= $hoststats->passive_sum
> 0 ?
573 number_format(($hoststats->passive_5_sum
*100)/$hoststats->passive_sum
, 1) : '0.0';
574 $content->hst_passive_15min_perc
= $hoststats->passive_sum
> 0 ?
575 number_format(($hoststats->passive_15_sum
*100)/$hoststats->passive_sum
, 1) : '0.0';
576 $content->hst_passive_1hour_perc
= $hoststats->passive_sum
> 0 ?
577 number_format(($hoststats->passive_60_sum
*100)/$hoststats->passive_sum
, 1) : '0.0';
578 $content->hst_passive_start_perc
= $hoststats->passive_sum
> 0 ?
579 number_format(($hoststats->passive_all_sum
*100)/$hoststats->passive_sum
, 1) : '0.0';
581 # host execution time
582 $content->min_host_execution_time
= number_format($hoststats->execution_time_min
, 2);
583 $content->max_host_execution_time
= number_format($hoststats->execution_time_max
, 2);
584 $content->average_host_execution_time
= number_format($hoststats->execution_time_avg
, 3);
587 $content->min_host_latency
= number_format($hoststats->latency_min
, 2);
588 $content->max_host_latency
= number_format($hoststats->latency_max
, 2);
589 $content->average_host_latency
= number_format($hoststats->latency_avg
, 3);
591 # host state change - active
592 $content->min_host_percent_change_a
= number_format($hoststats->active_state_change_min
, 2);
593 $content->max_host_percent_change_a
= number_format($hoststats->active_state_change_max
, 2);
594 $content->average_host_percent_change
= number_format($hoststats->active_state_change_avg
, 3);
596 # host state change - passive
597 $content->min_host_percent_change_b
= number_format($hoststats->passive_state_change_min
, 2);
598 $content->max_host_percent_change_b
= number_format($hoststats->passive_state_change_max
, 2);
599 $content->average_host_percent_change
= number_format($hoststats->passive_state_change_avg
, 3);
603 * Show scheduling queue
605 public function scheduling_queue()
607 $back_link = '/extinfo/scheduling_queue/';
609 $host = $this->input
->get('host');
610 $service = $this->input
->get('service');
611 $sq_model = new Scheduling_queue_Model();
613 $items_per_page = $this->input
->get('items_per_page', config
::get('pagination.default.items_per_page', '*'));
614 $pagination = new CountlessPagination(array('items_per_page' => $items_per_page));
616 $sq_model->set_range(
617 $pagination->items_per_page
,
618 ($pagination->current_page
-1)*$pagination->items_per_page
621 if (!Auth
::instance()->authorized_for('host_view_all')) {
622 return url
::redirect('extinfo/unauthorized/scheduling_queue');
625 $this->xtra_js
[] = $this->add_path('extinfo/js/extinfo.js');
626 $this->xtra_js
[] = 'application/media/js/jquery.tablesorter.min.js';
627 $this->js_strings
.= "var _filter_label = '"._('Enter text to filter')."';";
628 $this->template
->js_strings
= $this->js_strings
;
630 $this->session
->set('back_extinfo',$back_link);
632 $this->template
->title
= _('Monitoring').' » '._('Scheduling queue');
633 $this->template
->content
= $this->add_view('extinfo/scheduling_queue');
634 $this->template
->content
->data
= $sq_model->show_scheduling_queue($service, $host);
636 if(!$this->template
->content
->data ||
count($this->template
->content
->data
) < $items_per_page) {
637 $pagination->hide_next
= true;
640 $this->template
->content
->host_search
= $host;
641 $this->template
->content
->service_search
= $service;
642 $this->template
->content
->header_links
= array(
643 'host_name' => _('Host'),
644 'description' => _('Service'),
645 'last_check' => _('Last check'),
646 'next_check' => _('Next check')
649 $this->template
->content
->date_format_str
= nagstat
::date_format();
650 $this->template
->toolbar
= new Toolbar_Controller( "Scheduling Queue" );
652 $form = '<form action="scheduling_queue" method="get">';
653 $form .= _('Search for');
654 $form .= '<label> ' . _('Host') . ': <input name="host" value="' . $host . '" /></label>';
655 $form .= '<label> ' . _('Service') . ': <input name="service" value="' . $service . '" /></label>';
656 $form .= '<input type="submit" value="' . _('Search') . '" /></form>';
658 $this->template
->toolbar
->info( $form );
659 if ( isset( $pagination ) ) {
660 $this->template
->toolbar
->info( $pagination );
663 if ( $host ||
$service ) {
664 $this->template
->toolbar
->info( ' <span>' .
665 ' ' . _("Do you want to") .
666 ' <a href="'. Kohana
::config('config.site_domain') . 'index.php/' . Router
::$controller . '/' . Router
::$method . '">' .
667 _("reset the search filter?") . '</a></span>'