From d6fd3350e0c3d29ed229e0f30cc23304bac06508 Mon Sep 17 00:00:00 2001 From: Marius Hein Date: Tue, 15 Oct 2013 12:48:33 +0200 Subject: [PATCH] Apply style to detail refs #4869 --- .../scripts/show/components/command.phtml | 9 +- .../scripts/show/components/contacts.phtml | 34 ++-- .../scripts/show/components/customvars.phtml | 11 +- .../scripts/show/components/downtime.phtml | 3 +- .../scripts/show/components/hostgroups.phtml | 19 ++- .../scripts/show/components/properties.phtml | 4 - .../show/components/servicegroups.phtml | 17 +- .../application/views/scripts/show/host.phtml | 2 +- .../library/Monitoring/DataView/Customvar.php | 65 ++++++++ .../Monitoring/Object/AbstractObject.php | 144 +++++++++++------ .../library/Monitoring/Object/Host.php | 134 +++++++++++----- .../library/Monitoring/Object/Service.php | 150 ++++++++++++------ 12 files changed, 426 insertions(+), 166 deletions(-) create mode 100644 modules/monitoring/library/Monitoring/DataView/Customvar.php diff --git a/modules/monitoring/application/views/scripts/show/components/command.phtml b/modules/monitoring/application/views/scripts/show/components/command.phtml index 3e30b62e8..6e76bbfc6 100644 --- a/modules/monitoring/application/views/scripts/show/components/command.phtml +++ b/modules/monitoring/application/views/scripts/show/components/command.phtml @@ -1,9 +1,12 @@ -
+
- {{CHECK_COMMAND_ICON}} - Check Command +
+ Check Command +
+
+
diff --git a/modules/monitoring/application/views/scripts/show/components/contacts.phtml b/modules/monitoring/application/views/scripts/show/components/contacts.phtml index 3256d3ac6..cbd1a8bb4 100644 --- a/modules/monitoring/application/views/scripts/show/components/contacts.phtml +++ b/modules/monitoring/application/views/scripts/show/components/contacts.phtml @@ -1,4 +1,3 @@ -contacts)): ?> contacts as $contact) { @@ -14,17 +13,24 @@ foreach ($object->contacts as $contact) { . ''; } ?> -
+
- {{CONTACT_ICON}} Contacts +
+ Contacts +
+ +
+
- + + No Contacts + + +
- -contactgroups)): ?> contactgroups as $contactgroup) { @@ -40,12 +46,20 @@ foreach ($object->contactgroups as $contactgroup) { . ''; } ?> -
+
- {{CONTACTGROUP_ICON}} Contactgroups +
+ Contactgroups +
+ +
+
- + + No Contactgroups + + +
- diff --git a/modules/monitoring/application/views/scripts/show/components/customvars.phtml b/modules/monitoring/application/views/scripts/show/components/customvars.phtml index 093052245..e3ba9563b 100644 --- a/modules/monitoring/application/views/scripts/show/components/customvars.phtml +++ b/modules/monitoring/application/views/scripts/show/components/customvars.phtml @@ -8,6 +8,15 @@
- object); ?> + object->customvars)): ?> + No customvars + +
+ object->customvars as $varname => $varvalue): ?> +
+
+ +
+
\ No newline at end of file diff --git a/modules/monitoring/application/views/scripts/show/components/downtime.phtml b/modules/monitoring/application/views/scripts/show/components/downtime.phtml index 9003e0184..e38b10a14 100644 --- a/modules/monitoring/application/views/scripts/show/components/downtime.phtml +++ b/modules/monitoring/application/views/scripts/show/components/downtime.phtml @@ -56,7 +56,7 @@
- + object->downtimes as $downtime): ?> +
No Downtimes
@@ -89,6 +89,7 @@
diff --git a/modules/monitoring/application/views/scripts/show/components/hostgroups.phtml b/modules/monitoring/application/views/scripts/show/components/hostgroups.phtml index d33ccd590..ffc8c501f 100644 --- a/modules/monitoring/application/views/scripts/show/components/hostgroups.phtml +++ b/modules/monitoring/application/views/scripts/show/components/hostgroups.phtml @@ -1,4 +1,3 @@ -hostgroups)): ?> hostgroups as $name => $alias) { @@ -7,12 +6,20 @@ foreach ($object->hostgroups as $name => $alias) { . ''; } ?> -
+
- {{HOSTGROUP_ICON}} Hostgroups +
+ Hostgroups +
+ +
+
- + + No Hostgroups + + +
-
- +
\ No newline at end of file diff --git a/modules/monitoring/application/views/scripts/show/components/properties.phtml b/modules/monitoring/application/views/scripts/show/components/properties.phtml index 23e71ac60..161031060 100644 --- a/modules/monitoring/application/views/scripts/show/components/properties.phtml +++ b/modules/monitoring/application/views/scripts/show/components/properties.phtml @@ -10,12 +10,8 @@
Latency
object->check_execution_time); ?>s
-
-
Duration
object->check_latency); ?>s
-
-
Attempt
object->current_check_attempt; ?>/object->max_check_attempts; ?> diff --git a/modules/monitoring/application/views/scripts/show/components/servicegroups.phtml b/modules/monitoring/application/views/scripts/show/components/servicegroups.phtml index d2fdbceaf..5f79db497 100644 --- a/modules/monitoring/application/views/scripts/show/components/servicegroups.phtml +++ b/modules/monitoring/application/views/scripts/show/components/servicegroups.phtml @@ -1,4 +1,3 @@ -servicegroups)): ?> servicegroups as $name => $alias) { @@ -7,12 +6,20 @@ foreach ($object->servicegroups as $name => $alias) { . ''; } ?> -
+
- {{SERVICEGROUP_ICON}} Servicegroups +
+ Servicegroups +
+ +
+
- + + No Servicegroups + + +
- diff --git a/modules/monitoring/application/views/scripts/show/host.phtml b/modules/monitoring/application/views/scripts/show/host.phtml index 0b0166efd..8c482053b 100644 --- a/modules/monitoring/application/views/scripts/show/host.phtml +++ b/modules/monitoring/application/views/scripts/show/host.phtml @@ -5,6 +5,6 @@ render('show/components/properties.phtml'); ?> render('show/components/flags.phtml'); ?> render('show/components/customvars.phtml'); ?> -render('show/components/servicegroups.phtml'); ?> +render('show/components/hostgroups.phtml'); ?> render('show/components/contacts.phtml'); ?> render('show/components/command.phtml') ?> diff --git a/modules/monitoring/library/Monitoring/DataView/Customvar.php b/modules/monitoring/library/Monitoring/DataView/Customvar.php new file mode 100644 index 000000000..fab68204b --- /dev/null +++ b/modules/monitoring/library/Monitoring/DataView/Customvar.php @@ -0,0 +1,65 @@ + + * @license http://www.gnu.org/licenses/gpl-2.0.txt GPL, version 2 + * @author Icinga Development Team + */ +// {{{ICINGA_LICENSE_HEADER}}} + +namespace Icinga\Module\Monitoring\DataView; + +/** + * Represent customvar view + */ +class Customvar extends DataView +{ + /** + * Retrieve columns provided by this view + * + * @return array + */ + public function getColumns() + { + return array( + 'varname', + 'varvalue', + 'object_type' + ); + } + + /** + * Retrieve default sorting rules for particular columns. These involve sort order and potential additional to sort + * + * @return array + */ + public function getSortRules() + { + return array( + 'varname' => array( + 'varname' => self::SORT_ASC, + 'varvalue' => self::SORT_ASC, + ) + ); + } +} diff --git a/modules/monitoring/library/Monitoring/Object/AbstractObject.php b/modules/monitoring/library/Monitoring/Object/AbstractObject.php index 40ae632b5..33a653735 100644 --- a/modules/monitoring/library/Monitoring/Object/AbstractObject.php +++ b/modules/monitoring/library/Monitoring/Object/AbstractObject.php @@ -1,10 +1,40 @@ + * @license http://www.gnu.org/licenses/gpl-2.0.txt GPL, version 2 + * @author Icinga Development Team + */ +// {{{ICINGA_LICENSE_HEADER}}} namespace Icinga\Module\Monitoring\Object; use Icinga\Data\AbstractQuery as Query; use \Icinga\Module\Monitoring\Backend; +/** + * Generic icinga object with belongings + */ abstract class AbstractObject { protected $backend; @@ -17,14 +47,7 @@ abstract class AbstractObject protected $properties; - protected $foreign = array( - // 'hostgroups' => null, - // 'contacts' => null, - // 'contactgroups' => null, - // 'servicegroups' => null, - // 'customvars' => null, - // 'comments' => null, - ); + protected $foreign = array(); public function __construct(Backend $backend, $name1, $name2 = null) { @@ -81,10 +104,13 @@ abstract class AbstractObject protected function fetchHostgroups() { $this->foreign['hostgroups'] = $this->applyObjectFilter( - $this->backend->select()->from('hostgroup', array( - 'hostgroup_name', - 'hostgroup_alias' - )) + $this->backend->select()->from( + 'hostgroup', + array( + 'hostgroup_name', + 'hostgroup_alias' + ) + ) )->fetchPairs(); return $this; } @@ -92,10 +118,13 @@ abstract class AbstractObject protected function fetchServicegroups() { $this->foreign['servicegroups'] = $this->applyObjectFilter( - $this->backend->select()->from('servicegroup', array( - 'servicegroup_name', - 'servicegroup_alias' - )) + $this->backend->select()->from( + 'servicegroup', + array( + 'servicegroup_name', + 'servicegroup_alias' + ) + ) )->fetchPairs(); return $this; } @@ -103,12 +132,15 @@ abstract class AbstractObject protected function fetchContacts() { $this->foreign['contacts'] = $this->applyObjectFilter( - $this->backend->select()->from('contact', array( - 'contact_name', - 'contact_alias', - 'contact_email', - 'contact_pager', - )) + $this->backend->select()->from( + 'contact', + array( + 'contact_name', + 'contact_alias', + 'contact_email', + 'contact_pager', + ) + ) )->fetchAll(); return $this; } @@ -116,10 +148,13 @@ abstract class AbstractObject protected function fetchContactgroups() { $this->foreign['contactgroups'] = $this->applyObjectFilter( - $this->backend->select()->from('contactgroup', array( - 'contactgroup_name', - 'contactgroup_alias', - )) + $this->backend->select()->from( + 'contactgroup', + array( + 'contactgroup_name', + 'contactgroup_alias', + ) + ) )->fetchAll(); return $this; } @@ -127,12 +162,15 @@ abstract class AbstractObject protected function fetchComments() { $this->foreign['comments'] = $this->applyObjectFilter( - $this->backend->select()->from('comment', array( - 'comment_timestamp', - 'comment_author', - 'comment_data', - 'comment_type', - ))->where('comment_objecttype_id', $this->type) + $this->backend->select()->from( + 'comment', + array( + 'comment_timestamp', + 'comment_author', + 'comment_data', + 'comment_type', + ) + )->where('comment_objecttype_id', $this->type) )->fetchAll(); return $this; } @@ -140,12 +178,13 @@ abstract class AbstractObject protected function fetchCustomvars() { $this->foreign['customvars'] = $this->applyObjectFilter( - $this->backend->select()->from('customvar', array( - 'varname', - 'varvalue' - )) - ->where('varname', '-*PW*,-*PASS*,-*COMMUNITY*') - ->where('object_type', 'host') + $this->backend->select()->from( + 'customvar', + array( + 'varname', + 'varvalue' + ) + )->where('varname', '-*PW*,-*PASS*,-*COMMUNITY*') )->fetchPairs(); return $this; } @@ -153,17 +192,20 @@ abstract class AbstractObject public function fetchEventHistory() { $this->foreign['eventHistory'] = $this->applyObjectFilter( - $this->backend->select()->from('eventHistory', array( - 'object_type', - 'host_name', - 'service_description', - 'timestamp', - 'state', - 'attempt', - 'max_attempts', - 'output', - 'type' - )) + $this->backend->select()->from( + 'eventHistory', + array( + 'object_type', + 'host_name', + 'service_description', + 'timestamp', + 'state', + 'attempt', + 'max_attempts', + 'output', + 'type' + ) + ) ); return $this; } @@ -171,7 +213,9 @@ abstract class AbstractObject public function fetchDowtimes() { $this->foreign['downtimes'] = $this->applyObjectFilter( - $this->backend->select()->from('downtime', array( + $this->backend->select()->from( + 'downtime', + array( 'host_name', 'object_type', 'service_host_name', diff --git a/modules/monitoring/library/Monitoring/Object/Host.php b/modules/monitoring/library/Monitoring/Object/Host.php index ad540d49d..13b312f13 100644 --- a/modules/monitoring/library/Monitoring/Object/Host.php +++ b/modules/monitoring/library/Monitoring/Object/Host.php @@ -1,9 +1,39 @@ + * @license http://www.gnu.org/licenses/gpl-2.0.txt GPL, version 2 + * @author Icinga Development Team + */ +// {{{ICINGA_LICENSE_HEADER}}} namespace Icinga\Module\Monitoring\Object; use Icinga\Data\AbstractQuery as Query; +/** + * Represent a host object + */ class Host extends AbstractObject { protected $foreign = array( @@ -12,19 +42,35 @@ class Host extends AbstractObject 'contactgroups' => null, 'customvars' => null, 'comments' => null, - 'downtimes' => null + 'downtimes' => null, + 'customvars' => null ); + /** + * Statename + */ public function stateName() { // TODO } + /** + * Filter object belongings + * + * @param Query $query + * + * @return Query + */ protected function applyObjectFilter(Query $query) { return $query->where('host_name', $this->name1); } + /** + * Load foreign object data + * + * @return self + */ public function prefetch() { return $this->fetchHostgroups() @@ -32,48 +78,56 @@ class Host extends AbstractObject ->fetchContactgroups() ->fetchCustomvars() ->fetchComments() - ->fetchDowtimes(); + ->fetchDowtimes() + ->fetchCustomvars(); } + /** + * Load object data + * @return object + */ protected function fetchObject() { - return $this->backend->select()->from('status', array( - 'host_name', - 'host_alias', - 'host_address', - 'host_state', - 'host_handled', - 'host_in_downtime', - 'in_downtime' => 'host_in_downtime', - 'host_acknowledged', - 'host_last_state_change', - 'last_state_change' => 'host_last_state_change', - 'last_notification' => 'host_last_notification', - 'last_check' => 'host_last_check', - 'next_check' => 'host_next_check', - 'check_execution_time' => 'host_check_execution_time', - 'check_latency' => 'host_check_latency', - 'output' => 'host_output', - 'long_output' => 'host_long_output', - 'check_command' => 'host_check_command', - 'perfdata' => 'host_perfdata', - 'host_icon_image', - 'passive_checks_enabled' => 'host_passive_checks_enabled', - 'obsessing' => 'host_obsessing', - 'notifications_enabled' => 'host_notifications_enabled', - 'event_handler_enabled' => 'host_event_handler_enabled', - 'flap_detection_enabled' => 'host_flap_detection_enabled', - 'active_checks_enabled' => 'host_active_checks_enabled', - 'current_check_attempt' => 'host_current_check_attempt', - 'max_check_attempts' => 'host_max_check_attempts', - 'last_notification' => 'host_last_notification', - 'current_notification_number' => 'host_current_notification_number', - 'percent_state_change' => 'host_percent_state_change', - 'is_flapping' => 'host_is_flapping', - 'last_comment' => 'host_last_comment', - 'action_url' => 'host_action_url', - 'notes_url' => 'host_notes_url', - 'percent_state_change' => 'host_percent_state_change' - ))->where('host_name', $this->name1)->fetchRow(); + return $this->backend->select()->from( + 'status', + array( + 'host_name', + 'host_alias', + 'host_address', + 'host_state', + 'host_handled', + 'host_in_downtime', + 'in_downtime' => 'host_in_downtime', + 'host_acknowledged', + 'host_last_state_change', + 'last_state_change' => 'host_last_state_change', + 'last_notification' => 'host_last_notification', + 'last_check' => 'host_last_check', + 'next_check' => 'host_next_check', + 'check_execution_time' => 'host_check_execution_time', + 'check_latency' => 'host_check_latency', + 'output' => 'host_output', + 'long_output' => 'host_long_output', + 'check_command' => 'host_check_command', + 'perfdata' => 'host_perfdata', + 'host_icon_image', + 'passive_checks_enabled' => 'host_passive_checks_enabled', + 'obsessing' => 'host_obsessing', + 'notifications_enabled' => 'host_notifications_enabled', + 'event_handler_enabled' => 'host_event_handler_enabled', + 'flap_detection_enabled' => 'host_flap_detection_enabled', + 'active_checks_enabled' => 'host_active_checks_enabled', + 'current_check_attempt' => 'host_current_check_attempt', + 'max_check_attempts' => 'host_max_check_attempts', + 'last_notification' => 'host_last_notification', + 'current_notification_number' => 'host_current_notification_number', + 'percent_state_change' => 'host_percent_state_change', + 'is_flapping' => 'host_is_flapping', + 'last_comment' => 'host_last_comment', + 'action_url' => 'host_action_url', + 'notes_url' => 'host_notes_url', + 'percent_state_change' => 'host_percent_state_change' + ) + )->where('host_name', $this->name1)->fetchRow(); } } diff --git a/modules/monitoring/library/Monitoring/Object/Service.php b/modules/monitoring/library/Monitoring/Object/Service.php index 17e693acd..33cd4ff01 100644 --- a/modules/monitoring/library/Monitoring/Object/Service.php +++ b/modules/monitoring/library/Monitoring/Object/Service.php @@ -1,31 +1,82 @@ + * @license http://www.gnu.org/licenses/gpl-2.0.txt GPL, version 2 + * @author Icinga Development Team + */ +// {{{ICINGA_LICENSE_HEADER}}} namespace Icinga\Module\Monitoring\Object; use Icinga\Data\AbstractQuery as Query; +/** + * Represent a single service + */ class Service extends AbstractObject { + /** + * Foreign references to objects + * + * @var array + */ protected $foreign = array( 'servicegroups' => null, 'contacts' => null, 'contactgroups' => null, 'customvars' => null, 'comments' => null, - 'downtimes' => null + 'downtimes' => null, + 'customvars' => null ); + /** + * Statename + */ public function stateName() { // TODO } + /** + * Filter foreign object belongings + * + * @param Query $query + * + * @return Query + */ protected function applyObjectFilter(Query $query) { return $query->where('service_host_name', $this->name1) ->where('service_description', $this->name2); } + /** + * Collect foreign data + * + * @return self + */ public function prefetch() { return $this->fetchServicegroups() @@ -33,54 +84,63 @@ class Service extends AbstractObject ->fetchContactgroups() ->fetchCustomvars() ->fetchComments() - ->fetchDowtimes(); + ->fetchDowtimes() + ->fetchCustomvars(); } + /** + * Load object data + * + * @return object + */ protected function fetchObject() { - return $this->backend->select()->from('status', array( - 'host_name', - 'host_alias', - 'host_address', - 'host_state', - 'host_handled', - 'host_in_downtime', - 'host_acknowledged', - 'host_last_state_change', - 'service_description', - 'service_state', - 'service_handled', - 'service_acknowledged', - 'service_in_downtime', - 'service_last_state_change', - 'last_check' => 'service_last_check', - 'next_check' => 'service_next_check', - 'check_execution_time' => 'service_check_execution_time', - 'check_latency' => 'service_check_latency', - 'output' => 'service_output', - 'long_output' => 'service_long_output', - 'check_command' => 'service_check_command', - 'perfdata' => 'service_perfdata', - 'current_check_attempt' => 'service_current_check_attempt', - 'max_check_attempts' => 'service_max_check_attempts', - 'state_type' => 'service_state_type', - 'passive_checks_enabled' => 'service_passive_checks_enabled', - 'last_state_change' => 'service_last_state_change', - 'last_notification' => 'service_last_notification', - 'current_notification_number' => 'service_current_notification_number', - 'is_flapping' => 'service_is_flapping', - 'percent_state_change' => 'service_percent_state_change', - 'in_downtime' => 'service_in_downtime', - 'passive_checks_enabled' => 'service_passive_checks_enabled', - 'obsessing' => 'service_obsessing', - 'notifications_enabled' => 'service_notifications_enabled', - 'event_handler_enabled' => 'service_event_handler_enabled', - 'flap_detection_enabled' => 'service_flap_detection_enabled', - 'active_checks_enabled' => 'service_active_checks_enabled', - 'last_comment' => 'service_last_comment', - 'action_url' => 'service_action_url', - 'notes_url' => 'service_notes_url' - )) + return $this->backend->select()->from( + 'status', + array( + 'host_name', + 'host_alias', + 'host_address', + 'host_state', + 'host_handled', + 'host_in_downtime', + 'host_acknowledged', + 'host_last_state_change', + 'service_description', + 'service_state', + 'service_handled', + 'service_acknowledged', + 'service_in_downtime', + 'service_last_state_change', + 'last_check' => 'service_last_check', + 'next_check' => 'service_next_check', + 'check_execution_time' => 'service_check_execution_time', + 'check_latency' => 'service_check_latency', + 'output' => 'service_output', + 'long_output' => 'service_long_output', + 'check_command' => 'service_check_command', + 'perfdata' => 'service_perfdata', + 'current_check_attempt' => 'service_current_check_attempt', + 'max_check_attempts' => 'service_max_check_attempts', + 'state_type' => 'service_state_type', + 'passive_checks_enabled' => 'service_passive_checks_enabled', + 'last_state_change' => 'service_last_state_change', + 'last_notification' => 'service_last_notification', + 'current_notification_number' => 'service_current_notification_number', + 'is_flapping' => 'service_is_flapping', + 'percent_state_change' => 'service_percent_state_change', + 'in_downtime' => 'service_in_downtime', + 'passive_checks_enabled' => 'service_passive_checks_enabled', + 'obsessing' => 'service_obsessing', + 'notifications_enabled' => 'service_notifications_enabled', + 'event_handler_enabled' => 'service_event_handler_enabled', + 'flap_detection_enabled' => 'service_flap_detection_enabled', + 'active_checks_enabled' => 'service_active_checks_enabled', + 'last_comment' => 'service_last_comment', + 'action_url' => 'service_action_url', + 'notes_url' => 'service_notes_url' + ) + ) ->where('host_name', $this->name1) ->where('service_description', $this->name2) ->fetchRow();