diff --git a/modules/monitoring/application/controllers/ShowController.php b/modules/monitoring/application/controllers/ShowController.php index 66e7e103d..f13761832 100644 --- a/modules/monitoring/application/controllers/ShowController.php +++ b/modules/monitoring/application/controllers/ShowController.php @@ -1,14 +1,27 @@ _getParam('host'); @@ -26,7 +39,7 @@ class Monitoring_ShowController extends ModuleActionController $this->view->service = $this->backend->fetchService($host, $service); } if ($host !== null) { - $this->view->host = $this->backend->fetchHost($host); + $this->view->host = $this->backend->fetchHost($host, true); } $this->view->compact = $this->_getParam('view') === 'compact'; $this->view->tabs = $this->createTabs(); @@ -44,7 +57,8 @@ class Monitoring_ShowController extends ModuleActionController $this->view->ticket_link = preg_replace( '~__ID__~', '\$1', - $this->view->qlink('#__ID__', + $this->view->qlink( + '#__ID__', 'monitoring/show/ticket', $params ) @@ -54,17 +68,21 @@ class Monitoring_ShowController extends ModuleActionController } } + /** + * Service overview + */ public function serviceAction() { Benchmark::measure('Entered service action'); $this->view->active = 'service'; $this->view->tabs->activate('service')->enableSpecialActions(); - + if ($grapher = Hook::get('grapher')) { if ($grapher->hasGraph( $this->view->host->host_name, $this->view->service->service_description - )) { + ) + ) { $this->view->preview_image = $grapher->getPreviewImage( $this->view->host->host_name, $this->view->service->service_description @@ -73,41 +91,53 @@ class Monitoring_ShowController extends ModuleActionController } $this->view->contacts = $this->backend->select() - ->from('contact', array( - 'contact_name', - 'contact_alias', - 'contact_email', - 'contact_pager', - )) + ->from( + 'contact', + array( + 'contact_name', + 'contact_alias', + 'contact_email', + 'contact_pager', + ) + ) ->where('service_host_name', $this->view->host->host_name) ->where('service_description', $this->view->service->service_description) ->fetchAll(); $this->view->contactgroups = $this->backend->select() - ->from('contactgroup', array( - 'contactgroup_name', - 'contactgroup_alias', - )) + ->from( + 'contactgroup', + array( + 'contactgroup_name', + 'contactgroup_alias', + ) + ) ->where('service_host_name', $this->view->host->host_name) ->where('service_description', $this->view->service->service_description) ->fetchAll(); $this->view->comments = $this->backend->select() - ->from('comment', array( - 'comment_timestamp', - 'comment_author', - 'comment_data', - 'comment_type', - )) + ->from( + 'comment', + array( + 'comment_timestamp', + 'comment_author', + 'comment_data', + 'comment_type', + ) + ) ->where('service_host_name', $this->view->host->host_name) ->where('service_description', $this->view->service->service_description) ->fetchAll(); $this->view->customvars = $this->backend->select() - ->from('customvar', array( - 'varname', - 'varvalue' - )) + ->from( + 'customvar', + array( + 'varname', + 'varvalue' + ) + ) ->where('varname', '-*PW*,-*PASS*') ->where('host_name', $this->view->host->host_name) ->where('service_description', $this->view->service->service_description) @@ -116,11 +146,14 @@ class Monitoring_ShowController extends ModuleActionController Benchmark::measure('Service action done'); } + /** + * Host overview + */ public function hostAction() { $this->view->active = 'host'; $this->view->tabs->activate('host')->enableSpecialActions(); - + if ($grapher = Hook::get('grapher')) { if ($grapher->hasGraph($this->view->host->host_name)) { $this->view->preview_image = $grapher->getPreviewImage( @@ -130,90 +163,122 @@ class Monitoring_ShowController extends ModuleActionController } $this->view->hostgroups = $this->backend->select() - ->from('hostgroup', array( - 'hostgroup_name', - 'hostgroup_alias' - )) + ->from( + 'hostgroup', + array( + 'hostgroup_name', + 'hostgroup_alias' + ) + ) ->where('host_name', $this->view->host->host_name) ->fetchPairs(); $this->view->contacts = $this->backend->select() - ->from('contact', array( - 'contact_name', - 'contact_alias', - 'contact_email', - 'contact_pager', - )) + ->from( + 'contact', + array( + 'contact_name', + 'contact_alias', + 'contact_email', + 'contact_pager', + ) + ) ->where('host_name', $this->view->host->host_name) ->fetchAll(); $this->view->contactgroups = $this->backend->select() - ->from('contactgroup', array( - 'contactgroup_name', - 'contactgroup_alias', - )) + ->from( + 'contactgroup', + array( + 'contactgroup_name', + 'contactgroup_alias', + ) + ) ->where('host_name', $this->view->host->host_name) ->fetchAll(); $this->view->comments = $this->backend->select() - ->from('comment', array( - 'comment_timestamp', - 'comment_author', - 'comment_data', - 'comment_type', - )) + ->from( + 'comment', + array( + 'comment_timestamp', + 'comment_author', + 'comment_data', + 'comment_type', + ) + ) ->where('host_name', $this->view->host->host_name) ->fetchAll(); $this->view->customvars = $this->backend->select() - ->from('customvar', array( - 'varname', - 'varvalue' - )) + ->from( + 'customvar', + array( + 'varname', + 'varvalue' + ) + ) ->where('varname', '-*PW*,-*PASS*') ->where('host_name', $this->view->host->host_name) ->where('object_type', 'host') ->fetchPairs(); } + /** + * History entries for objects + */ public function historyAction() { if ($this->view->host) { $this->view->tabs->activate('history')->enableSpecialActions(); } $this->view->history = $this->backend->select() - ->from('eventHistory', array( - 'object_type', - 'host_name', - 'service_description', - 'timestamp', - 'state', - 'attempt', - 'max_attempts', - 'output', - 'type' - ))->applyRequest($this->_request); + ->from( + 'eventHistory', + array( + 'object_type', + 'host_name', + 'service_description', + 'timestamp', + 'state', + 'attempt', + 'max_attempts', + 'output', + 'type' + ) + )->applyRequest($this->_request); - $this->view->preserve = $this->view->history->getAppliedFilter()->toParams(); - if ($this->_getParam('dump') === 'sql') { - echo '
' . htmlspecialchars($this->view->history->getQuery()->dump()) . '
'; - exit; - } + $this->view->preserve = $this->view->history->getAppliedFilter()->toParams(); + if ($this->_getParam('dump') === 'sql') { + echo '
' . htmlspecialchars($this->view->history->getQuery()->dump()) . '
'; + exit; + } if ($this->_getParam('sort')) { $this->view->preserve['sort'] = $this->_getParam('sort'); } } + /** + * Service overview + */ public function servicesAction() { // Ugly and slow: - $this->view->services = $this->view->action('services', 'list', 'monitoring', array( - 'host_name' => $this->view->host->host_name, - //'sort', 'service_description' - )); + $this->view->services = $this->view->action( + 'services', + 'list', + 'monitoring', + array( + 'host_name' => $this->view->host->host_name, + //'sort', 'service_description' + ) + ); } + /** + * Ticets actions + */ public function ticketAction() { $this->view->tabs->activate('ticket')->enableSpecialActions(); @@ -222,16 +287,25 @@ class Monitoring_ShowController extends ModuleActionController if (Hook::has('ticket')) { $ticketModule = 'rt'; $this->render(); - $this->_forward('ticket', 'show', $ticketModule, array( - 'id' => $id - )); + $this->_forward( + 'ticket', + 'show', + $ticketModule, + array( + 'id' => $id + ) + ); } } + /** + * Creating tabs for this controller + * @return \Icinga\Web\Widget\AbstractWidget + */ protected function createTabs() { $tabs = $this->widget('tabs'); - if ( ! $this->view->host) { + if (!$this->view->host) { return $tabs; } $params = array( @@ -246,48 +320,63 @@ class Monitoring_ShowController extends ModuleActionController } else { $hostParams = $params; } - $tabs->add('host', array( - 'title' => 'Host', - 'icon' => 'img/classic/server.png', - 'url' => 'monitoring/show/host', - 'urlParams' => $hostParams, - )); - $tabs->add('services', array( - 'title' => 'Services', - 'icon' => 'img/classic/service.png', - 'url' => 'monitoring/show/services', - 'urlParams' => $params, - )); - if (isset($params['service'])) { - $tabs->add('service', array( - 'title' => 'Service', - 'icon' => 'img/classic/service.png', - 'url' => 'monitoring/show/service', + $tabs->add( + 'host', + array( + 'title' => 'Host', + 'icon' => 'img/classic/server.png', + 'url' => 'monitoring/show/host', + 'urlParams' => $hostParams, + ) + ); + $tabs->add( + 'services', + array( + 'title' => 'Services', + 'icon' => 'img/classic/service.png', + 'url' => 'monitoring/show/services', 'urlParams' => $params, - )); + ) + ); + if (isset($params['service'])) { + $tabs->add( + 'service', + array( + 'title' => 'Service', + 'icon' => 'img/classic/service.png', + 'url' => 'monitoring/show/service', + 'urlParams' => $params, + ) + ); } - $tabs->add('history', array( - 'title' => 'History', - 'icon' => 'img/classic/history.gif', - 'url' => 'monitoring/show/history', - 'urlParams' => $params, - )); + $tabs->add( + 'history', + array( + 'title' => 'History', + 'icon' => 'img/classic/history.gif', + 'url' => 'monitoring/show/history', + 'urlParams' => $params, + ) + ); if ($this->action_name === 'ticket') { - $tabs->add('ticket', array( - 'title' => 'Ticket', - 'icon' => 'img/classic/ticket.gif', - 'url' => 'monitoring/show/ticket', - 'urlParams' => $params + array('ticket' => $this->_getParam('ticket')), - )); + $tabs->add( + 'ticket', + array( + 'title' => 'Ticket', + 'icon' => 'img/classic/ticket.gif', + 'url' => 'monitoring/show/ticket', + 'urlParams' => $params + array('ticket' => $this->_getParam('ticket')), + ) + ); } -/* - $tabs->add('contacts', array( - 'title' => 'Contacts', - 'icon' => 'img/classic/customer.png', - 'url' => 'monitoring/detail/contacts', - 'urlParams' => $params, - )); -*/ + /* + $tabs->add('contacts', array( + 'title' => 'Contacts', + 'icon' => 'img/classic/customer.png', + 'url' => 'monitoring/detail/contacts', + 'urlParams' => $params, + )); + */ // TODO: Inventory 'img/classic/facts.gif' // Ticket 'img/classic/ticket.gif' // Customer 'img/classic/customer.png' diff --git a/modules/monitoring/application/views/scripts/show/components/comments.phtml b/modules/monitoring/application/views/scripts/show/components/comments.phtml index e19da1adf..b641985ee 100644 --- a/modules/monitoring/application/views/scripts/show/components/comments.phtml +++ b/modules/monitoring/application/views/scripts/show/components/comments.phtml @@ -21,5 +21,11 @@ foreach ($this->comments as $comment) { ); } ?> -Comments:
', $list) ?>
+
+
+ Comments +
+ +
', $list) ?>
+
diff --git a/modules/monitoring/application/views/scripts/show/components/contacts.phtml b/modules/monitoring/application/views/scripts/show/components/contacts.phtml index 0b34e22de..7197c96b9 100644 --- a/modules/monitoring/application/views/scripts/show/components/contacts.phtml +++ b/modules/monitoring/application/views/scripts/show/components/contacts.phtml @@ -1,24 +1,33 @@ -contacts)): ?> -contacts as $contact) { - $list[] = $this->qlink($contact->contact_alias, 'monitoring/show/contact', array( - 'contact_name' => $contact->contact_name - )); -} -?> -Contacts:
- +contacts)) { + $contactList = array(); + foreach ($this->contacts as $contact) { + $contactList[] = $this->qlink( + $contact->contact_alias, + 'monitoring/show/contact', + array( + 'contact_name' => $contact->contact_name + ) + ); + } -contactgroups)): ?> -contactgroups as $contactgroup) { - $list[] = $this->qlink($contactgroup->contactgroup_alias, 'monitoring/show/contactgroup', array( - 'contactgroup_name' => $contactgroup->contactgroup_name - )); -} -?> -Contactgroups:
- + echo 'Contacts: '; + echo implode(', ', $contactList); + } + if (!empty($this->contactgroups)) { + $contactGroupList = array(); + foreach ($this->contactgroups as $contactgroup) { + $contactGroupList[] = $this->qlink( + $contactgroup->contactgroup_alias, + 'monitoring/show/contactgroup', + array( + 'contactgroup_name' => $contactgroup->contactgroup_name + ) + ); + } + + echo 'Contactgroups: '; + echo implode(', ', $contactGroupList); + } +?> \ No newline at end of file diff --git a/modules/monitoring/application/views/scripts/show/components/customvars.phtml b/modules/monitoring/application/views/scripts/show/components/customvars.phtml new file mode 100644 index 000000000..afb05d2db --- /dev/null +++ b/modules/monitoring/application/views/scripts/show/components/customvars.phtml @@ -0,0 +1,22 @@ +customvars) && count($this->customvars)) { ?> +
+
+ Customvariables +
+ +
+ + + + + + customvars as $name => $value) { ?> + + + + + +
NameValue
escape($name) ?>escape($value) ?>
+
+
+ \ No newline at end of file diff --git a/modules/monitoring/application/views/scripts/show/header.phtml b/modules/monitoring/application/views/scripts/show/header.phtml index 5caeb3af0..ca09e6529 100644 --- a/modules/monitoring/application/views/scripts/show/header.phtml +++ b/modules/monitoring/application/views/scripts/show/header.phtml @@ -1,30 +1,72 @@ service) && $this->tabs->getActiveName() !== 'host'; +/** @var boolean $showService */ +$showService = false; +if (isset($this->service) && $this->tabs->getActiveName() !== 'host') { + $showService = true; +} + +/** @var boolean $inlineCommands */ +$inlineCommands = true; +if ($this->tabs->getActiveName() === 'history') { + $inlineCommands = false; +} + +if (!$this->compact) { + echo $this->tabs; +} ?> -compact): ?> -tabs ?> - - - - - - - - - - - - - - -
escape($this->host->host_name) ?>host->host_address && $this->host->host_address !== $this->host->host_name): ?> - (escape($this->host->host_address) ?>) - - > - util()->getHostStateName($this->host->host_state); ?>
- since timeSince($this->host->host_last_state_change) ?> -
Service: escape($this->service->service_description) ?> - util()->getServiceStateName($this->service->service_state); ?>
- since timeSince($this->service->service_last_state_change) ?> -
Host state
+
+ +
+
+ +
+
+ +
+
+ + + + + + + + + + + + + + + +
+ + escape($this->host->host_name); ?> + host->host_address && $this->host->host_address !== $this->host->host_name) { ?> + (escape($this->host->host_address); ?>) + + + + host->host_alias) && $this->host->host_alias !== $this->host->host_name) { ?> +
+ (host->host_alias; ?>) + +
> + util()->getHostStateName($this->host->host_state); ?> + since timeSince($this->host->host_last_state_change); ?> +
+ + Service: escape($this->service->service_description); ?> + + + util()->getServiceStateName($this->service->service_state); ?> + since timeSince($this->service->service_last_state_change); ?> +
+ +
+
\ No newline at end of file diff --git a/modules/monitoring/application/views/scripts/show/host.phtml b/modules/monitoring/application/views/scripts/show/host.phtml index 2ffe6601a..da9d5a94d 100644 --- a/modules/monitoring/application/views/scripts/show/host.phtml +++ b/modules/monitoring/application/views/scripts/show/host.phtml @@ -1,40 +1,78 @@ -partial('show/header.phtml', array( - 'host' => $this->host, - 'service' => $this->service, - 'tabs' => $this->tabs, - 'compact' => $this->compact -)); ?> -expandable( - $this->pluginOutput($this->host->host_output), - $this->pluginOutput($this->host->host_long_output) -) ?> -expandable( - 'Command: ' . array_shift(preg_split('|!|', $this->host->host_check_command)), - $this->commandArguments($this->host->host_check_command) -) ?> -hostgroups)): ?> -hostgroups as $name => $alias) { - $list[] = $this->qlink($alias, 'monitoring/list/services', array( - 'hostgroups' => $name - )); -} -?> -Hostgroups:
- -render('show/components/contacts.phtml') ?> -render('show/components/comments.phtml') ?> +hostgroups)) { + foreach ($this->hostgroups as $name => $alias) { + $hostgroupLinkList[] = $this->qlink( + $alias, + 'monitoring/list/services', + array( + 'hostgroups' => $name + ) + ); + } + } + +var_dump($this->host); +?> +partial( + 'show/header.phtml', + array( + 'host' => $this->host, + 'service' => $this->service, + 'tabs' => $this->tabs, + 'compact' => $this->compact + ) + ); +?> -customvars as $name => $value): ?> -escape($name) ?>: escape($value) ?>
- -host->host_perfdata): ?> -expandable( - 'Performance data', - $this->perfdata($this->host->host_perfdata), - array('collapsed' => false) -) ?> - preview_image ?> +
+
+ Plugin output +
+
+ pluginOutput($this->host->host_output); ?> + pluginOutput($this->host->host_long_output); ?> +
+
+ +
+
+ Command +
+ +
+ Command: + host->host_check_command, 2)); ?> + commandArguments($this->host->host_check_command); ?> +
+
+ +
+
+ Groups and Contacts +
+ + Hostgroups: + + + + render('show/components/contacts.phtml') ?> +
+ +render('show/components/comments.phtml'); ?> + +render('show/components/customvars.phtml'); ?> + +host->host_perfdata): ?> +
+
+ Perfdata +
+
+ perfdata($this->host->host_perfdata); ?> +
+
+ \ No newline at end of file diff --git a/modules/monitoring/library/Monitoring/Backend/AbstractBackend.php b/modules/monitoring/library/Monitoring/Backend/AbstractBackend.php index 0dcdb278a..a7ab52211 100644 --- a/modules/monitoring/library/Monitoring/Backend/AbstractBackend.php +++ b/modules/monitoring/library/Monitoring/Backend/AbstractBackend.php @@ -23,7 +23,7 @@ class AbstractBackend implements DatasourceInterface protected function init() { } - + /** * Dummy function for fluent code * @@ -46,7 +46,7 @@ class AbstractBackend implements DatasourceInterface public function from($virtual_table, $fields = array()) { $classname = $this->tableToClassName($virtual_table); - if (! class_exists($classname)) { + if (!class_exists($classname)) { throw new ProgrammingError( sprintf( 'Asking for invalid virtual table %s', @@ -67,10 +67,10 @@ class AbstractBackend implements DatasourceInterface protected function tableToClassName($virtual_table) { return 'Icinga\\Monitoring\\View\\' - // . $this->getName() - // . '\\' - . ucfirst($virtual_table) - . 'View'; + // . $this->getName() + // . '\\' + . ucfirst($virtual_table) + . 'View'; } public function getName() @@ -84,62 +84,87 @@ class AbstractBackend implements DatasourceInterface } - // UGLY temporary host fetch - public function fetchHost($host) + public function fetchHost($host, $fetchAll = false) { - $select = $this->select() - ->from('status', array( - 'host_name', - 'host_address', - 'host_state', - 'host_handled', - 'host_in_downtime', - 'host_acknowledged', - 'host_check_command', - 'host_last_state_change', - 'host_alias', - 'host_output', - 'host_long_output', - 'host_perfdata', - )) - ->where('host_name', $host); - return $select->fetchRow(); - $object = \Icinga\Objects\Host::fromBackend( - $this->select() - ->from('status', array( - 'host_name', - 'host_address', - 'host_state', - 'host_handled', - 'host_in_downtime', - 'host_acknowledged', - 'host_check_command', - 'host_last_state_change', - 'host_alias', - 'host_output', - 'host_long_output', - 'host_perfdata', - )) - ->where('host_name', $host) - ->fetchRow() + $fields = array( + 'host_name', + 'host_address', + 'host_state', + 'host_handled', + 'host_in_downtime', + 'host_acknowledged', + 'host_check_command', + 'host_last_state_change', + 'host_alias', + 'host_output', + 'host_long_output', + 'host_perfdata' ); - // $object->customvars = $this->fetchCustomvars($host); - return $object; + + $fields = array_merge( + $fields, + array( + 'current_check_attempt', + 'max_check_attempts', + 'attempt', + 'last_check', + 'next_check', + 'check_type', + 'last_state_change', + 'last_hard_state_change', + 'last_hard_state', + 'last_time_up', + 'last_time_down', + 'last_time_unreachable', + 'state_type', + 'last_notification', + 'next_notification', + 'no_more_notifications', + 'notifications_enabled', + 'problem_has_been_acknowledged', + 'acknowledgement_type', + 'current_notification_number', + 'passive_checks_enabled', + 'active_checks_enabled', + 'event_handler_enabled', + 'flap_detection_enabled', + 'is_flapping', + 'percent_state_change', + 'latency', + 'execution_time', + 'scheduled_downtime_depth', + 'failure_prediction_enabled', + 'process_performance_data', + 'obsess_over_host', + 'modified_host_attributes', + 'event_handler', + 'check_command', + 'normal_check_interval', + 'retry_check_interval', + 'check_timeperiod_object_id' + ) + ); + + $select = $this->select() + ->from('status', $fields) + ->where('host_name', $host); + return $select->fetchRow(); } // UGLY temporary service fetch public function fetchService($host, $service) { -Benchmark::measure('Preparing service select'); + Benchmark::measure('Preparing service select'); $select = $this->select() - ->from('status', array( + ->from( + 'status', + array( 'host_name', 'host_state', 'host_check_command', 'host_last_state_change', - 'service_description', 'service_state', 'service_acknowledged', @@ -154,39 +179,42 @@ Benchmark::measure('Preparing service select'); 'service_next_check', 'service_check_execution_time', 'service_check_latency', - // 'service_ - )) - ->where('host_name', $host) - ->where('service_description', $service); + // 'service_ + ) + ) + ->where('host_name', $host) + ->where('service_description', $service); // Benchmark::measure((string) $select->getQuery()); -Benchmark::measure('Prepared service select'); + Benchmark::measure('Prepared service select'); return $select->fetchRow(); $object = \Icinga\Objects\Service::fromBackend( $this->select() - ->from('status', array( + ->from( + 'status', + array( - 'host_name', - 'host_state', - 'host_check_command', - 'host_last_state_change', - - 'service_description', - 'service_state', - 'service_acknowledged', - 'service_handled', - 'service_output', - 'service_long_output', - 'service_perfdata', - // '_host_satellite', - 'service_check_command', - 'service_last_state_change', - 'service_last_check', - 'service_next_check', - 'service_check_execution_time', - 'service_check_latency', - // 'service_ - )) + 'host_name', + 'host_state', + 'host_check_command', + 'host_last_state_change', + 'service_description', + 'service_state', + 'service_acknowledged', + 'service_handled', + 'service_output', + 'service_long_output', + 'service_perfdata', + // '_host_satellite', + 'service_check_command', + 'service_last_state_change', + 'service_last_check', + 'service_next_check', + 'service_check_execution_time', + 'service_check_latency', + // 'service_ + ) + ) ->where('host_name', $host) ->where('service_description', $service) ->fetchRow() diff --git a/modules/monitoring/library/Monitoring/Backend/Ido/Query/StatusQuery.php b/modules/monitoring/library/Monitoring/Backend/Ido/Query/StatusQuery.php index 4d2ee946e..b6c5b02b5 100644 --- a/modules/monitoring/library/Monitoring/Backend/Ido/Query/StatusQuery.php +++ b/modules/monitoring/library/Monitoring/Backend/Ido/Query/StatusQuery.php @@ -8,27 +8,67 @@ class StatusQuery extends AbstractQuery protected $columnMap = array( 'hosts' => array( - 'host' => 'ho.name1', - 'host_name' => 'ho.name1', - 'host_display_name' => 'h.display_name', - 'host_alias' => 'h.alias', - 'host_address' => 'h.address', - 'host_ipv4' => 'INET_ATON(h.address)', - 'host_icon_image' => 'h.icon_image', + 'host' => 'ho.name1', + 'host_name' => 'ho.name1', + 'host_display_name' => 'h.display_name', + 'host_alias' => 'h.alias', + 'host_address' => 'h.address', + 'host_ipv4' => 'INET_ATON(h.address)', + 'host_icon_image' => 'h.icon_image', ), 'hoststatus' => array( - 'host_state' => 'CASE WHEN hs.has_been_checked = 0 OR hs.has_been_checked IS NULL THEN 99 ELSE hs.current_state END', - 'host_output' => 'hs.output', - 'host_long_output' => 'hs.long_output', - 'host_perfdata' => 'hs.perfdata', - 'host_acknowledged' => 'hs.problem_has_been_acknowledged', - 'host_in_downtime' => 'CASE WHEN (hs.scheduled_downtime_depth = 0) THEN 0 ELSE 1 END', - 'host_handled' => 'CASE WHEN (hs.problem_has_been_acknowledged + hs.scheduled_downtime_depth) > 0 THEN 1 ELSE 0 END', - 'host_does_active_checks' => 'hs.active_checks_enabled', + 'host_state' => 'CASE WHEN hs.has_been_checked = 0 OR hs.has_been_checked IS NULL THEN 99 ELSE hs.current_state END', + 'host_output' => 'hs.output', + 'host_long_output' => 'hs.long_output', + 'host_perfdata' => 'hs.perfdata', + 'host_acknowledged' => 'hs.problem_has_been_acknowledged', + 'host_in_downtime' => 'CASE WHEN (hs.scheduled_downtime_depth = 0) THEN 0 ELSE 1 END', + 'host_handled' => 'CASE WHEN (hs.problem_has_been_acknowledged + hs.scheduled_downtime_depth) > 0 THEN 1 ELSE 0 END', + 'host_does_active_checks' => 'hs.active_checks_enabled', 'host_accepts_passive_checks' => 'hs.passive_checks_enabled', - 'host_last_state_change' => 'UNIX_TIMESTAMP(hs.last_state_change)', - 'host_check_command' => 'hs.check_command', - 'host_problems' => 'CASE WHEN hs.current_state = 0 THEN 0 ELSE 1 END', + 'host_last_state_change' => 'UNIX_TIMESTAMP(hs.last_state_change)', + 'host_check_command' => 'hs.check_command', + + 'current_check_attempt' => 'hs.current_check_attempt', + 'max_check_attempts' => 'hs.max_check_attempts', + 'attempt' => 'CONCAT(hs.current_check_attempt, "/", hs.max_check_attempts)', + 'last_check' => 'hs.last_check', + 'next_check' => 'hs.next_check', + 'check_type' => 'hs.check_type', + 'last_state_change' => 'hs.last_state_change', + 'last_hard_state_change' => 'hs.last_hard_state_change', + 'last_hard_state' => 'hs.last_hard_state', + 'last_time_up' => 'hs.last_time_up', + 'last_time_down' => 'hs.last_time_down', + 'last_time_unreachable' => 'hs.last_time_unreachable', + 'state_type' => 'hs.state_type', + 'last_notification' => 'hs.last_notification', + 'next_notification' => 'hs.next_notification', + 'no_more_notifications' => 'hs.no_more_notifications', + 'notifications_enabled' => 'hs.notifications_enabled', + 'problem_has_been_acknowledged' => 'hs.problem_has_been_acknowledged', + 'acknowledgement_type' => 'hs.acknowledgement_type', + 'current_notification_number' => 'hs.current_notification_number', + 'passive_checks_enabled' => 'hs.passive_checks_enabled', + 'active_checks_enabled' => 'hs.active_checks_enabled', + 'event_handler_enabled' => 'hs.event_handler_enabled', + 'flap_detection_enabled' => 'hs.flap_detection_enabled', + 'is_flapping' => 'hs.is_flapping', + 'percent_state_change' => 'hs.percent_state_change', + 'latency' => 'hs.latency', + 'execution_time' => 'hs.execution_time', + 'scheduled_downtime_depth' => 'hs.scheduled_downtime_depth', + 'failure_prediction_enabled' => 'hs.failure_prediction_enabled', + 'process_performance_data' => 'hs.process_performance_data', + 'obsess_over_host' => 'hs.obsess_over_host', + 'modified_host_attributes' => 'hs.modified_host_attributes', + 'event_handler' => 'hs.event_handler', + 'check_command' => 'hs.check_command', + 'normal_check_interval' => 'hs.normal_check_interval', + 'retry_check_interval' => 'hs.retry_check_interval', + 'check_timeperiod_object_id' => 'hs.check_timeperiod_object_id', + + 'host_problems' => 'CASE WHEN hs.current_state = 0 THEN 0 ELSE 1 END', 'host_severity' => 'CASE WHEN hs.current_state = 0 THEN CASE WHEN hs.has_been_checked = 0 OR hs.has_been_checked IS NULL @@ -65,36 +105,36 @@ class StatusQuery extends AbstractQuery 'hostgroups' => 'hgo.name1', ), 'services' => array( - 'service_host_name' => 'so.name1', - 'service' => 'so.name2', - 'service_description' => 'so.name2', - 'service_display_name' => 's.display_name', - 'service_icon_image' => 's.icon_image', + 'service_host_name' => 'so.name1', + 'service' => 'so.name2', + 'service_description' => 'so.name2', + 'service_display_name' => 's.display_name', + 'service_icon_image' => 's.icon_image', ), 'servicestatus' => array( - 'current_state' => 'CASE WHEN ss.has_been_checked = 0 OR ss.has_been_checked IS NULL THEN 99 ELSE ss.current_state END', - 'service_state' => 'CASE WHEN ss.has_been_checked = 0 OR ss.has_been_checked IS NULL THEN 99 ELSE ss.current_state END', - 'service_hard_state' => 'CASE WHEN ss.has_been_checked = 0 OR ss.has_been_checked IS NULL THEN 99 ELSE CASE WHEN ss.state_type = 1 THEN ss.current_state ELSE ss.last_hard_state END END', - 'service_state_type' => 'ss.state_type', - 'service_output' => 'ss.output', - 'service_long_output' => 'ss.long_output', - 'service_perfdata' => 'ss.perfdata', - 'service_acknowledged' => 'ss.problem_has_been_acknowledged', - 'service_in_downtime' => 'CASE WHEN (ss.scheduled_downtime_depth = 0) THEN 0 ELSE 1 END', - 'service_handled' => 'CASE WHEN (ss.problem_has_been_acknowledged + ss.scheduled_downtime_depth + COALESCE(hs.current_state, 0)) > 0 THEN 1 ELSE 0 END', - 'service_does_active_checks' => 'ss.active_checks_enabled', + 'current_state' => 'CASE WHEN ss.has_been_checked = 0 OR ss.has_been_checked IS NULL THEN 99 ELSE ss.current_state END', + 'service_state' => 'CASE WHEN ss.has_been_checked = 0 OR ss.has_been_checked IS NULL THEN 99 ELSE ss.current_state END', + 'service_hard_state' => 'CASE WHEN ss.has_been_checked = 0 OR ss.has_been_checked IS NULL THEN 99 ELSE CASE WHEN ss.state_type = 1 THEN ss.current_state ELSE ss.last_hard_state END END', + 'service_state_type' => 'ss.state_type', + 'service_output' => 'ss.output', + 'service_long_output' => 'ss.long_output', + 'service_perfdata' => 'ss.perfdata', + 'service_acknowledged' => 'ss.problem_has_been_acknowledged', + 'service_in_downtime' => 'CASE WHEN (ss.scheduled_downtime_depth = 0) THEN 0 ELSE 1 END', + 'service_handled' => 'CASE WHEN (ss.problem_has_been_acknowledged + ss.scheduled_downtime_depth + COALESCE(hs.current_state, 0)) > 0 THEN 1 ELSE 0 END', + 'service_does_active_checks' => 'ss.active_checks_enabled', 'service_accepts_passive_checks' => 'ss.passive_checks_enabled', - 'service_last_state_change' => 'UNIX_TIMESTAMP(ss.last_state_change)', + 'service_last_state_change' => 'UNIX_TIMESTAMP(ss.last_state_change)', 'service_last_hard_state_change' => 'UNIX_TIMESTAMP(ss.last_hard_state_change)', - 'service_check_command' => 'ss.check_command', - 'service_last_check' => 'UNIX_TIMESTAMP(ss.last_check)', - 'service_next_check' => 'CASE WHEN ss.should_be_scheduled THEN UNIX_TIMESTAMP(ss.next_check) ELSE NULL END', - 'service_check_execution_time' => 'ss.execution_time', - 'service_check_latency' => 'ss.latency', + 'service_check_command' => 'ss.check_command', + 'service_last_check' => 'UNIX_TIMESTAMP(ss.last_check)', + 'service_next_check' => 'CASE WHEN ss.should_be_scheduled THEN UNIX_TIMESTAMP(ss.next_check) ELSE NULL END', + 'service_check_execution_time' => 'ss.execution_time', + 'service_check_latency' => 'ss.latency', ), 'status' => array( 'problems' => 'CASE WHEN ss.current_state = 0 THEN 0 ELSE 1 END', - 'handled' => 'CASE WHEN ss.problem_has_been_acknowledged = 1 OR ss.scheduled_downtime_depth > 0 THEN 1 ELSE 0 END', + 'handled' => 'CASE WHEN ss.problem_has_been_acknowledged = 1 OR ss.scheduled_downtime_depth > 0 THEN 1 ELSE 0 END', 'severity' => 'CASE WHEN ss.current_state = 0 THEN CASE WHEN ss.has_been_checked = 0 OR ss.has_been_checked IS NULL @@ -129,10 +169,12 @@ class StatusQuery extends AbstractQuery END', ) ); -public function group($col) -{ - $this->baseQuery->group($col); -} + + public function group($col) + { + $this->baseQuery->group($col); + } + protected function getDefaultColumns() { return $this->columnMap['hosts']; @@ -150,25 +192,25 @@ public function group($col) array('ho' => $this->prefix . 'objects'), array() )->join( - array('hs' => $this->prefix . 'hoststatus'), - 'ho.object_id = hs.host_object_id AND ho.is_active = 1', - array() - )->join( - array('h' => $this->prefix . 'hosts'), - 'hs.host_object_id = h.host_object_id', - array() - ); + array('hs' => $this->prefix . 'hoststatus'), + 'ho.object_id = hs.host_object_id AND ho.is_active = 1', + array() + )->join( + array('h' => $this->prefix . 'hosts'), + 'hs.host_object_id = h.host_object_id', + array() + ); $this->joinedVirtualTables = array( - 'hosts' => true, + 'hosts' => true, 'hoststatus' => true, ); } - + protected function joinStatus() { $this->requireVirtualTable('services'); } - + protected function joinServiceStatus() { $this->requireVirtualTable('services'); @@ -181,16 +223,16 @@ public function group($col) 's.host_object_id = h.host_object_id', array() )->join( - array('so' => $this->prefix . 'objects'), - "so.$this->object_id = s.service_object_id AND so.is_active = 1", - array() - )->joinLeft( - array('ss' => $this->prefix . 'servicestatus'), - "so.$this->object_id = ss.service_object_id", - array() - ); + array('so' => $this->prefix . 'objects'), + "so.$this->object_id = s.service_object_id AND so.is_active = 1", + array() + )->joinLeft( + array('ss' => $this->prefix . 'servicestatus'), + "so.$this->object_id = ss.service_object_id", + array() + ); } - + // TODO: Test this one, doesn't seem to work right now protected function joinHostgroups() { @@ -208,10 +250,10 @@ public function group($col) 'hgm.host_object_id = h.host_object_id', array() )->join( - array('hg' => $this->prefix . 'hostgroups'), - "hgm.hostgroup_id = hg.$this->hostgroup_id", - array() - ); + array('hg' => $this->prefix . 'hostgroups'), + "hgm.hostgroup_id = hg.$this->hostgroup_id", + array() + ); return $this; } @@ -223,15 +265,15 @@ public function group($col) 'hgm.host_object_id = s.host_object_id', array() )->join( - array('hg' => $this->prefix . 'hostgroups'), - 'hgm.hostgroup_id = hg.' . $this->hostgroup_id, - array() - )->join( - array('hgo' => $this->prefix . 'objects'), - 'hgo.' . $this->object_id. ' = hg.hostgroup_object_id' - . ' AND hgo.is_active = 1', - array() - ); + array('hg' => $this->prefix . 'hostgroups'), + 'hgm.hostgroup_id = hg.' . $this->hostgroup_id, + array() + )->join( + array('hgo' => $this->prefix . 'objects'), + 'hgo.' . $this->object_id . ' = hg.hostgroup_object_id' + . ' AND hgo.is_active = 1', + array() + ); return $this; } @@ -243,15 +285,15 @@ public function group($col) 'sgm.service_object_id = s.service_object_id', array() )->join( - array('sg' => $this->prefix . 'servicegroups'), - 'sgm.servicegroup_id = sg.' . $this->servicegroup_id, - array() - )->join( - array('hgo' => $this->prefix . 'objects'), - 'hgo.' . $this->object_id. ' = hg.' . $this->hostgroup_id - . ' AND hgo.is_active = 1', - array() - ); + array('sg' => $this->prefix . 'servicegroups'), + 'sgm.servicegroup_id = sg.' . $this->servicegroup_id, + array() + )->join( + array('hgo' => $this->prefix . 'objects'), + 'hgo.' . $this->object_id . ' = hg.' . $this->hostgroup_id + . ' AND hgo.is_active = 1', + array() + ); return $this; } diff --git a/public/css/base.less b/public/css/base.less index ccd852ad7..7b54bad28 100755 --- a/public/css/base.less +++ b/public/css/base.less @@ -178,3 +178,4 @@ body { @import 'dataviews'; @import 'components/layouts'; @import 'components/tables'; +@import 'components/details'; diff --git a/public/css/components/details.less b/public/css/components/details.less index e47834065..0f6b765eb 100755 --- a/public/css/components/details.less +++ b/public/css/components/details.less @@ -84,4 +84,24 @@ font-size: 12px; clear:left; font-weight:bold; } +} + +.information-container { + margin: 0 0 5px 0; + + border: 1px #fa4600 solid; + padding: 5px; + + .head { + top: -5px; + left: -5px; + position: relative; + display: table-cell; + background-color: yellow; + padding: 4px; + } + + .container-spacer { + margin: 10px 0 0 0; + } } \ No newline at end of file