From a0839ea0dae47f4021bad0fe5163efe2f5c1939a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jannis=20Mo=C3=9Fhammer?= Date: Mon, 22 Jul 2013 16:03:36 +0200 Subject: [PATCH 1/3] Add service detail view refs #4181 --- library/Icinga/Application/Logger.php | 21 + library/Icinga/Application/Web.php | 21 + .../Backend/LdapUserBackend.php | 21 + library/Icinga/Authentication/Credentials.php | 21 + library/Icinga/Authentication/Manager.php | 21 + library/Icinga/Authentication/PhpSession.php | 21 + library/Icinga/Authentication/Session.php | 21 + library/Icinga/Authentication/User.php | 21 + library/Icinga/Authentication/UserBackend.php | 21 + library/Icinga/Backend/AbstractBackend.php | 21 + library/Icinga/Backend/Criteria/Order.php | 21 + .../DataView/AbstractAccessorStrategy.php | 21 + .../Backend/DataView/ObjectRemappingView.php | 21 + library/Icinga/Backend/Query.php | 21 + library/Icinga/Backend/Statusdat.php | 21 + .../Statusdat/DataView/StatusdatHostView.php | 21 + .../DataView/StatusdatServiceView.php | 21 + .../Backend/Statusdat/GroupsummaryQuery.php | 21 + .../Statusdat/HostgroupsummaryQuery.php | 21 + .../Backend/Statusdat/HostlistQuery.php | 21 + library/Icinga/Backend/Statusdat/Query.php | 21 + .../Statusdat/ServicegroupsummaryQuery.php | 21 + .../Backend/Statusdat/ServicelistQuery.php | 21 + .../Icinga/Exception/ConfigurationError.php | 21 + .../Exception/MissingParameterException.php | 21 + .../Icinga/Exception/NotImplementedError.php | 21 + library/Icinga/Exception/ProgrammingError.php | 21 + .../Exception/SystemPermissionException.php | 21 + library/Icinga/Form/Builder.php | 21 + library/Icinga/Protocol/AbstractQuery.php | 21 + .../Protocol/Commandpipe/Acknowledgement.php | 21 + .../Protocol/Commandpipe/CommandPipe.php | 21 + .../Icinga/Protocol/Commandpipe/Comment.php | 21 + .../Icinga/Protocol/Commandpipe/Downtime.php | 21 + .../Exception/InvalidCommandException.php | 21 + .../Icinga/Protocol/Commandpipe/IComment.php | 21 + .../Protocol/Commandpipe/PropertyModifier.php | 21 + library/Icinga/Protocol/Ldap/Connection.php | 21 + library/Icinga/Protocol/Ldap/Exception.php | 21 + library/Icinga/Protocol/Ldap/LdapUtils.php | 21 + library/Icinga/Protocol/Ldap/Node.php | 21 + library/Icinga/Protocol/Ldap/Query.php | 21 + library/Icinga/Protocol/Ldap/Root.php | 21 + .../Statusdat/Exception/ParsingException.php | 21 + library/Icinga/Protocol/Statusdat/IReader.php | 21 + .../Protocol/Statusdat/ObjectContainer.php | 21 + library/Icinga/Protocol/Statusdat/Parser.php | 21 + library/Icinga/Protocol/Statusdat/Query.php | 21 + .../Protocol/Statusdat/Query/Expression.php | 21 + .../Icinga/Protocol/Statusdat/Query/Group.php | 21 + .../Protocol/Statusdat/Query/IQueryPart.php | 21 + library/Icinga/Protocol/Statusdat/Reader.php | 21 + .../Statusdat/RuntimeStateContainer.php | 21 + library/Icinga/Web/ActionController.php | 21 + library/Icinga/Web/Form.php | 21 + .../Hook/Configuration/ConfigurationTab.php | 21 + .../Configuration/ConfigurationTabBuilder.php | 21 + .../ConfigurationTabInterface.php | 21 + library/Icinga/Web/Hook/Grapher.php | 21 + library/Icinga/Web/Hook/Toptray.php | 21 + library/Icinga/Web/ModuleActionController.php | 21 + library/Icinga/Web/Notification.php | 21 + .../Web/Paginator/Adapter/QueryAdapter.php | 21 + .../ScrollingStyle/SlidingWithBorder.php | 21 + library/Icinga/Web/Widget.php | 21 + .../controllers/ShowController.php | 23 +- .../views/helpers/MonitoringCommands.php | 88 ++ .../views/helpers/MonitoringFlags.php | 56 ++ .../views/helpers/MonitoringProperties.php | 250 ++++++ .../scripts/show/components/comments.phtml | 4 +- .../scripts/show/components/downtime.phtml | 43 + .../views/scripts/show/components/flags.phtml | 25 + .../scripts/show/components/properties.phtml | 19 + .../views/scripts/show/header.phtml | 55 +- .../application/views/scripts/show/host.phtml | 33 +- .../views/scripts/show/service.phtml | 126 ++- .../Monitoring/Backend/AbstractBackend.php | 228 ++--- .../Backend/Ido/Query/DowntimeQuery.php | 98 ++ .../Backend/Ido/Query/StatusQuery.php | 129 ++- .../library/Monitoring/Command/Meta.php | 846 ++++++++++++++++++ .../library/Monitoring/View/DowntimeView.php | 76 ++ .../views/helpers/MonitoringCommandsTest.php | 116 +++ .../views/helpers/MonitoringFlagsTest.php | 116 +++ .../helpers/MonitoringPropertiesTest.php | 105 +++ .../test/php/library/Command/MetaTest.php | 185 ++++ 85 files changed, 3786 insertions(+), 200 deletions(-) create mode 100644 modules/monitoring/application/views/helpers/MonitoringCommands.php create mode 100644 modules/monitoring/application/views/helpers/MonitoringFlags.php create mode 100644 modules/monitoring/application/views/helpers/MonitoringProperties.php create mode 100644 modules/monitoring/application/views/scripts/show/components/downtime.phtml create mode 100644 modules/monitoring/application/views/scripts/show/components/flags.phtml create mode 100644 modules/monitoring/application/views/scripts/show/components/properties.phtml create mode 100644 modules/monitoring/library/Monitoring/Backend/Ido/Query/DowntimeQuery.php create mode 100644 modules/monitoring/library/Monitoring/Command/Meta.php create mode 100644 modules/monitoring/library/Monitoring/View/DowntimeView.php create mode 100644 modules/monitoring/test/php/application/views/helpers/MonitoringCommandsTest.php create mode 100644 modules/monitoring/test/php/application/views/helpers/MonitoringFlagsTest.php create mode 100644 modules/monitoring/test/php/application/views/helpers/MonitoringPropertiesTest.php create mode 100644 modules/monitoring/test/php/library/Command/MetaTest.php diff --git a/library/Icinga/Application/Logger.php b/library/Icinga/Application/Logger.php index fa3246a4c..f6976b6ac 100755 --- a/library/Icinga/Application/Logger.php +++ b/library/Icinga/Application/Logger.php @@ -1,5 +1,26 @@ + * @author Icinga Development Team + */ // {{{ICINGA_LICENSE_HEADER}}} namespace Icinga\Application; diff --git a/library/Icinga/Application/Web.php b/library/Icinga/Application/Web.php index 6b6aea625..b27c777f2 100644 --- a/library/Icinga/Application/Web.php +++ b/library/Icinga/Application/Web.php @@ -1,5 +1,26 @@ + * @author Icinga Development Team + */ // {{{ICINGA_LICENSE_HEADER}}} namespace Icinga\Application; diff --git a/library/Icinga/Authentication/Backend/LdapUserBackend.php b/library/Icinga/Authentication/Backend/LdapUserBackend.php index 674aa88a5..93b56b14b 100644 --- a/library/Icinga/Authentication/Backend/LdapUserBackend.php +++ b/library/Icinga/Authentication/Backend/LdapUserBackend.php @@ -1,5 +1,26 @@ + * @author Icinga Development Team + */ // {{{ICINGA_LICENSE_HEADER}}} namespace Icinga\Authentication\Backend; diff --git a/library/Icinga/Authentication/Credentials.php b/library/Icinga/Authentication/Credentials.php index fb0581ad7..42e8b19e7 100644 --- a/library/Icinga/Authentication/Credentials.php +++ b/library/Icinga/Authentication/Credentials.php @@ -1,5 +1,26 @@ + * @author Icinga Development Team + */ // {{{ICINGA_LICENSE_HEADER}}} namespace Icinga\Authentication; diff --git a/library/Icinga/Authentication/Manager.php b/library/Icinga/Authentication/Manager.php index 5a1acc29d..306cb4993 100644 --- a/library/Icinga/Authentication/Manager.php +++ b/library/Icinga/Authentication/Manager.php @@ -1,5 +1,26 @@ + * @author Icinga Development Team + */ // {{{ICINGA_LICENSE_HEADER}}} namespace Icinga\Authentication; diff --git a/library/Icinga/Authentication/PhpSession.php b/library/Icinga/Authentication/PhpSession.php index 66c83e38b..e0fa6d216 100644 --- a/library/Icinga/Authentication/PhpSession.php +++ b/library/Icinga/Authentication/PhpSession.php @@ -1,5 +1,26 @@ + * @author Icinga Development Team + */ // {{{ICINGA_LICENSE_HEADER}}} namespace Icinga\Authentication; diff --git a/library/Icinga/Authentication/Session.php b/library/Icinga/Authentication/Session.php index 2f1743fb2..305587678 100644 --- a/library/Icinga/Authentication/Session.php +++ b/library/Icinga/Authentication/Session.php @@ -1,5 +1,26 @@ + * @author Icinga Development Team + */ // {{{ICINGA_LICENSE_HEADER}}} namespace Icinga\Authentication; diff --git a/library/Icinga/Authentication/User.php b/library/Icinga/Authentication/User.php index 6571af33e..3c6db51dc 100644 --- a/library/Icinga/Authentication/User.php +++ b/library/Icinga/Authentication/User.php @@ -1,5 +1,26 @@ + * @author Icinga Development Team + */ // {{{ICINGA_LICENSE_HEADER}}} namespace Icinga\Authentication; diff --git a/library/Icinga/Authentication/UserBackend.php b/library/Icinga/Authentication/UserBackend.php index 104ecafb4..cbf79cc01 100644 --- a/library/Icinga/Authentication/UserBackend.php +++ b/library/Icinga/Authentication/UserBackend.php @@ -1,5 +1,26 @@ + * @author Icinga Development Team + */ // {{{ICINGA_LICENSE_HEADER}}}} namespace Icinga\Authentication; diff --git a/library/Icinga/Backend/AbstractBackend.php b/library/Icinga/Backend/AbstractBackend.php index 972bc2d72..db2dab664 100755 --- a/library/Icinga/Backend/AbstractBackend.php +++ b/library/Icinga/Backend/AbstractBackend.php @@ -1,5 +1,26 @@ + * @author Icinga Development Team + */ // {{{ICINGA_LICENSE_HEADER}}} namespace Icinga\Backend; diff --git a/library/Icinga/Backend/Criteria/Order.php b/library/Icinga/Backend/Criteria/Order.php index d26392d71..a7d72d76f 100755 --- a/library/Icinga/Backend/Criteria/Order.php +++ b/library/Icinga/Backend/Criteria/Order.php @@ -1,5 +1,26 @@ + * @author Icinga Development Team + */ // {{{ICINGA_LICENSE_HEADER}}} namespace Icinga\Backend\Criteria; diff --git a/library/Icinga/Backend/DataView/AbstractAccessorStrategy.php b/library/Icinga/Backend/DataView/AbstractAccessorStrategy.php index 058653705..ea6df0997 100755 --- a/library/Icinga/Backend/DataView/AbstractAccessorStrategy.php +++ b/library/Icinga/Backend/DataView/AbstractAccessorStrategy.php @@ -1,5 +1,26 @@ + * @author Icinga Development Team + */ // {{{ICINGA_LICENSE_HEADER}}} namespace Icinga\Backend\DataView; diff --git a/library/Icinga/Backend/DataView/ObjectRemappingView.php b/library/Icinga/Backend/DataView/ObjectRemappingView.php index 1f2338722..012f98d03 100755 --- a/library/Icinga/Backend/DataView/ObjectRemappingView.php +++ b/library/Icinga/Backend/DataView/ObjectRemappingView.php @@ -1,5 +1,26 @@ + * @author Icinga Development Team + */ // {{{ICINGA_LICENSE_HEADER}}} namespace Icinga\Backend\DataView; diff --git a/library/Icinga/Backend/Query.php b/library/Icinga/Backend/Query.php index 2062e1ff8..b3a5abf38 100755 --- a/library/Icinga/Backend/Query.php +++ b/library/Icinga/Backend/Query.php @@ -1,5 +1,26 @@ + * @author Icinga Development Team + */ // {{{ICINGA_LICENSE_HEADER}}} namespace Icinga\Backend; diff --git a/library/Icinga/Backend/Statusdat.php b/library/Icinga/Backend/Statusdat.php index 75f09a93c..935078767 100755 --- a/library/Icinga/Backend/Statusdat.php +++ b/library/Icinga/Backend/Statusdat.php @@ -1,5 +1,26 @@ + * @author Icinga Development Team + */ // {{{ICINGA_LICENSE_HEADER}}} namespace Icinga\Backend; diff --git a/library/Icinga/Backend/Statusdat/DataView/StatusdatHostView.php b/library/Icinga/Backend/Statusdat/DataView/StatusdatHostView.php index 6cfe2c674..61b58cd73 100644 --- a/library/Icinga/Backend/Statusdat/DataView/StatusdatHostView.php +++ b/library/Icinga/Backend/Statusdat/DataView/StatusdatHostView.php @@ -1,5 +1,26 @@ + * @author Icinga Development Team + */ // {{{ICINGA_LICENSE_HEADER}}} namespace Icinga\Backend\Statusdat\DataView; diff --git a/library/Icinga/Backend/Statusdat/DataView/StatusdatServiceView.php b/library/Icinga/Backend/Statusdat/DataView/StatusdatServiceView.php index fd55d21a5..8524212f3 100755 --- a/library/Icinga/Backend/Statusdat/DataView/StatusdatServiceView.php +++ b/library/Icinga/Backend/Statusdat/DataView/StatusdatServiceView.php @@ -1,5 +1,26 @@ + * @author Icinga Development Team + */ // {{{ICINGA_LICENSE_HEADER}}} namespace Icinga\Backend\Statusdat\DataView; diff --git a/library/Icinga/Backend/Statusdat/GroupsummaryQuery.php b/library/Icinga/Backend/Statusdat/GroupsummaryQuery.php index 335677f3d..51fb9f09e 100755 --- a/library/Icinga/Backend/Statusdat/GroupsummaryQuery.php +++ b/library/Icinga/Backend/Statusdat/GroupsummaryQuery.php @@ -1,5 +1,26 @@ + * @author Icinga Development Team + */ // {{{ICINGA_LICENSE_HEADER}}} namespace Icinga\Backend\Statusdat; diff --git a/library/Icinga/Backend/Statusdat/HostgroupsummaryQuery.php b/library/Icinga/Backend/Statusdat/HostgroupsummaryQuery.php index 219011a9a..fc3f7b356 100755 --- a/library/Icinga/Backend/Statusdat/HostgroupsummaryQuery.php +++ b/library/Icinga/Backend/Statusdat/HostgroupsummaryQuery.php @@ -1,5 +1,26 @@ + * @author Icinga Development Team + */ // {{{ICINGA_LICENSE_HEADER}}} namespace Icinga\Backend\Statusdat; diff --git a/library/Icinga/Backend/Statusdat/HostlistQuery.php b/library/Icinga/Backend/Statusdat/HostlistQuery.php index 1fa025ed6..f5cbe8184 100755 --- a/library/Icinga/Backend/Statusdat/HostlistQuery.php +++ b/library/Icinga/Backend/Statusdat/HostlistQuery.php @@ -1,5 +1,26 @@ + * @author Icinga Development Team + */ // {{{ICINGA_LICENSE_HEADER}}} namespace Icinga\Backend\Statusdat; diff --git a/library/Icinga/Backend/Statusdat/Query.php b/library/Icinga/Backend/Statusdat/Query.php index 00b9ae89f..f23e189d6 100644 --- a/library/Icinga/Backend/Statusdat/Query.php +++ b/library/Icinga/Backend/Statusdat/Query.php @@ -1,5 +1,26 @@ + * @author Icinga Development Team + */ // {{{ICINGA_LICENSE_HEADER}}} namespace Icinga\Backend\Statusdat; diff --git a/library/Icinga/Backend/Statusdat/ServicegroupsummaryQuery.php b/library/Icinga/Backend/Statusdat/ServicegroupsummaryQuery.php index 4d01b560d..d78f973dc 100644 --- a/library/Icinga/Backend/Statusdat/ServicegroupsummaryQuery.php +++ b/library/Icinga/Backend/Statusdat/ServicegroupsummaryQuery.php @@ -1,5 +1,26 @@ + * @author Icinga Development Team + */ // {{{ICINGA_LICENSE_HEADER}}} namespace Icinga\Backend\Statusdat; diff --git a/library/Icinga/Backend/Statusdat/ServicelistQuery.php b/library/Icinga/Backend/Statusdat/ServicelistQuery.php index 550fcfc22..416e193dd 100755 --- a/library/Icinga/Backend/Statusdat/ServicelistQuery.php +++ b/library/Icinga/Backend/Statusdat/ServicelistQuery.php @@ -1,5 +1,26 @@ + * @author Icinga Development Team + */ // {{{ICINGA_LICENSE_HEADER}}} namespace Icinga\Backend\Statusdat; diff --git a/library/Icinga/Exception/ConfigurationError.php b/library/Icinga/Exception/ConfigurationError.php index 988246f5f..434068009 100644 --- a/library/Icinga/Exception/ConfigurationError.php +++ b/library/Icinga/Exception/ConfigurationError.php @@ -1,5 +1,26 @@ + * @author Icinga Development Team + */ // {{{ICINGA_LICENSE_HEADER}}} namespace Icinga\Exception; diff --git a/library/Icinga/Exception/MissingParameterException.php b/library/Icinga/Exception/MissingParameterException.php index dda47aeab..de74db6e3 100644 --- a/library/Icinga/Exception/MissingParameterException.php +++ b/library/Icinga/Exception/MissingParameterException.php @@ -1,5 +1,26 @@ + * @author Icinga Development Team + */ // {{{ICINGA_LICENSE_HEADER}}} namespace Icinga\Exception; diff --git a/library/Icinga/Exception/NotImplementedError.php b/library/Icinga/Exception/NotImplementedError.php index 01131275d..7f85669f8 100644 --- a/library/Icinga/Exception/NotImplementedError.php +++ b/library/Icinga/Exception/NotImplementedError.php @@ -1,5 +1,26 @@ + * @author Icinga Development Team + */ // {{{ICINGA_LICENSE_HEADER}}} namespace Icinga\Exception; diff --git a/library/Icinga/Exception/ProgrammingError.php b/library/Icinga/Exception/ProgrammingError.php index 282d80db0..2d77f7511 100644 --- a/library/Icinga/Exception/ProgrammingError.php +++ b/library/Icinga/Exception/ProgrammingError.php @@ -1,5 +1,26 @@ + * @author Icinga Development Team + */ // {{{ICINGA_LICENSE_HEADER}}} namespace Icinga\Exception; diff --git a/library/Icinga/Exception/SystemPermissionException.php b/library/Icinga/Exception/SystemPermissionException.php index 02849ec34..01711cba5 100644 --- a/library/Icinga/Exception/SystemPermissionException.php +++ b/library/Icinga/Exception/SystemPermissionException.php @@ -1,5 +1,26 @@ + * @author Icinga Development Team + */ // {{{ICINGA_LICENSE_HEADER}}} namespace Icinga\Exception; diff --git a/library/Icinga/Form/Builder.php b/library/Icinga/Form/Builder.php index cc2b08591..89d2bccfb 100644 --- a/library/Icinga/Form/Builder.php +++ b/library/Icinga/Form/Builder.php @@ -1,5 +1,26 @@ + * @author Icinga Development Team + */ // {{{ICINGA_LICENSE_HEADER}}} namespace Icinga\Form; diff --git a/library/Icinga/Protocol/AbstractQuery.php b/library/Icinga/Protocol/AbstractQuery.php index 95b336496..b326b9c12 100755 --- a/library/Icinga/Protocol/AbstractQuery.php +++ b/library/Icinga/Protocol/AbstractQuery.php @@ -1,5 +1,26 @@ + * @author Icinga Development Team + */ // {{{ICINGA_LICENSE_HEADER}}} namespace Icinga\Protocol; diff --git a/library/Icinga/Protocol/Commandpipe/Acknowledgement.php b/library/Icinga/Protocol/Commandpipe/Acknowledgement.php index f293c5470..e4e94553c 100644 --- a/library/Icinga/Protocol/Commandpipe/Acknowledgement.php +++ b/library/Icinga/Protocol/Commandpipe/Acknowledgement.php @@ -1,5 +1,26 @@ + * @author Icinga Development Team + */ // {{{ICINGA_LICENSE_HEADER}}} namespace Icinga\Protocol\Commandpipe; diff --git a/library/Icinga/Protocol/Commandpipe/CommandPipe.php b/library/Icinga/Protocol/Commandpipe/CommandPipe.php index b48c5f16a..a89757ad5 100644 --- a/library/Icinga/Protocol/Commandpipe/CommandPipe.php +++ b/library/Icinga/Protocol/Commandpipe/CommandPipe.php @@ -1,5 +1,26 @@ + * @author Icinga Development Team + */ // {{{ICINGA_LICENSE_HEADER}}} namespace Icinga\Protocol\Commandpipe; diff --git a/library/Icinga/Protocol/Commandpipe/Comment.php b/library/Icinga/Protocol/Commandpipe/Comment.php index 4b8466fb5..6e4333a3f 100644 --- a/library/Icinga/Protocol/Commandpipe/Comment.php +++ b/library/Icinga/Protocol/Commandpipe/Comment.php @@ -1,5 +1,26 @@ + * @author Icinga Development Team + */ // {{{ICINGA_LICENSE_HEADER}}} namespace Icinga\Protocol\Commandpipe; diff --git a/library/Icinga/Protocol/Commandpipe/Downtime.php b/library/Icinga/Protocol/Commandpipe/Downtime.php index 11919041b..bb0f5629b 100644 --- a/library/Icinga/Protocol/Commandpipe/Downtime.php +++ b/library/Icinga/Protocol/Commandpipe/Downtime.php @@ -1,5 +1,26 @@ + * @author Icinga Development Team + */ // {{{ICINGA_LICENSE_HEADER}}} namespace Icinga\Protocol\Commandpipe; diff --git a/library/Icinga/Protocol/Commandpipe/Exception/InvalidCommandException.php b/library/Icinga/Protocol/Commandpipe/Exception/InvalidCommandException.php index 8d005f4ed..6017115fb 100644 --- a/library/Icinga/Protocol/Commandpipe/Exception/InvalidCommandException.php +++ b/library/Icinga/Protocol/Commandpipe/Exception/InvalidCommandException.php @@ -1,5 +1,26 @@ + * @author Icinga Development Team + */ // {{{ICINGA_LICENSE_HEADER}}} namespace Icinga\Protocol\Commandpipe\Exception; diff --git a/library/Icinga/Protocol/Commandpipe/IComment.php b/library/Icinga/Protocol/Commandpipe/IComment.php index aa6636868..bc8f068e2 100644 --- a/library/Icinga/Protocol/Commandpipe/IComment.php +++ b/library/Icinga/Protocol/Commandpipe/IComment.php @@ -1,5 +1,26 @@ + * @author Icinga Development Team + */ // {{{ICINGA_LICENSE_HEADER}}} namespace Icinga\Protocol\Commandpipe; diff --git a/library/Icinga/Protocol/Commandpipe/PropertyModifier.php b/library/Icinga/Protocol/Commandpipe/PropertyModifier.php index c7019a740..dbc7e5af0 100644 --- a/library/Icinga/Protocol/Commandpipe/PropertyModifier.php +++ b/library/Icinga/Protocol/Commandpipe/PropertyModifier.php @@ -1,5 +1,26 @@ + * @author Icinga Development Team + */ // {{{ICINGA_LICENSE_HEADER}}} namespace Icinga\Protocol\Commandpipe; diff --git a/library/Icinga/Protocol/Ldap/Connection.php b/library/Icinga/Protocol/Ldap/Connection.php index 403bfd665..fbf7883fc 100644 --- a/library/Icinga/Protocol/Ldap/Connection.php +++ b/library/Icinga/Protocol/Ldap/Connection.php @@ -1,5 +1,26 @@ + * @author Icinga Development Team + */ // {{{ICINGA_LICENSE_HEADER}}} namespace Icinga\Protocol\Ldap; diff --git a/library/Icinga/Protocol/Ldap/Exception.php b/library/Icinga/Protocol/Ldap/Exception.php index 41a5b782b..9474b06eb 100644 --- a/library/Icinga/Protocol/Ldap/Exception.php +++ b/library/Icinga/Protocol/Ldap/Exception.php @@ -1,5 +1,26 @@ + * @author Icinga Development Team + */ // {{{ICINGA_LICENSE_HEADER}}} namespace Icinga\Protocol\Ldap; diff --git a/library/Icinga/Protocol/Ldap/LdapUtils.php b/library/Icinga/Protocol/Ldap/LdapUtils.php index 8232ebf67..fa7752228 100644 --- a/library/Icinga/Protocol/Ldap/LdapUtils.php +++ b/library/Icinga/Protocol/Ldap/LdapUtils.php @@ -1,5 +1,26 @@ + * @author Icinga Development Team + */ // {{{ICINGA_LICENSE_HEADER}}} namespace Icinga\Protocol\Ldap; diff --git a/library/Icinga/Protocol/Ldap/Node.php b/library/Icinga/Protocol/Ldap/Node.php index ecff98c0b..2237292f4 100644 --- a/library/Icinga/Protocol/Ldap/Node.php +++ b/library/Icinga/Protocol/Ldap/Node.php @@ -1,5 +1,26 @@ + * @author Icinga Development Team + */ // {{{ICINGA_LICENSE_HEADER}}} namespace Icinga\Protocol\Ldap; diff --git a/library/Icinga/Protocol/Ldap/Query.php b/library/Icinga/Protocol/Ldap/Query.php index 630f1041d..083a680ca 100644 --- a/library/Icinga/Protocol/Ldap/Query.php +++ b/library/Icinga/Protocol/Ldap/Query.php @@ -1,5 +1,26 @@ + * @author Icinga Development Team + */ // {{{ICINGA_LICENSE_HEADER}}} namespace Icinga\Protocol\Ldap; diff --git a/library/Icinga/Protocol/Ldap/Root.php b/library/Icinga/Protocol/Ldap/Root.php index 64b098776..46b80d598 100644 --- a/library/Icinga/Protocol/Ldap/Root.php +++ b/library/Icinga/Protocol/Ldap/Root.php @@ -1,5 +1,26 @@ + * @author Icinga Development Team + */ // {{{ICINGA_LICENSE_HEADER}}} namespace Icinga\Protocol\Ldap; diff --git a/library/Icinga/Protocol/Statusdat/Exception/ParsingException.php b/library/Icinga/Protocol/Statusdat/Exception/ParsingException.php index 0947e65bc..5eefee284 100755 --- a/library/Icinga/Protocol/Statusdat/Exception/ParsingException.php +++ b/library/Icinga/Protocol/Statusdat/Exception/ParsingException.php @@ -1,5 +1,26 @@ + * @author Icinga Development Team + */ // {{{ICINGA_LICENSE_HEADER}}} namespace Icinga\Protocol\Statusdat\Exception; diff --git a/library/Icinga/Protocol/Statusdat/IReader.php b/library/Icinga/Protocol/Statusdat/IReader.php index 1ce7a02a8..e837edbc2 100755 --- a/library/Icinga/Protocol/Statusdat/IReader.php +++ b/library/Icinga/Protocol/Statusdat/IReader.php @@ -1,5 +1,26 @@ + * @author Icinga Development Team + */ // {{{ICINGA_LICENSE_HEADER}}} namespace Icinga\Protocol\Statusdat; diff --git a/library/Icinga/Protocol/Statusdat/ObjectContainer.php b/library/Icinga/Protocol/Statusdat/ObjectContainer.php index fd40de940..82f72c70b 100644 --- a/library/Icinga/Protocol/Statusdat/ObjectContainer.php +++ b/library/Icinga/Protocol/Statusdat/ObjectContainer.php @@ -1,5 +1,26 @@ + * @author Icinga Development Team + */ // {{{ICINGA_LICENSE_HEADER}}} namespace Icinga\Protocol\Statusdat; diff --git a/library/Icinga/Protocol/Statusdat/Parser.php b/library/Icinga/Protocol/Statusdat/Parser.php index a0636d241..90bc64cb0 100755 --- a/library/Icinga/Protocol/Statusdat/Parser.php +++ b/library/Icinga/Protocol/Statusdat/Parser.php @@ -1,5 +1,26 @@ + * @author Icinga Development Team + */ // {{{ICINGA_LICENSE_HEADER}}} namespace Icinga\Protocol\Statusdat; diff --git a/library/Icinga/Protocol/Statusdat/Query.php b/library/Icinga/Protocol/Statusdat/Query.php index 26604f3b8..108141468 100755 --- a/library/Icinga/Protocol/Statusdat/Query.php +++ b/library/Icinga/Protocol/Statusdat/Query.php @@ -1,5 +1,26 @@ + * @author Icinga Development Team + */ // {{{ICINGA_LICENSE_HEADER}}} namespace Icinga\Protocol\Statusdat; diff --git a/library/Icinga/Protocol/Statusdat/Query/Expression.php b/library/Icinga/Protocol/Statusdat/Query/Expression.php index c4cdb17e3..da722e28a 100755 --- a/library/Icinga/Protocol/Statusdat/Query/Expression.php +++ b/library/Icinga/Protocol/Statusdat/Query/Expression.php @@ -1,5 +1,26 @@ + * @author Icinga Development Team + */ // {{{ICINGA_LICENSE_HEADER}}} namespace Icinga\Protocol\Statusdat\Query; diff --git a/library/Icinga/Protocol/Statusdat/Query/Group.php b/library/Icinga/Protocol/Statusdat/Query/Group.php index ae29b9ddf..79a748487 100755 --- a/library/Icinga/Protocol/Statusdat/Query/Group.php +++ b/library/Icinga/Protocol/Statusdat/Query/Group.php @@ -1,5 +1,26 @@ + * @author Icinga Development Team + */ // {{{ICINGA_LICENSE_HEADER}}} namespace Icinga\Protocol\Statusdat\Query; diff --git a/library/Icinga/Protocol/Statusdat/Query/IQueryPart.php b/library/Icinga/Protocol/Statusdat/Query/IQueryPart.php index 852a7362e..4d543a3f9 100755 --- a/library/Icinga/Protocol/Statusdat/Query/IQueryPart.php +++ b/library/Icinga/Protocol/Statusdat/Query/IQueryPart.php @@ -1,5 +1,26 @@ + * @author Icinga Development Team + */ // {{{ICINGA_LICENSE_HEADER}}} namespace Icinga\Protocol\Statusdat\Query; diff --git a/library/Icinga/Protocol/Statusdat/Reader.php b/library/Icinga/Protocol/Statusdat/Reader.php index 199919071..d0076b45b 100755 --- a/library/Icinga/Protocol/Statusdat/Reader.php +++ b/library/Icinga/Protocol/Statusdat/Reader.php @@ -1,5 +1,26 @@ + * @author Icinga Development Team + */ // {{{ICINGA_LICENSE_HEADER}}} namespace Icinga\Protocol\Statusdat; diff --git a/library/Icinga/Protocol/Statusdat/RuntimeStateContainer.php b/library/Icinga/Protocol/Statusdat/RuntimeStateContainer.php index 96b7bfa13..878bc4c59 100755 --- a/library/Icinga/Protocol/Statusdat/RuntimeStateContainer.php +++ b/library/Icinga/Protocol/Statusdat/RuntimeStateContainer.php @@ -1,5 +1,26 @@ + * @author Icinga Development Team + */ // {{{ICINGA_LICENSE_HEADER}}} namespace Icinga\Protocol\Statusdat; diff --git a/library/Icinga/Web/ActionController.php b/library/Icinga/Web/ActionController.php index 4d8c02fbe..ebefc8acf 100755 --- a/library/Icinga/Web/ActionController.php +++ b/library/Icinga/Web/ActionController.php @@ -1,5 +1,26 @@ + * @author Icinga Development Team + */ // {{{ICINGA_LICENSE_HEADER}}} namespace Icinga\Web; diff --git a/library/Icinga/Web/Form.php b/library/Icinga/Web/Form.php index 5361a1868..d4caa39c0 100644 --- a/library/Icinga/Web/Form.php +++ b/library/Icinga/Web/Form.php @@ -1,5 +1,26 @@ + * @author Icinga Development Team + */ // {{{ICINGA_LICENSE_HEADER}}} namespace Icinga\Web; diff --git a/library/Icinga/Web/Hook/Configuration/ConfigurationTab.php b/library/Icinga/Web/Hook/Configuration/ConfigurationTab.php index fe6a17428..3188d7d8c 100644 --- a/library/Icinga/Web/Hook/Configuration/ConfigurationTab.php +++ b/library/Icinga/Web/Hook/Configuration/ConfigurationTab.php @@ -1,5 +1,26 @@ + * @author Icinga Development Team + */ // {{{ICINGA_LICENSE_HEADER}}} namespace Icinga\Web\Hook\Configuration; diff --git a/library/Icinga/Web/Hook/Configuration/ConfigurationTabBuilder.php b/library/Icinga/Web/Hook/Configuration/ConfigurationTabBuilder.php index ba7bee670..47ead0147 100644 --- a/library/Icinga/Web/Hook/Configuration/ConfigurationTabBuilder.php +++ b/library/Icinga/Web/Hook/Configuration/ConfigurationTabBuilder.php @@ -1,5 +1,26 @@ + * @author Icinga Development Team + */ // {{{ICINGA_LICENSE_HEADER}}} namespace Icinga\Web\Hook\Configuration; diff --git a/library/Icinga/Web/Hook/Configuration/ConfigurationTabInterface.php b/library/Icinga/Web/Hook/Configuration/ConfigurationTabInterface.php index 064bd8450..667dd9c3d 100644 --- a/library/Icinga/Web/Hook/Configuration/ConfigurationTabInterface.php +++ b/library/Icinga/Web/Hook/Configuration/ConfigurationTabInterface.php @@ -1,5 +1,26 @@ + * @author Icinga Development Team + */ // {{{ICINGA_LICENSE_HEADER}}} namespace Icinga\Web\Hook\Configuration; diff --git a/library/Icinga/Web/Hook/Grapher.php b/library/Icinga/Web/Hook/Grapher.php index 28de49604..5c860f7a3 100644 --- a/library/Icinga/Web/Hook/Grapher.php +++ b/library/Icinga/Web/Hook/Grapher.php @@ -1,5 +1,26 @@ + * @author Icinga Development Team + */ // {{{ICINGA_LICENSE_HEADER}}} namespace Icinga\Web\Hook; diff --git a/library/Icinga/Web/Hook/Toptray.php b/library/Icinga/Web/Hook/Toptray.php index f2753db44..028339844 100755 --- a/library/Icinga/Web/Hook/Toptray.php +++ b/library/Icinga/Web/Hook/Toptray.php @@ -1,5 +1,26 @@ + * @author Icinga Development Team + */ // {{{ICINGA_LICENSE_HEADER}}} namespace Icinga\Web\Hook; diff --git a/library/Icinga/Web/ModuleActionController.php b/library/Icinga/Web/ModuleActionController.php index 76aa9fe8a..f5eb62e90 100644 --- a/library/Icinga/Web/ModuleActionController.php +++ b/library/Icinga/Web/ModuleActionController.php @@ -1,5 +1,26 @@ + * @author Icinga Development Team + */ // {{{ICINGA_LICENSE_HEADER}}} namespace Icinga\Web; diff --git a/library/Icinga/Web/Notification.php b/library/Icinga/Web/Notification.php index c99713c7a..1b5a975e6 100644 --- a/library/Icinga/Web/Notification.php +++ b/library/Icinga/Web/Notification.php @@ -1,5 +1,26 @@ + * @author Icinga Development Team + */ // {{{ICINGA_LICENSE_HEADER}}} namespace Icinga\Web; diff --git a/library/Icinga/Web/Paginator/Adapter/QueryAdapter.php b/library/Icinga/Web/Paginator/Adapter/QueryAdapter.php index d781cd4b2..01504fafd 100755 --- a/library/Icinga/Web/Paginator/Adapter/QueryAdapter.php +++ b/library/Icinga/Web/Paginator/Adapter/QueryAdapter.php @@ -1,5 +1,26 @@ + * @author Icinga Development Team + */ // {{{ICINGA_LICENSE_HEADER}}} namespace Icinga\Web\Paginator\Adapter; diff --git a/library/Icinga/Web/Paginator/ScrollingStyle/SlidingWithBorder.php b/library/Icinga/Web/Paginator/ScrollingStyle/SlidingWithBorder.php index f929eb60c..a1590c818 100755 --- a/library/Icinga/Web/Paginator/ScrollingStyle/SlidingWithBorder.php +++ b/library/Icinga/Web/Paginator/ScrollingStyle/SlidingWithBorder.php @@ -2,6 +2,27 @@ // @codingStandardsIgnoreStart // {{{ICINGA_LICENSE_HEADER}}} +/** + * Icinga 2 Web - Head for multiple monitoring frontends + * Copyright (C) 2013 Icinga Development Team + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + * @copyright 2013 Icinga Development Team + * @author Icinga Development Team + */ // {{{ICINGA_LICENSE_HEADER}}} /** diff --git a/library/Icinga/Web/Widget.php b/library/Icinga/Web/Widget.php index 8d8f3d5a2..8552f4396 100644 --- a/library/Icinga/Web/Widget.php +++ b/library/Icinga/Web/Widget.php @@ -1,5 +1,26 @@ + * @author Icinga Development Team + */ // {{{ICINGA_LICENSE_HEADER}}} namespace Icinga\Web; diff --git a/modules/monitoring/application/controllers/ShowController.php b/modules/monitoring/application/controllers/ShowController.php index f13761832..aab3ccb0e 100644 --- a/modules/monitoring/application/controllers/ShowController.php +++ b/modules/monitoring/application/controllers/ShowController.php @@ -36,7 +36,7 @@ class Monitoring_ShowController extends ModuleActionController $this->backend = Backend::getInstance($this->_getParam('backend')); if ($service !== null && $service !== '*') { - $this->view->service = $this->backend->fetchService($host, $service); + $this->view->service = $this->backend->fetchService($host, $service, true); } if ($host !== null) { $this->view->host = $this->backend->fetchHost($host, true); @@ -210,6 +210,27 @@ class Monitoring_ShowController extends ModuleActionController ->where('host_name', $this->view->host->host_name) ->fetchAll(); + $this->view->downtimes = $this->backend->select() + ->from( + 'downtime', + array( + 'host_name', + 'downtime_type', + 'downtime_author_name', + 'downtime_comment_data', + 'downtime_is_fixed', + 'downtime_duration', + 'downtime_scheduled_start_time', + 'downtime_scheduled_end_time', + 'downtime_actual_start_time', + 'downtime_was_started', + 'downtime_is_in_effect', + 'downtime_internal_downtime_id' + ) + ) + ->where('host_name', $this->view->host->host_name) + ->fetchAll(); + $this->view->customvars = $this->backend->select() ->from( 'customvar', diff --git a/modules/monitoring/application/views/helpers/MonitoringCommands.php b/modules/monitoring/application/views/helpers/MonitoringCommands.php new file mode 100644 index 000000000..6a1a9b57b --- /dev/null +++ b/modules/monitoring/application/views/helpers/MonitoringCommands.php @@ -0,0 +1,88 @@ + + * @author Icinga Development Team + */ +// {{{ICINGA_LICENSE_HEADER}}} + +use Icinga\Monitoring\Command\Meta; + +/** + * Class MonitoringCommands + * + * Helper which produces a list of command buttons + * depending on object states + */ +class Zend_View_Helper_MonitoringCommands extends Zend_View_Helper_Abstract +{ + /** + * @param stdClass $object host or service object or something other + * @param string $type small or full + * @return string html output + */ + public function monitoringCommands(\stdClass $object, $type) + { + $commands = new Meta(); + $definitions = $commands->getCommandForObject($object, $type); + $out = '
'; + $i = 0; + + foreach ($definitions as $definition) { + + if ($i % 5 === 0) { + $out .= '
'; + } + + if ($type === Meta::TYPE_FULL) { + $out .= '
'; + } + + $out .= sprintf( + '', + $definition->id, + $definition->shortDescription, + $definition->longDescription, + $definition->iconCls, + $definition->btnCls + ); + + if ($type === Meta::TYPE_FULL) { + $out .= '
'; + } + + $i++; + } + + $out .= '
'; + + $out .= '
'; + + if ($type === Meta::TYPE_FULL) { + return '
'. $out. '
'; + } + + return $out; + } +} diff --git a/modules/monitoring/application/views/helpers/MonitoringFlags.php b/modules/monitoring/application/views/helpers/MonitoringFlags.php new file mode 100644 index 000000000..13064e568 --- /dev/null +++ b/modules/monitoring/application/views/helpers/MonitoringFlags.php @@ -0,0 +1,56 @@ + 'Passive checks', + 'active_checks_enabled' => 'Active checks', + 'obsess_over_host' => 'Obsessing', + 'notifications_enabled' => 'Notifications', + 'event_handler_enabled' => 'Event handler', + 'flap_detection_enabled' => 'Flap detection', + ); + + /** + * Type prefix + * @param array $vars + * @return string + */ + private function getObjectType(array $vars) + { + return array_shift(explode('_', array_shift(array_keys($vars)), 2)); + } + + /** + * Build all existing flags to a readable array + * @param stdClass $object + * @return array + */ + public function monitoringFlags(\stdClass $object) + { + $vars = (array)$object; + $type = $this->getObjectType($vars); + $out = array(); + + foreach (self::$keys as $key => $name) { + $value = false; + if (array_key_exists(($realKey = $type. '_'. $key), $vars)) { + $value = $vars[$realKey] === '1' ? true : false; + } + $out[$name] = $value; + } + + return $out; + } +} \ No newline at end of file diff --git a/modules/monitoring/application/views/helpers/MonitoringProperties.php b/modules/monitoring/application/views/helpers/MonitoringProperties.php new file mode 100644 index 000000000..13c7a52c5 --- /dev/null +++ b/modules/monitoring/application/views/helpers/MonitoringProperties.php @@ -0,0 +1,250 @@ + 'Current attempt', + 'last_check' => 'Last check time', + 'buildCheckType' => 'Check type', + 'buildLatency' => 'Check latency / duration', + 'buildNextCheck' => 'Next scheduled active check', + 'buildLastStateChange' => 'Last state change', + 'buildLastNotification' => 'Last notification', + 'buildFlapping' => 'Is this %s flapping?', + 'buildScheduledDowntime' => 'In scheduled downtime?', + 'status_update_time' => 'Last update' + ); + + /** + * Return the object type + * @param stdClass $object + * @return mixed + */ + private function getObjectType(\stdClass $object) + { + return array_shift(explode('_', array_shift(array_keys(get_object_vars($object))), 2)); + } + + /** + * Drop all object specific attribute prefixes + * @param stdClass $object + * @param $type + * @return object + */ + private function dropObjectType(\stdClass $object, $type) + { + $vars = get_object_vars($object); + $out = array(); + foreach ($vars as $name => $value) { + $name = str_replace($type. '_', '', $name); + $out[$name] = $value; + } + return (object)$out; + } + + /** + * Get string for attempt + * @param stdClass $object + * @return string + */ + private function buildAttempt(\stdClass $object) + { + return sprintf( + '%s/%s (%s state)', + $object->current_check_attempt, + $object->max_check_attempts, + ($object->state_type === '1') ? 'HARD' : 'SOFT' + ); + } + + /** + * Generic fomatter for float values + * @param $value + * @return string + */ + private function floatFormatter($value) + { + return sprintf('%.4f', $value); + } + + /** + * Get the string for check type + * @param stdClass $object + * @return string + */ + private function buildCheckType(\stdClass $object) + { + if ($object->passive_checks_enabled === '1' && $object->active_checks_enabled === '0') { + return self::CHECK_PASSIVE; + } elseif ($object->passive_checks_enabled === '0' && $object->active_checks_enabled === '0') { + return self::CHECK_DISABLED; + } + + return self::CHECK_ACTIVE; + } + + /** + * Get string for latency + * @param stdClass $object + * @return string + */ + private function buildLatency(\stdClass $object) + { + $val = ''; + + if ($this->buildCheckType($object) === self::CHECK_PASSIVE) { + $val .= self::VALUE_NA; + } else { + $val .= $this->floatFormatter($object->latency); + } + + $val .= ' / '. $this->floatFormatter($object->execution_time). ' seconds'; + + return $val; + } + + /** + * Get string for next check + * @param stdClass $object + * @return string + */ + private function buildNextCheck(\stdClass $object) + { + if ($this->buildCheckType($object) === self::CHECK_PASSIVE) { + return self::VALUE_NA; + } else { + return $object->next_check; + } + } + + /** + * Get date for last state change + * @param stdClass $object + * @return string + */ + private function buildLastStateChange(\stdClass $object) + { + return strftime('%Y-%m-%d %H:%M:%S', $object->last_state_change); + } + + /** + * Get string for "last notification" + * @param stdClass $object + * @return string + */ + private function buildLastNotification(\stdClass $object) + { + $val = ''; + + if ($object->last_notification === '0000-00-00 00:00:00') { + $val .= self::VALUE_NA; + } else { + $val .= $object->last_notification; + } + + $val .= sprintf(' (notification %d)', $object->current_notification_number); + + return $val; + } + + /** + * Get string for "is flapping" + * @param stdClass $object + * @return string + */ + private function buildFlapping(\stdClass $object) + { + $val = ''; + + if ($object->is_flapping === '0') { + $val .= self::VALUE_NO; + } else { + $val .= self::VALUE_YES; + } + + $val .= sprintf(' (%.2f%% state change)', $object->percent_state_change); + + return $val; + } + + /** + * Get string for scheduled downtime + * @param stdClass $object + * @return string + */ + private function buildScheduledDowntime(\stdClass $object) + { + if ($object->in_downtime === '1') { + return self::VALUE_YES; + } + + return self::VALUE_NO; + } + + /** + * Get an array which represent monitoring properties + * + * @param stdClass $object + * @return array + */ + public function monitoringProperties(\stdClass $object) + { + $type = $this->getObjectType($object); + $object = $this->dropObjectType($object, $type); + + $out = array(); + + foreach (self::$keys as $property => $label) { + $label = sprintf($label, $type); + if (is_callable(array(&$this, $property))) { + $out[$label] = $this->$property($object); + } elseif (isset($object->{$property})) { + $out[$label] = $object->{$property}; + } + } + + return $out; + } +} diff --git a/modules/monitoring/application/views/scripts/show/components/comments.phtml b/modules/monitoring/application/views/scripts/show/components/comments.phtml index b641985ee..2273fcaee 100644 --- a/modules/monitoring/application/views/scripts/show/components/comments.phtml +++ b/modules/monitoring/application/views/scripts/show/components/comments.phtml @@ -1,5 +1,5 @@ -comments)): ?> +comments)) { ?> comments as $comment) { @@ -28,4 +28,4 @@ foreach ($this->comments as $comment) {
', $list) ?>
- + \ 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 new file mode 100644 index 000000000..cb2effe0b --- /dev/null +++ b/modules/monitoring/application/views/scripts/show/components/downtime.phtml @@ -0,0 +1,43 @@ +downtimes)) { ?> +downtimes as $downtime) { + $row = array(); + if ($downtime->downtime_is_in_effect === '1') { + $row[] = 'Running
since '. $this->timeSince($downtime->downtime_actual_start_time); + } else { + if ($downtime->downtime_is_fixed) { + $row[] = 'Scheduled
for '. $downtime->downtime_scheduled_start_time; + } else { + $row[] = 'Waiting'; + } + } + + $row[] = sprintf( + 'Triggered by %s: %s', + $downtime->downtime_author_name, + $downtime->downtime_comment_data + ); + + $row[] = ''; + + $list[] = ''. implode('', $row). ''; + } +?> +
+
+ Downtimes +
+ +
+ + + ', $list); ?> + +
+
+
+ \ No newline at end of file diff --git a/modules/monitoring/application/views/scripts/show/components/flags.phtml b/modules/monitoring/application/views/scripts/show/components/flags.phtml new file mode 100644 index 000000000..435cee465 --- /dev/null +++ b/modules/monitoring/application/views/scripts/show/components/flags.phtml @@ -0,0 +1,25 @@ +service)) { + $object = $this->service; + } elseif (isset($this->host)) { + $object = $this->host; + } + + $flags = $this->monitoringFlags($object); +?> + + $value) { ?> + + + + + +
+ + ENABLED + + DISABLED + +
\ 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 new file mode 100644 index 000000000..8d43736ad --- /dev/null +++ b/modules/monitoring/application/views/scripts/show/components/properties.phtml @@ -0,0 +1,19 @@ +service)) { + $object = $this->service; +} elseif (isset($this->host)) { + $object = $this->host; +} + +$properties = $this->monitoringProperties($object); +?> + + $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 ca09e6529..7a69b5535 100644 --- a/modules/monitoring/application/views/scripts/show/header.phtml +++ b/modules/monitoring/application/views/scripts/show/header.phtml @@ -18,22 +18,23 @@ if (!$this->compact) {
-
- -
-
- -
+ monitoringCommands( + ($showService === true) ? $this->service : $this->host, + 'small' + ); + ?>
- - + - - - -
+ service->host_icon_image): ?> +
+ Host image +
+ escape($this->host->host_name); ?> host->host_address && $this->host->host_address !== $this->host->host_name) { ?> @@ -46,14 +47,22 @@ if (!$this->compact) { (host->host_alias; ?>)
> + util()->getHostStateName($this->host->host_state); ?> since timeSince($this->host->host_last_state_change); ?> + host->host_acknowledged === '1') { ?> + (Has been acknowledged) +
+ service->service_icon_image): ?> +
+ Host image +
+ Service: escape($this->service->service_description); ?> @@ -61,12 +70,26 @@ if (!$this->compact) {
util()->getServiceStateName($this->service->service_state); ?> since timeSince($this->service->service_last_state_change); ?> + service->service_acknowledged === '1') { ?> + (Has been acknowledged) +
+ service->service_action_url || $this->service->service_notes_url): ?> + + + + Actions + + + Notes + + + + + + +
\ 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 da9d5a94d..cc41be532 100644 --- a/modules/monitoring/application/views/scripts/show/host.phtml +++ b/modules/monitoring/application/views/scripts/show/host.phtml @@ -11,8 +11,6 @@ ); } } - -var_dump($this->host); ?> partial( @@ -64,6 +62,8 @@ var_dump($this->host); render('show/components/comments.phtml'); ?> +render('show/components/downtime.phtml'); ?> + render('show/components/customvars.phtml'); ?> host->host_perfdata): ?> @@ -75,4 +75,31 @@ var_dump($this->host); perfdata($this->host->host_perfdata); ?> - \ No newline at end of file + + +
+
+ Flags +
+
+ render('show/components/flags.phtml'); ?> +
+
+ +
+
+ Properties +
+
+ render('show/components/properties.phtml'); ?> +
+
+ +
+
+ Commands +
+
+ monitoringCommands($this->host, 'full'); ?> +
+
\ No newline at end of file diff --git a/modules/monitoring/application/views/scripts/show/service.phtml b/modules/monitoring/application/views/scripts/show/service.phtml index 5023175d5..8c6f20111 100644 --- a/modules/monitoring/application/views/scripts/show/service.phtml +++ b/modules/monitoring/application/views/scripts/show/service.phtml @@ -1,31 +1,105 @@ -partial('show/header.phtml', array( - 'host' => $this->host, - 'service' => $this->service, - 'tabs' => $this->tabs, - 'compact' => $this->compact -)); ?> -expandable( - $this->pluginOutput($this->service->service_output), - $this->pluginOutput($this->service->service_long_output) -) ?> +hostgroups)) { + foreach ($this->hostgroups as $name => $alias) { + $servicegroupLinkList[] = $this->qlink( + $alias, + 'monitoring/list/services', + array( + 'servicegroups' => $name + ) + ); + } +} +?> +partial( + 'show/header.phtml', + array( + 'host' => $this->host, + 'service' => $this->service, + 'tabs' => $this->tabs, + 'compact' => $this->compact + ) +); +?> -render('show/components/contacts.phtml') ?> -render('show/components/comments.phtml') ?> +preview_image ?> + +
+
+ Plugin output +
+
+ pluginOutput($this->service->service_output); ?> + pluginOutput($this->service->service_long_output); ?> +
+
+ +
+
+ Command +
+ +
+ Command: + service->service_check_command, 2)); ?> + commandArguments($this->service->service_check_command); ?> +
+
+ +
+
+ Groups and Contacts +
+ + Servicegroups: + + + + render('show/components/contacts.phtml') ?> +
+ +render('show/components/comments.phtml'); ?> + +render('show/components/downtime.phtml'); ?> + +render('show/components/customvars.phtml'); ?> -customvars as $name => $value): ?> -escape($name) ?>: escape($value) ?>
- -expandable( - 'Command: ' . array_shift(preg_split('|!|', $this->service->service_check_command)), - $this->commandArguments($this->service->service_check_command) -) ?> service->service_perfdata): ?> -expandable( - 'Performance data:', - $this->perfdata($this->service->service_perfdata), - array('collapsed' => false) -) ?> +
+
+ Perfdata +
+
+ perfdata($this->service->service_perfdata); ?> +
+
-partial('show/legacy-service.phtml', array('service' => $this->service)) ?> -preview_image ?> +
+
+ Flags +
+
+ render('show/components/flags.phtml'); ?> +
+
+ +
+
+ Properties +
+
+ render('show/components/properties.phtml'); ?> +
+
+ +
+
+ Commands +
+
+ monitoringCommands($this->service, 'full'); ?> +
+
\ 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 a7ab52211..4eb32067a 100644 --- a/modules/monitoring/library/Monitoring/Backend/AbstractBackend.php +++ b/modules/monitoring/library/Monitoring/Backend/AbstractBackend.php @@ -84,7 +84,13 @@ class AbstractBackend implements DatasourceInterface } - // UGLY temporary host fetch + /** + * UGLY temporary host fetch + * + * @param string $host + * @param bool $fetchAll + * @return mixed + */ public function fetchHost($host, $fetchAll = false) { $fields = array( @@ -102,49 +108,52 @@ class AbstractBackend implements DatasourceInterface 'host_perfdata' ); - $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' - ) - ); + if ($fetchAll === true) { + $fields = array_merge( + $fields, + array( + 'host_current_check_attempt', + 'host_max_check_attempts', + 'host_attempt', + 'host_last_check', + 'host_next_check', + 'host_check_type', + 'host_last_state_change', + 'host_last_hard_state_change', + 'host_last_hard_state', + 'host_last_time_up', + 'host_last_time_down', + 'host_last_time_unreachable', + 'host_state_type', + 'host_last_notification', + 'host_next_notification', + 'host_no_more_notifications', + 'host_notifications_enabled', + 'host_problem_has_been_acknowledged', + 'host_acknowledgement_type', + 'host_current_notification_number', + 'host_passive_checks_enabled', + 'host_active_checks_enabled', + 'host_event_handler_enabled', + 'host_flap_detection_enabled', + 'host_is_flapping', + 'host_percent_state_change', + 'host_latency', + 'host_execution_time', + 'host_scheduled_downtime_depth', + 'host_failure_prediction_enabled', + 'host_process_performance_data', + 'host_obsess_over_host', + 'host_modified_host_attributes', + 'host_event_handler', + 'host_check_command', + 'host_normal_check_interval', + 'host_retry_check_interval', + 'host_check_timeperiod_object_id', + 'host_status_update_time' + ) + ); + } $select = $this->select() ->from('status', $fields) @@ -153,74 +162,83 @@ class AbstractBackend implements DatasourceInterface } // UGLY temporary service fetch - public function fetchService($host, $service) + public function fetchService($host, $service, $fetchAll = false) { - Benchmark::measure('Preparing service select'); - $select = $this->select() - ->from( - 'status', - array( + $fields = array( + 'service_description', + 'host_name', + 'host_address', + 'host_state', + 'host_handled', + 'host_icon_image', + 'service_state', + 'service_handled', + 'service_in_downtime', + 'service_acknowledged', + 'service_check_command', + 'service_last_state_change', + 'service_display_name', + 'service_output', + 'service_long_output', + 'service_perfdata', + 'service_action_url', + 'service_notes_url', + 'service_icon_image' + ); - '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', + if ($fetchAll === true) { + $fields = array_merge( + $fields, + array( + 'service_current_check_attempt', + 'service_max_check_attempts', + 'service_attempt', 'service_last_check', 'service_next_check', - 'service_check_execution_time', - 'service_check_latency', - // 'service_ + 'service_check_type', + 'service_last_state_change', + 'service_last_hard_state_change', + 'service_last_hard_state', + 'service_last_time_ok', + 'service_last_time_warning', + 'service_last_time_unknown', + 'service_last_time_critical', + 'service_state_type', + 'service_last_notification', + 'service_next_notification', + 'service_no_more_notifications', + 'service_notifications_enabled', + 'service_problem_has_been_acknowledged', + 'service_acknowledgement_type', + 'service_current_notification_number', + 'service_passive_checks_enabled', + 'service_active_checks_enabled', + 'service_event_handler_enabled', + 'service_flap_detection_enabled', + 'service_is_flapping', + 'service_percent_state_change', + 'service_latency', + 'service_execution_time', + 'service_scheduled_downtime_depth', + 'service_failure_prediction_enabled', + 'service_process_performance_data', + 'service_obsess_over_service', + 'service_modified_service_attributes', + 'service_event_handler', + 'service_check_command', + 'service_normal_check_interval', + 'service_retry_check_interval', + 'service_check_timeperiod_object_id', + 'service_status_update_time' ) - ) - ->where('host_name', $host) - ->where('service_description', $service); - // Benchmark::measure((string) $select->getQuery()); - Benchmark::measure('Prepared service select'); + ); + } + $select = $this->select() + ->from('status', $fields) + ->where('host_name', $host); return $select->fetchRow(); - $object = \Icinga\Objects\Service::fromBackend( - $this->select() - ->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_ - ) - ) - ->where('host_name', $host) - ->where('service_description', $service) - ->fetchRow() - ); - // $object->customvars = $this->fetchCustomvars($host, $service); - return $object; + } diff --git a/modules/monitoring/library/Monitoring/Backend/Ido/Query/DowntimeQuery.php b/modules/monitoring/library/Monitoring/Backend/Ido/Query/DowntimeQuery.php new file mode 100644 index 000000000..58097ce49 --- /dev/null +++ b/modules/monitoring/library/Monitoring/Backend/Ido/Query/DowntimeQuery.php @@ -0,0 +1,98 @@ + + * @author Icinga Development Team + */ +// {{{ICINGA_LICENSE_HEADER}}} + +namespace Icinga\Monitoring\Backend\Ido\Query; + +/** + * Class DowntimeQuery + */ +class DowntimeQuery extends AbstractQuery +{ + /** + * Column map + * @var array + */ + protected $columnMap = array( + 'downtime' => array( + 'downtime_type' => 'sd.downtime_type', + 'downtime_author_name' => 'sd.author_name', + 'downtime_comment_data' => 'sd.comment_data', + 'downtime_is_fixed' => 'sd.is_fixed', + 'downtime_duration' => 'sd.duration', + 'downtime_scheduled_start_time' => 'sd.scheduled_start_time', + 'downtime_scheduled_end_time' => 'sd.scheduled_end_time', + 'downtime_was_started' => 'sd.was_started', + 'downtime_actual_start_time' => 'sd.actual_start_time', + 'downtime_actual_start_time_usec' => 'sd.actual_start_time_usec', + 'downtime_is_in_effect' => 'sd.is_in_effect', + 'downtime_trigger_time' => 'sd.trigger_time', + 'downtime_internal_downtime_id' => 'sd.internal_downtime_id' + ), + 'hosts' => array( + 'host_name' => 'ho.name1', + ), + 'services' => array( + 'service_host_name' => 'so.name1', + 'service_description' => 'so.name2', + ) + ); + + /** + * Join with scheduleddowntime + */ + protected function joinBaseTables() + { + $this->baseQuery = $this->db->select()->from( + array('sd' => $this->prefix . 'scheduleddowntime'), + array() + ); + + $this->joinedVirtualTables = array('downtime' => true); + } + + /** + * Join if host needed + */ + protected function joinHosts() + { + $this->baseQuery->join( + array('ho' => $this->prefix . 'objects'), + 'sd.object_id = ho.object_id AND ho.is_active = 1 AND ho.objecttype_id = 1', + array() + ); + } + + /** + * Join if services needed + */ + protected function joinServices() + { + $this->baseQuery->join( + array('so' => $this->prefix . 'objects'), + 'so.object_id = ho.object_id AND ho.is_active = 1 AND ho.objecttype_id = 2', + array() + ); + } +} diff --git a/modules/monitoring/library/Monitoring/Backend/Ido/Query/StatusQuery.php b/modules/monitoring/library/Monitoring/Backend/Ido/Query/StatusQuery.php index b6c5b02b5..fe17ab412 100644 --- a/modules/monitoring/library/Monitoring/Backend/Ido/Query/StatusQuery.php +++ b/modules/monitoring/library/Monitoring/Backend/Ido/Query/StatusQuery.php @@ -15,6 +15,8 @@ class StatusQuery extends AbstractQuery 'host_address' => 'h.address', 'host_ipv4' => 'INET_ATON(h.address)', 'host_icon_image' => 'h.icon_image', + 'host_action_url' => 'h.action_url', + 'host_notes_url' => 'h.notes_url' ), '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', @@ -29,44 +31,44 @@ class StatusQuery extends AbstractQuery '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_current_check_attempt' => 'hs.current_check_attempt', + 'host_max_check_attempts' => 'hs.max_check_attempts', + 'host_attempt' => 'CONCAT(hs.current_check_attempt, "/", hs.max_check_attempts)', + 'host_last_check' => 'hs.last_check', + 'host_next_check' => 'hs.next_check', + 'host_check_type' => 'hs.check_type', + 'host_last_hard_state_change' => 'hs.last_hard_state_change', + 'host_last_hard_state' => 'hs.last_hard_state', + 'host_last_time_up' => 'hs.last_time_up', + 'host_last_time_down' => 'hs.last_time_down', + 'host_last_time_unreachable' => 'hs.last_time_unreachable', + 'host_state_type' => 'hs.state_type', + 'host_last_notification' => 'hs.last_notification', + 'host_next_notification' => 'hs.next_notification', + 'host_no_more_notifications' => 'hs.no_more_notifications', + 'host_notifications_enabled' => 'hs.notifications_enabled', + 'host_problem_has_been_acknowledged' => 'hs.problem_has_been_acknowledged', + 'host_acknowledgement_type' => 'hs.acknowledgement_type', + 'host_current_notification_number' => 'hs.current_notification_number', + 'host_passive_checks_enabled' => 'hs.passive_checks_enabled', + 'host_active_checks_enabled' => 'hs.active_checks_enabled', + 'host_event_handler_enabled' => 'hs.event_handler_enabled', + 'host_flap_detection_enabled' => 'hs.flap_detection_enabled', + 'host_is_flapping' => 'hs.is_flapping', + 'host_percent_state_change' => 'hs.percent_state_change', + 'host_latency' => 'hs.latency', + 'host_execution_time' => 'hs.execution_time', + 'host_scheduled_downtime_depth' => 'hs.scheduled_downtime_depth', + 'host_failure_prediction_enabled' => 'hs.failure_prediction_enabled', + 'host_process_performance_data' => 'hs.process_performance_data', + 'host_obsess_over_host' => 'hs.obsess_over_host', + 'host_modified_host_attributes' => 'hs.modified_host_attributes', + 'host_event_handler' => 'hs.event_handler', + 'host_check_command' => 'hs.check_command', + 'host_normal_check_interval' => 'hs.normal_check_interval', + 'host_retry_check_interval' => 'hs.retry_check_interval', + 'host_check_timeperiod_object_id' => 'hs.check_timeperiod_object_id', + 'host_status_update_time' => 'hs.status_update_time', 'host_problems' => 'CASE WHEN hs.current_state = 0 THEN 0 ELSE 1 END', 'host_severity' => 'CASE WHEN hs.current_state = 0 @@ -110,27 +112,60 @@ class StatusQuery extends AbstractQuery 'service_description' => 'so.name2', 'service_display_name' => 's.display_name', 'service_icon_image' => 's.icon_image', + 'service_action_url' => 's.action_url', + 'service_notes_url' => 's.notes_url' ), '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_handled' => 'CASE WHEN (ss.problem_has_been_acknowledged + ss.scheduled_downtime_depth) > 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_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_last_time_ok' => 'ss.last_time_ok', + 'service_last_time_warning' => 'ss.last_time_warning', + 'service_last_time_critical' => 'ss.last_time_critical', + 'service_last_time_unknown' => 'ss.last_time_unknown', + 'service_current_check_attempt' => 'ss.current_check_attempt', + 'service_max_check_attempts' => 'ss.max_check_attempts', + 'service_attempt' => 'CONCAT(ss.current_check_attempt, "/", ss.max_check_attempts)', + 'service_last_check' => 'ss.last_check', + 'service_next_check' => 'ss.next_check', + 'service_check_type' => 'ss.check_type', + 'service_last_hard_state_change' => 'ss.last_hard_state_change', + 'service_last_hard_state' => 'ss.last_hard_state', + 'service_state_type' => 'ss.state_type', + 'service_last_notification' => 'ss.last_notification', + 'service_next_notification' => 'ss.next_notification', + 'service_no_more_notifications' => 'ss.no_more_notifications', + 'service_notifications_enabled' => 'ss.notifications_enabled', + 'service_problem_has_been_acknowledged' => 'ss.problem_has_been_acknowledged', + 'service_acknowledgement_type' => 'ss.acknowledgement_type', + 'service_current_notification_number' => 'ss.current_notification_number', + 'service_passive_checks_enabled' => 'ss.passive_checks_enabled', + 'service_active_checks_enabled' => 'ss.active_checks_enabled', + 'service_event_handler_enabled' => 'ss.event_handler_enabled', + 'service_flap_detection_enabled' => 'ss.flap_detection_enabled', + 'service_is_flapping' => 'ss.is_flapping', + 'service_percent_state_change' => 'ss.percent_state_change', + 'service_latency' => 'ss.latency', + 'service_execution_time' => 'ss.execution_time', + 'service_scheduled_downtime_depth' => 'ss.scheduled_downtime_depth', + 'service_failure_prediction_enabled' => 'ss.failure_prediction_enabled', + 'service_process_performance_data' => 'ss.process_performance_data', + 'service_obsess_over_service' => 'ss.obsess_over_service', + 'service_modified_service_attributes' => 'ss.modified_service_attributes', + 'service_event_handler' => 'ss.event_handler', + 'service_check_command' => 'ss.check_command', + 'service_normal_check_interval' => 'ss.normal_check_interval', + 'service_retry_check_interval' => 'ss.retry_check_interval', + 'service_check_timeperiod_object_id' => 'ss.check_timeperiod_object_id', + 'service_status_update_time' => 'ss.status_update_time' ), 'status' => array( 'problems' => 'CASE WHEN ss.current_state = 0 THEN 0 ELSE 1 END', diff --git a/modules/monitoring/library/Monitoring/Command/Meta.php b/modules/monitoring/library/Monitoring/Command/Meta.php new file mode 100644 index 000000000..3648fa703 --- /dev/null +++ b/modules/monitoring/library/Monitoring/Command/Meta.php @@ -0,0 +1,846 @@ + + * @author Icinga Development Team + */ +// {{{ICINGA_LICENSE_HEADER}}} + +namespace Icinga\Monitoring\Command; + +use Icinga\Authentication\User; +use Icinga\Exception\ProgrammingError; + +/** + * Class Meta + * + * Deals with objects and available commands which can be used on the object + */ +class Meta +{ + /** + * Category name which is useless + */ + const DROP_CATEGORY = 'none'; + + /** + * Interface type for small interfaces + * + * Only important commands + */ + const TYPE_SMALL = 'small'; + + /** + * Interface type for full featured interface + * + * All commands are shown + */ + const TYPE_FULL = 'full'; + + const CMD_DISABLE_ACTIVE_CHECKS = 1; + const CMD_ENABLE_ACTIVE_CHECKS = 2; + const CMD_RESCHEDULE_NEXT_CHECK = 3; + const CMD_SUBMIT_PASSIVE_CHECK_RESULT = 4; + const CMD_STOP_OBSESSING = 5; + const CMD_START_OBSESSING = 6; + const CMD_STOP_ACCEPTING_PASSIVE_CHECKS = 7; + const CMD_START_ACCEPTING_PASSIVE_CHECKS = 8; + const CMD_DISABLE_NOTIFICATIONS = 9; + const CMD_ENABLE_NOTIFICATIONS = 10; + const CMD_SEND_CUSTOM_NOTIFICATION = 11; + const CMD_SCHEDULE_DOWNTIME = 12; + const CMD_SCHEDULE_DOWNTIMES_TO_ALL = 13; + const CMD_REMOVE_DOWNTIMES_FROM_ALL = 14; + const CMD_DISABLE_NOTIFICATIONS_FOR_ALL = 15; + const CMD_ENABLE_NOTIFICATIONS_FOR_ALL = 16; + const CMD_RESCHEDULE_NEXT_CHECK_TO_ALL = 17; + const CMD_DISABLE_ACTIVE_CHECKS_FOR_ALL = 18; + const CMD_ENABLE_ACTIVE_CHECKS_FOR_ALL = 19; + const CMD_DISABLE_EVENT_HANDLER = 20; + const CMD_ENABLE_EVENT_HANDLER = 21; + const CMD_DISABLE_FLAP_DETECTION = 22; + const CMD_ENABLE_FLAP_DETECTION = 23; + const CMD_ADD_COMMENT = 24; + const CMD_RESET_ATTRIBUTES = 25; + const CMD_ACKNOWLEDGE_PROBLEM = 26; + const CMD_REMOVE_ACKNOWLEDGEMENT = 27; + const CMD_DELAY_NOTIFICATION = 28; + const CMD_REMOVE_DOWNTIME = 29; + + /** + * Filter array for array displayed in small interfaces + * @var int[] + */ + private static $commandSmallFilter = array( + self::CMD_RESCHEDULE_NEXT_CHECK, + self::CMD_ACKNOWLEDGE_PROBLEM, + self::CMD_REMOVE_ACKNOWLEDGEMENT + ); + + /** + * Information about interface commands + * + * With following structure + *
+     * array(
+     *  self::CMD_CONSTANT_* => array(
+     *   '',
+     *   '',
+     *   '[ICON CSS CLASS]',
+     *   '[BUTTON CSS CLASS]',
+     *
+     *    // Maybe any other options later on
+     *  )
+     * )
+     * 
+ * + * @var array + */ + private static $commandInformation = array( + self::CMD_DISABLE_ACTIVE_CHECKS => array( + 'Disable active checks for this %s', // Long description (mandatory) + 'Disable active checks', // Short description (mandatory) + '', // Icon anything (optional) + '' // Button css cls (optional) + ), + self::CMD_ENABLE_ACTIVE_CHECKS => array( + 'Enable active checks for this %s', + 'Enable active checks', + '' + ), + self::CMD_RESCHEDULE_NEXT_CHECK => array( + 'Reschedule next service check', + 'Recheck', + '', + 'btn-success' + ), + self::CMD_SUBMIT_PASSIVE_CHECK_RESULT => array( + 'Submit passive check result', + 'Submit check result', + '' + ), + self::CMD_STOP_OBSESSING => array( + 'Stop obsessing over this %s', + 'Stop obsessing', + '' + ), + self::CMD_START_OBSESSING => array( + 'Start obsessing over this %s', + 'Start obsessing', + '' + ), + self::CMD_STOP_ACCEPTING_PASSIVE_CHECKS => array( + 'Stop accepting passive check for this %s', + 'Stop passive checks', + '' + ), + self::CMD_START_ACCEPTING_PASSIVE_CHECKS => array( + 'Start accepting passive check for this %s', + 'Start passive checks', + '' + ), + self::CMD_DISABLE_NOTIFICATIONS => array( + 'Disable notifications for this %s', + 'Disable notifications', + '' + ), + self::CMD_ENABLE_NOTIFICATIONS => array( + 'Enable notifications for this %s', + 'Enable notifications', + '' + ), + self::CMD_SEND_CUSTOM_NOTIFICATION => array( + 'Send custom %s notification', + 'Send notification', + '' + ), + self::CMD_SCHEDULE_DOWNTIME => array( + 'Schedule downtime for this %s', + 'Schedule downtime', + '' + ), + self::CMD_SCHEDULE_DOWNTIMES_TO_ALL => array( + 'Schedule downtime for this %s and all services', + 'Schedule services downtime', + '' + ), + self::CMD_REMOVE_DOWNTIMES_FROM_ALL => array( + 'Remove downtime(s) for this %s and all services', + 'Remove downtime(s)', + '' + ), + self::CMD_DISABLE_NOTIFICATIONS_FOR_ALL => array( + 'Disable notification for all service on this %s', + 'Disable service notifications', + '' + ), + self::CMD_ENABLE_NOTIFICATIONS_FOR_ALL => array( + 'Enable notification for all service on this %s', + 'Enable service notifications', + '' + ), + self::CMD_RESCHEDULE_NEXT_CHECK_TO_ALL => array( + 'Schedule a check of all service on this %s', + 'Recheck all services', + '', + 'btn-success' + ), + self::CMD_DISABLE_ACTIVE_CHECKS_FOR_ALL => array( + 'Disable checks for all services on this %s', + 'Disable service checks', + '' + ), + self::CMD_ENABLE_ACTIVE_CHECKS_FOR_ALL => array( + 'Enable checks for all services on this %s', + 'Enable service checks', + '' + ), + self::CMD_DISABLE_EVENT_HANDLER => array( + 'Disable event handler for this %s', + 'Disable event handler', + '' + ), + self::CMD_ENABLE_EVENT_HANDLER => array( + 'Enable event handler for this %s', + 'Enable event handler', + '' + ), + self::CMD_DISABLE_FLAP_DETECTION => array( + 'Disable flap detection for this %s', + 'Disable flap detection', + '' + ), + self::CMD_ENABLE_FLAP_DETECTION => array( + 'Enable flap detection for this %s', + 'Enable flap detection', + '' + ), + self::CMD_ADD_COMMENT => array( + 'Add new %s comment', + 'Add comment', + '' + ), + self::CMD_RESET_ATTRIBUTES => array( + 'Reset modified attributes', + 'Reset attributes', + '', + 'btn-danger' + ), + self::CMD_ACKNOWLEDGE_PROBLEM => array( + 'Acknowledge %s problem', + 'Acknowledge', + '', + 'btn-warning' + ), + self::CMD_REMOVE_ACKNOWLEDGEMENT => array( + 'Remove %s acknowledgement', + 'Remove acknowledgement', + '', + 'btn-warning' + ), + self::CMD_DELAY_NOTIFICATION => array( + 'Delay next %s notification', + 'Delay notification', + '' + ), + ); + + /** + * An mapping array which is valid for hosts and services + * @var array + */ + private static $defaultObjectCommands = array( + self::CMD_DISABLE_ACTIVE_CHECKS, + self::CMD_ENABLE_ACTIVE_CHECKS, + self::CMD_RESCHEDULE_NEXT_CHECK, + self::CMD_SUBMIT_PASSIVE_CHECK_RESULT, + self::CMD_STOP_OBSESSING, + self::CMD_START_OBSESSING, + self::CMD_ACKNOWLEDGE_PROBLEM, + self::CMD_REMOVE_ACKNOWLEDGEMENT, + self::CMD_STOP_ACCEPTING_PASSIVE_CHECKS, + self::CMD_START_ACCEPTING_PASSIVE_CHECKS, + self::CMD_DISABLE_NOTIFICATIONS, + self::CMD_ENABLE_NOTIFICATIONS, + self::CMD_SEND_CUSTOM_NOTIFICATION, + self::CMD_SCHEDULE_DOWNTIME, + self::CMD_SCHEDULE_DOWNTIMES_TO_ALL, + self::CMD_REMOVE_DOWNTIMES_FROM_ALL, + self::CMD_DISABLE_NOTIFICATIONS_FOR_ALL, + self::CMD_ENABLE_NOTIFICATIONS_FOR_ALL, + self::CMD_RESCHEDULE_NEXT_CHECK_TO_ALL, + self::CMD_DISABLE_ACTIVE_CHECKS_FOR_ALL, + self::CMD_ENABLE_ACTIVE_CHECKS_FOR_ALL, + self::CMD_DISABLE_EVENT_HANDLER, + self::CMD_ENABLE_EVENT_HANDLER, + self::CMD_DISABLE_FLAP_DETECTION, + self::CMD_ENABLE_FLAP_DETECTION, + self::CMD_ADD_COMMENT, + self::CMD_RESET_ATTRIBUTES, + self::CMD_DELAY_NOTIFICATION + ); + + /** + * Command mapper + * + * Holds information about commands for object types + * + * Please note that host and service are implicit initialized! + * see $defaultObjectCommands for definition + * + * @var array + */ + private static $objectCommands = array( + // 'host' => self::$defaultObjectCommands, + // 'service' => self::$defaultObjectCommands, + // -> this is done in self::initCommandStructure() + // + // Real other commands structures: + // NONE + ); + + /** + * Array of modifier methods in this class + * + * Maps object type to modifier method which rewrites + * visible commands depending on object states + * + * @var array + */ + private static $commandProcessorMethods = array( + 'host' => 'defaultCommandProcessor', + 'service' => 'defaultCommandProcessor' + ); + + /** + * Init flag for lazy, static data preparation + * @var bool + */ + private static $initialized = false; + + /** + * Array of available categories + * @var array + */ + private static $rawCategories = array(); + + /** + * Categories to command names + * @var array + */ + private static $rawCommandCategories = array(); + + /** + * Command reference list + * @var array + */ + private static $rawCommands = array( + 'NONE' => 'none', + 'ADD_HOST_COMMENT' => 'host', + 'DEL_HOST_COMMENT' => 'host', + 'ADD_SVC_COMMENT' => 'service', + 'DEL_SVC_COMMENT' => 'service', + 'ENABLE_SVC_CHECK' => 'service', + 'DISABLE_SVC_CHECK' => 'service', + 'SCHEDULE_SVC_CHECK' => 'service', + 'DELAY_SVC_NOTIFICATION' => 'service', + 'DELAY_HOST_NOTIFICATION' => 'host', + 'DISABLE_NOTIFICATIONS' => 'global', + 'ENABLE_NOTIFICATIONS' => 'global', + 'RESTART_PROCESS' => 'global', + 'SHUTDOWN_PROCESS' => 'global', + 'ENABLE_HOST_SVC_CHECKS' => 'host', + 'DISABLE_HOST_SVC_CHECKS' => 'host', + 'SCHEDULE_HOST_SVC_CHECKS' => 'host', + 'DELAY_HOST_SVC_NOTIFICATIONS' => 'host', + 'DEL_ALL_HOST_COMMENTS' => 'host', + 'DEL_ALL_SVC_COMMENTS' => 'service', + 'ENABLE_SVC_NOTIFICATIONS' => 'service', + 'DISABLE_SVC_NOTIFICATIONS' => 'service', + 'ENABLE_HOST_NOTIFICATIONS' => 'host', + 'DISABLE_HOST_NOTIFICATIONS' => 'host', + 'ENABLE_ALL_NOTIFICATIONS_BEYOND_HOST' => 'host', + 'DISABLE_ALL_NOTIFICATIONS_BEYOND_HOST' => 'host', + 'ENABLE_HOST_SVC_NOTIFICATIONS' => 'host', + 'DISABLE_HOST_SVC_NOTIFICATIONS' => 'host', + 'PROCESS_SERVICE_CHECK_RESULT' => 'service', + 'SAVE_STATE_INFORMATION' => 'global', + 'READ_STATE_INFORMATION' => 'global', + 'ACKNOWLEDGE_HOST_PROBLEM' => 'host', + 'ACKNOWLEDGE_SVC_PROBLEM' => 'service', + 'START_EXECUTING_SVC_CHECKS' => 'service', + 'STOP_EXECUTING_SVC_CHECKS' => 'service', + 'START_ACCEPTING_PASSIVE_SVC_CHECKS' => 'service', + 'STOP_ACCEPTING_PASSIVE_SVC_CHECKS' => 'service', + 'ENABLE_PASSIVE_SVC_CHECKS' => 'service', + 'DISABLE_PASSIVE_SVC_CHECKS' => 'service', + 'ENABLE_EVENT_HANDLERS' => 'global', + 'DISABLE_EVENT_HANDLERS' => 'global', + 'ENABLE_HOST_EVENT_HANDLER' => 'host', + 'DISABLE_HOST_EVENT_HANDLER' => 'host', + 'ENABLE_SVC_EVENT_HANDLER' => 'service', + 'DISABLE_SVC_EVENT_HANDLER' => 'service', + 'ENABLE_HOST_CHECK' => 'host', + 'DISABLE_HOST_CHECK' => 'host', + 'START_OBSESSING_OVER_SVC_CHECKS' => 'service', + 'STOP_OBSESSING_OVER_SVC_CHECKS' => 'service', + 'REMOVE_HOST_ACKNOWLEDGEMENT' => 'host', + 'REMOVE_SVC_ACKNOWLEDGEMENT' => 'service', + 'SCHEDULE_FORCED_HOST_SVC_CHECKS' => 'host', + 'SCHEDULE_FORCED_SVC_CHECK' => 'service', + 'SCHEDULE_HOST_DOWNTIME' => 'host', + 'SCHEDULE_SVC_DOWNTIME' => 'service', + 'ENABLE_HOST_FLAP_DETECTION' => 'host', + 'DISABLE_HOST_FLAP_DETECTION' => 'host', + 'ENABLE_SVC_FLAP_DETECTION' => 'service', + 'DISABLE_SVC_FLAP_DETECTION' => 'service', + 'ENABLE_FLAP_DETECTION' => 'global', + 'DISABLE_FLAP_DETECTION' => 'global', + 'ENABLE_HOSTGROUP_SVC_NOTIFICATIONS' => 'hostgroup', + 'DISABLE_HOSTGROUP_SVC_NOTIFICATIONS' => 'hostgroup', + 'ENABLE_HOSTGROUP_HOST_NOTIFICATIONS' => 'hostgroup', + 'DISABLE_HOSTGROUP_HOST_NOTIFICATIONS' => 'hostgroup', + 'ENABLE_HOSTGROUP_SVC_CHECKS' => 'hostgroup', + 'DISABLE_HOSTGROUP_SVC_CHECKS' => 'hostgroup', + 'CANCEL_HOST_DOWNTIME' => 'host', + 'CANCEL_SVC_DOWNTIME' => 'service', + 'CANCEL_ACTIVE_HOST_DOWNTIME' => 'host', + 'CANCEL_PENDING_HOST_DOWNTIME' => 'host', + 'CANCEL_ACTIVE_SVC_DOWNTIME' => 'service', + 'CANCEL_PENDING_SVC_DOWNTIME' => 'service', + 'CANCEL_ACTIVE_HOST_SVC_DOWNTIME' => 'host', + 'CANCEL_PENDING_HOST_SVC_DOWNTIME' => 'host', + 'FLUSH_PENDING_COMMANDS' => 'global', + 'DEL_HOST_DOWNTIME' => 'host', + 'DEL_SVC_DOWNTIME' => 'service', + 'ENABLE_FAILURE_PREDICTION' => 'global', + 'DISABLE_FAILURE_PREDICTION' => 'global', + 'ENABLE_PERFORMANCE_DATA' => 'global', + 'DISABLE_PERFORMANCE_DATA' => 'global', + 'SCHEDULE_HOSTGROUP_HOST_DOWNTIME' => 'hostgroup', + 'SCHEDULE_HOSTGROUP_SVC_DOWNTIME' => 'hostgroup', + 'SCHEDULE_HOST_SVC_DOWNTIME' => 'host', + 'PROCESS_HOST_CHECK_RESULT' => 'host', + 'START_EXECUTING_HOST_CHECKS' => 'host', + 'STOP_EXECUTING_HOST_CHECKS' => 'host', + 'START_ACCEPTING_PASSIVE_HOST_CHECKS' => 'host', + 'STOP_ACCEPTING_PASSIVE_HOST_CHECKS' => 'host', + 'ENABLE_PASSIVE_HOST_CHECKS' => 'host', + 'DISABLE_PASSIVE_HOST_CHECKS' => 'host', + 'START_OBSESSING_OVER_HOST_CHECKS' => 'host', + 'STOP_OBSESSING_OVER_HOST_CHECKS' => 'host', + 'SCHEDULE_HOST_CHECK' => 'host', + 'SCHEDULE_FORCED_HOST_CHECK' => 'host', + 'START_OBSESSING_OVER_SVC' => 'global', + 'STOP_OBSESSING_OVER_SVC' => 'global', + 'START_OBSESSING_OVER_HOST' => 'global', + 'STOP_OBSESSING_OVER_HOST' => 'global', + 'ENABLE_HOSTGROUP_HOST_CHECKS' => 'host', + 'DISABLE_HOSTGROUP_HOST_CHECKS' => 'host', + 'ENABLE_HOSTGROUP_PASSIVE_SVC_CHECKS' => 'host', + 'DISABLE_HOSTGROUP_PASSIVE_SVC_CHECKS' => 'host', + 'ENABLE_HOSTGROUP_PASSIVE_HOST_CHECKS' => 'host', + 'DISABLE_HOSTGROUP_PASSIVE_HOST_CHECKS' => 'host', + 'ENABLE_SERVICEGROUP_SVC_NOTIFICATIONS' => 'servicegroup', + 'DISABLE_SERVICEGROUP_SVC_NOTIFICATIONS' => 'servicegroup', + 'ENABLE_SERVICEGROUP_HOST_NOTIFICATIONS' => 'servicegroup', + 'DISABLE_SERVICEGROUP_HOST_NOTIFICATIONS' => 'servicegroup', + 'ENABLE_SERVICEGROUP_SVC_CHECKS' => 'servicegroup', + 'DISABLE_SERVICEGROUP_SVC_CHECKS' => 'servicegroup', + 'ENABLE_SERVICEGROUP_HOST_CHECKS' => 'servicegroup', + 'DISABLE_SERVICEGROUP_HOST_CHECKS' => 'servicegroup', + 'ENABLE_SERVICEGROUP_PASSIVE_SVC_CHECKS' => 'servicegroup', + 'DISABLE_SERVICEGROUP_PASSIVE_SVC_CHECKS' => 'servicegroup', + 'ENABLE_SERVICEGROUP_PASSIVE_HOST_CHECKS' => 'servicegroup', + 'DISABLE_SERVICEGROUP_PASSIVE_HOST_CHECKS' => 'servicegroup', + 'SCHEDULE_SERVICEGROUP_HOST_DOWNTIME' => 'servicegroup', + 'SCHEDULE_SERVICEGROUP_SVC_DOWNTIME' => 'servicegroup', + 'CHANGE_GLOBAL_HOST_EVENT_HANDLER' => 'global', + 'CHANGE_GLOBAL_SVC_EVENT_HANDLER' => 'global', + 'CHANGE_HOST_EVENT_HANDLER' => 'host', + 'CHANGE_SVC_EVENT_HANDLER' => 'service', + 'CHANGE_HOST_CHECK_COMMAND' => 'host', + 'CHANGE_SVC_CHECK_COMMAND' => 'service', + 'CHANGE_NORMAL_HOST_CHECK_INTERVAL' => 'host', + 'CHANGE_NORMAL_SVC_CHECK_INTERVAL' => 'service', + 'CHANGE_RETRY_SVC_CHECK_INTERVAL' => 'service', + 'CHANGE_MAX_HOST_CHECK_ATTEMPTS' => 'host', + 'CHANGE_MAX_SVC_CHECK_ATTEMPTS' => 'service', + 'SCHEDULE_AND_PROPAGATE_TRIGGERED_HOST_DOWNTIME' => 'host', + 'ENABLE_HOST_AND_CHILD_NOTIFICATIONS' => 'host', + 'DISABLE_HOST_AND_CHILD_NOTIFICATIONS' => 'host', + 'SCHEDULE_AND_PROPAGATE_HOST_DOWNTIME' => 'host', + 'ENABLE_SERVICE_FRESHNESS_CHECKS' => 'global', + 'DISABLE_SERVICE_FRESHNESS_CHECKS' => 'global', + 'ENABLE_HOST_FRESHNESS_CHECKS' => 'host', + 'DISABLE_HOST_FRESHNESS_CHECKS' => 'host', + 'SET_HOST_NOTIFICATION_NUMBER' => 'host', + 'SET_SVC_NOTIFICATION_NUMBER' => 'service', + 'CHANGE_HOST_CHECK_TIMEPERIOD' => 'host', + 'CHANGE_SVC_CHECK_TIMEPERIOD' => 'service', + 'PROCESS_FILE' => 'global', + 'CHANGE_CUSTOM_HOST_VAR' => 'host', + 'CHANGE_CUSTOM_SVC_VAR' => 'service', + 'CHANGE_CUSTOM_CONTACT_VAR' => 'global', + 'ENABLE_CONTACT_HOST_NOTIFICATIONS' => 'host', + 'DISABLE_CONTACT_HOST_NOTIFICATIONS' => 'host', + 'ENABLE_CONTACT_SVC_NOTIFICATIONS' => 'service', + 'DISABLE_CONTACT_SVC_NOTIFICATIONS' => 'service', + 'ENABLE_CONTACTGROUP_HOST_NOTIFICATIONS' => 'host', + 'DISABLE_CONTACTGROUP_HOST_NOTIFICATIONS' => 'host', + 'ENABLE_CONTACTGROUP_SVC_NOTIFICATIONS' => 'service', + 'DISABLE_CONTACTGROUP_SVC_NOTIFICATIONS' => 'service', + 'CHANGE_RETRY_HOST_CHECK_INTERVAL' => 'host', + 'SEND_CUSTOM_HOST_NOTIFICATION' => 'host', + 'SEND_CUSTOM_SVC_NOTIFICATION' => 'service', + 'CHANGE_HOST_NOTIFICATION_TIMEPERIOD' => 'host', + 'CHANGE_SVC_NOTIFICATION_TIMEPERIOD' => 'service', + 'CHANGE_CONTACT_HOST_NOTIFICATION_TIMEPERIOD' => 'host', + 'CHANGE_CONTACT_SVC_NOTIFICATION_TIMEPERIOD' => 'service', + 'CHANGE_HOST_MODATTR' => 'host', + 'CHANGE_SVC_MODATTR' => 'service', + 'CHANGE_CONTACT_MODATTR' => 'contact', + 'CHANGE_CONTACT_MODHATTR' => 'contact', + 'CHANGE_CONTACT_MODSATTR' => 'contact', + 'SYNC_STATE_INFORMATION' => 'contact', + 'DEL_DOWNTIME_BY_HOST_NAME' => 'host', + 'DEL_DOWNTIME_BY_HOSTGROUP_NAME' => 'hostgroup', + 'DEL_DOWNTIME_BY_START_TIME_COMMENT' => 'comment', + 'ACKNOWLEDGE_HOST_PROBLEM_EXPIRE' => 'host', + 'ACKNOWLEDGE_SVC_PROBLEM_EXPIRE' => 'service', + 'DISABLE_NOTIFICATIONS_EXPIRE_TIME' => 'global', + 'CUSTOM_COMMAND' => 'none', + ); + + /** + * Initialize command structures only once + */ + private static function initCommandStructure() + { + if (self::$initialized === true) { + return; + } + + /* + * Build everything for raw commands + */ + $categories = array(); + foreach (self::$rawCommands as $commandName => $categoryName) { + // We do not want to see useless commands + if ($categoryName === self::DROP_CATEGORY) { + unset(self::$rawCommands[$commandName]); + continue; + } + + $categories[$categoryName] = null; + + if (array_key_exists($categoryName, self::$rawCommandCategories) === false) { + self::$rawCommandCategories[$categoryName] = array(); + } + + self::$rawCommandCategories[$categoryName][] = $commandName; + } + + self::$rawCategories = array_keys($categories); + sort(self::$rawCategories); + + /* + * Build everything for object commands + */ + self::$objectCommands['host'] = self::$defaultObjectCommands; + self::$objectCommands['service'] = self::$defaultObjectCommands; + + self::$initialized = true; + } + + /** + * Creates a new object + */ + public function __construct() + { + self::initCommandStructure(); + } + + /** + * Return a full list of commands + * @return string[] + */ + public function getRawCommands() + { + static $commands = null; + + if ($commands === null) { + $commands = array_keys(self::$rawCommands); + } + + return $commands; + } + + /** + * Return all commands for a category + * @param string $categoryName + * @return string[] + */ + public function getRawCommandsForCategory($categoryName) + { + $this->assertRawCategoryExistence($categoryName); + return array_values(self::$rawCommandCategories[$categoryName]); + } + + /** + * Test for category existence + * @param string $categoryName + * @throws \Icinga\Exception\ProgrammingError + */ + private function assertRawCategoryExistence($categoryName) + { + if (array_key_exists($categoryName, self::$rawCommandCategories) === false) { + throw new ProgrammingError('Category does not exists: ' . $categoryName); + } + } + + /** + * Return a list of all categories + * @return string[] + */ + public function getRawCategories() + { + return self::$rawCategories; + } + + /** + * Returns the type of object + * + * This is made by the first key of property + * e.g. + * $object->host_state + * Type is 'host' + * + * @param \stdClass $object + * @return mixed + */ + private function getObjectType(\stdClass $object) + { + return array_shift(explode('_', array_shift(array_keys(get_object_vars($object))), 2)); + } + + /** + * Returns method name based on object type + * @param string $type + * @return string + * @throws \Icinga\Exception\ProgrammingError + */ + private function getCommandProcessorMethod($type) + { + if (array_key_exists($type, self::$commandProcessorMethods)) { + $method = self::$commandProcessorMethods[$type]; + if (is_callable(array(&$this, $method))) { + return $method; + } + } + + throw new ProgrammingError('Type has no command processor: '. $type); + } + + /** + * Return interface commands by object type + * @param string $type + * @return array + * @throws \Icinga\Exception\ProgrammingError + */ + private function getCommandsByType($type) + { + if (array_key_exists($type, self::$objectCommands)) { + return self::$objectCommands[$type]; + } + + throw new ProgrammingError('Type has no commands defined: '. $type); + } + + /** + * Modifies data objects to drop their object type + * + * - host_state will be state + * - service_state will be also state + * - And so on + * + * @param \stdClass $object + * @param $type + * @return object + */ + private function dropTypeAttributes(\stdClass $object, $type) + { + $objectData = get_object_vars($object); + + foreach ($objectData as $propertyName => $propertyValue) { + $newProperty = str_replace($type. '_', '', $propertyName); + $objectData[$newProperty] = $propertyValue; + unset($objectData[$propertyName]); + } + + return (object)$objectData; + } + + /** + * Default processor for host and service objects + * + * Drop commands from list based on states and object properties + * + * @param \stdClass $object + * @param array $commands + * @param string $type + * @return array + */ + private function defaultCommandProcessor(\stdClass $object, array $commands, $type) + { + $object = $this->dropTypeAttributes($object, $type); + + $commands = array_flip($commands); + + if ($object->active_checks_enabled === '1') { + unset($commands[self::CMD_ENABLE_ACTIVE_CHECKS]); + } else { + unset($commands[self::CMD_DISABLE_ACTIVE_CHECKS]); + } + + if ($object->passive_checks_enabled !== '1') { + unset($commands[self::CMD_SUBMIT_PASSIVE_CHECK_RESULT]); + } + + if ($object->passive_checks_enabled === '1') { + unset($commands[self::CMD_STOP_ACCEPTING_PASSIVE_CHECKS]); + } else { + unset($commands[self::CMD_START_ACCEPTING_PASSIVE_CHECKS]); + } + $obsess = 'obsess_over_'.$type; + if ($object->$obsess === '1') { + unset($commands[self::CMD_START_OBSESSING]); + } else { + unset($commands[self::CMD_STOP_OBSESSING]); + } + + if ($object->state !== '0') { + if ($object->acknowledged === '1') { + unset($commands[self::CMD_ACKNOWLEDGE_PROBLEM]); + } else { + unset($commands[self::CMD_REMOVE_ACKNOWLEDGEMENT]); + } + } else { + unset($commands[self::CMD_ACKNOWLEDGE_PROBLEM]); + unset($commands[self::CMD_REMOVE_ACKNOWLEDGEMENT]); + } + + if ($object->notifications_enabled === '1') { + unset($commands[self::CMD_ENABLE_NOTIFICATIONS]); + } else { + unset($commands[self::CMD_DISABLE_NOTIFICATIONS]); + } + + if ($object->event_handler_enabled === '1') { + unset($commands[self::CMD_ENABLE_EVENT_HANDLER]); + } else { + unset($commands[self::CMD_DISABLE_EVENT_HANDLER]); + } + + if ($object->flap_detection_enabled === '1') { + unset($commands[self::CMD_ENABLE_FLAP_DETECTION]); + } else { + unset($commands[self::CMD_DISABLE_FLAP_DETECTION]); + } + + return array_flip($commands); + } + + /** + * Creates structure to work with in interfaces + * + * @param array $commands + * @param string $objectType + * @return array + */ + private function buildInterfaceConfiguration(array $commands, $objectType) + { + $out = array(); + foreach ($commands as $index => $commandId) { + + $command = new \stdClass(); + $command->id = $commandId; + if (array_key_exists($commandId, self::$commandInformation)) { + $command->shortDescription = sprintf(self::$commandInformation[$commandId][1], $objectType); + $command->longDescription = sprintf(self::$commandInformation[$commandId][0], $objectType); + $command->iconCls = + (isset(self::$commandInformation[$commandId][2])) + ? self::$commandInformation[$commandId][2] + : ''; + $command->btnCls = + (isset(self::$commandInformation[$commandId][3])) + ? self::$commandInformation[$commandId][3] + : ''; + } + + $out[] = $command; + } + + return $out; + } + + /** + * Drop commands + * For small interfaces or bypass when full interfaces are needed + * @param array $commands + * @param string $type + * @return array + */ + private function filterInterfaceType(array $commands, $type) + { + if ($type === self::TYPE_FULL) { + return $commands; + } + + foreach ($commands as $arrayId => $commandId) { + if (in_array($commandId, self::$commandSmallFilter) === false) { + unset($commands[$arrayId]); + } + } + + return $commands; + } + + /** + * Get commands for an object + * + * Based on objects and interface type + * + * @param \stdClass $object + * @param $interfaceType + * @param User $user + * @return array + */ + public function getCommandForObject(\stdClass $object, $interfaceType, User $user = null) + { + $objectType = $this->getObjectType($object); + $commands = $this->getCommandsByType($objectType); + $method = $this->getCommandProcessorMethod($objectType); + $commands = $this->$method($object, $commands, $objectType); + $commands = $this->filterInterfaceType($commands, $interfaceType); + $commands = $this->buildInterfaceConfiguration($commands, $objectType); + return $commands; + } +} diff --git a/modules/monitoring/library/Monitoring/View/DowntimeView.php b/modules/monitoring/library/Monitoring/View/DowntimeView.php new file mode 100644 index 000000000..4884db1f7 --- /dev/null +++ b/modules/monitoring/library/Monitoring/View/DowntimeView.php @@ -0,0 +1,76 @@ + + * @author Icinga Development Team + */ +// {{{ICINGA_LICENSE_HEADER}}} +namespace Icinga\Monitoring\View; + +/** + * Class DowntimeView + */ +class DowntimeView extends MonitoringView +{ + /** + * Query object + * @var mixed + */ + protected $query; + + /** + * Available columns + * @var string[] + */ + protected $availableColumns = array( + 'downtime_type', + 'downtime_author_name', + 'downtime_comment_data', + 'downtime_is_fixed', + 'downtime_duration', + 'downtime_scheduled_start_time', + 'downtime_scheduled_end_time', + 'downtime_was_started', + 'downtime_actual_start_time', + 'downtime_actual_start_time_usec', + 'downtime_is_in_effect', + 'downtime_trigger_time', + 'downtime_internal_downtime_id' + ); + + /** + * Filters + * @var array + */ + protected $specialFilters = array(); + + /** + * Default sorting of data set + * @var array + */ + protected $sortDefaults = array( + 'downtime_is_in_effect' => array( + 'default_dir' => self::SORT_DESC + ), + 'downtime_actual_start_time' => array( + 'default_dir' => self::SORT_DESC + ) + ); +} diff --git a/modules/monitoring/test/php/application/views/helpers/MonitoringCommandsTest.php b/modules/monitoring/test/php/application/views/helpers/MonitoringCommandsTest.php new file mode 100644 index 000000000..8d3060c85 --- /dev/null +++ b/modules/monitoring/test/php/application/views/helpers/MonitoringCommandsTest.php @@ -0,0 +1,116 @@ +monitoringCommands($object, Meta::TYPE_SMALL); + + $this->assertContains('Remove acknowledgement', $html); + $this->assertContains('Recheck', $html); + $this->assertNotContains('Obsess', $html); + $this->assertNotContains('Enable', $html); + $this->assertNotContains('Disable', $html); + } + + public function testOutput2() + { + $helper = new \Zend_View_Helper_MonitoringCommands(); + $object = new HostStruct(); + + $html = $helper->monitoringCommands($object, Meta::TYPE_FULL); + + $dom = new \DOMDocument('1.0', 'utf-8'); + $dom->loadXML($html); + + $xpath = new \DOMXPath($dom); + $nodes = $xpath->query('//div[@class=\'command-section pull-left\']'); + + $this->assertEquals(5, $nodes->length); + + $nodes = $xpath->query('//button'); + $this->assertEquals(21, $nodes->length); + } + + public function testOutput3() + { + $helper = new \Zend_View_Helper_MonitoringCommands(); + $object = new HostStruct(); + $object->host_state = '0'; + + $html = $helper->monitoringCommands($object, Meta::TYPE_FULL); + + $dom = new \DOMDocument('1.0', 'utf-8'); + $dom->loadXML($html); + + $xpath = new \DOMXPath($dom); + + $nodes = $xpath->query('//button'); + $this->assertEquals(20, $nodes->length); + } +} \ No newline at end of file diff --git a/modules/monitoring/test/php/application/views/helpers/MonitoringFlagsTest.php b/modules/monitoring/test/php/application/views/helpers/MonitoringFlagsTest.php new file mode 100644 index 000000000..b03eff55f --- /dev/null +++ b/modules/monitoring/test/php/application/views/helpers/MonitoringFlagsTest.php @@ -0,0 +1,116 @@ + '0', + 'host_active_checks_enabled' => '0', + 'host_obsess_over_host' => '1', + 'host_notifications_enabled' => '0', + 'host_event_handler_enabled' => '1', + 'host_flap_detection_enabled' => '1', + ); + + $monitoringFlags = new \Zend_View_Helper_MonitoringFlags(); + $returnArray = $monitoringFlags->monitoringFlags((object)$testArray); + + $this->assertCount(6, $returnArray); + + $expected = array( + 'Passive checks' => false, + 'Active checks' => false, + 'Obsessing' => true, + 'Notifications' => false, + 'Event handler' => true, + 'Flap detection' => true + ); + + $this->assertEquals($expected, $returnArray); + } + + public function testService1() + { + $testArray = array( + 'service_passive_checks_enabled' => '0', + 'service_active_checks_enabled' => '1', + 'service_obsess_over_host' => '0', + 'service_notifications_enabled' => '1', + 'service_event_handler_enabled' => '1', + 'service_flap_detection_enabled' => '0', + ); + + $monitoringFlags = new \Zend_View_Helper_MonitoringFlags(); + $returnArray = $monitoringFlags->monitoringFlags((object)$testArray); + + $this->assertCount(6, $returnArray); + + $expected = array( + 'Passive checks' => false, + 'Active checks' => true, + 'Obsessing' => false, + 'Notifications' => true, + 'Event handler' => true, + 'Flap detection' => false + ); + + $this->assertEquals($expected, $returnArray); + } + + public function testUglyConditions1() + { + $testArray = array( + 'service_active_checks_enabled' => '1', + 'service_obsess_over_host' => '1', + 'DING DING' => '$$$', + 'DONG DONG' => '###' + ); + + $monitoringFlags = new \Zend_View_Helper_MonitoringFlags(); + $returnArray = $monitoringFlags->monitoringFlags((object)$testArray); + + $this->assertCount(6, $returnArray); + + $expected = array( + 'Passive checks' => false, + 'Active checks' => true, + 'Obsessing' => true, + 'Notifications' => false, + 'Event handler' => false, + 'Flap detection' => false + ); + + $this->assertEquals($expected, $returnArray); + } + + public function testUglyConditions2() + { + $testArray = array( + 'DING DING' => '$$$', + 'DONG DONG' => '###' + ); + + $monitoringFlags = new \Zend_View_Helper_MonitoringFlags(); + $returnArray = $monitoringFlags->monitoringFlags((object)$testArray); + + $this->assertCount(6, $returnArray); + + $expected = array( + 'Passive checks' => false, + 'Active checks' => false, + 'Obsessing' => false, + 'Notifications' => false, + 'Event handler' => false, + 'Flap detection' => false + ); + + $this->assertEquals($expected, $returnArray); + } +} \ No newline at end of file diff --git a/modules/monitoring/test/php/application/views/helpers/MonitoringPropertiesTest.php b/modules/monitoring/test/php/application/views/helpers/MonitoringPropertiesTest.php new file mode 100644 index 000000000..0551c23bb --- /dev/null +++ b/modules/monitoring/test/php/application/views/helpers/MonitoringPropertiesTest.php @@ -0,0 +1,105 @@ +host_current_check_attempt = '5'; + + $propertyHelper = new \Zend_View_Helper_MonitoringProperties(); + $items = $propertyHelper->monitoringProperties($host); + + $this->assertCount(10, $items); + $this->assertEquals('5/10 (HARD state)', $items['Current attempt']); + $this->assertEquals('2013-07-08 10:10:10', $items['Last update']); + } + + public function testOutput2() + { + $host = new HostStruct4Properties(); + $host->host_current_check_attempt = '5'; + $host->host_active_checks_enabled = '1'; + $host->host_passive_checks_enabled = '0'; + $host->host_is_flapping = '1'; + + $propertyHelper = new \Zend_View_Helper_MonitoringProperties(); + $items = $propertyHelper->monitoringProperties($host); + + $this->assertCount(10, $items); + + $test = array( + 'Current attempt' => "5/10 (HARD state)", + 'Last check time' => "2013-07-04 11:24:42", + 'Check type' => "ACTIVE", + 'Check latency / duration' => "0.1204 / 0.0000 seconds", + 'Next scheduled active check' => "2013-07-04 11:29:43", + 'Last state change' => "2013-07-04 13:24:43", + 'Last notification' => "N/A (notification 0)", + 'Is this host flapping?' => "YES (12.37% state change)", + 'In scheduled downtime?' => "YES", + 'Last update' => "2013-07-08 10:10:10", + ); + + $this->assertEquals($test, $items); + } +} diff --git a/modules/monitoring/test/php/library/Command/MetaTest.php b/modules/monitoring/test/php/library/Command/MetaTest.php new file mode 100644 index 000000000..dc06e10ba --- /dev/null +++ b/modules/monitoring/test/php/library/Command/MetaTest.php @@ -0,0 +1,185 @@ +getRawCommands(); + + $this->assertCount(173, $commands); + + $this->assertTrue(in_array('SCHEDULE_SERVICEGROUP_SVC_DOWNTIME', $commands)); + $this->assertTrue(in_array('SCHEDULE_SVC_CHECK', $commands)); + $this->assertTrue(in_array('ENABLE_HOSTGROUP_SVC_CHECKS', $commands)); + $this->assertTrue(in_array('PROCESS_HOST_CHECK_RESULT', $commands)); + $this->assertTrue(in_array('ACKNOWLEDGE_SVC_PROBLEM', $commands)); + $this->assertTrue(in_array('ACKNOWLEDGE_HOST_PROBLEM', $commands)); + $this->assertTrue(in_array('SCHEDULE_FORCED_SVC_CHECK', $commands)); + $this->assertTrue(in_array('DISABLE_FLAP_DETECTION', $commands)); + } + + public function testRawCommands2() + { + $meta = new Meta(); + $categories = $meta->getRawCategories(); + + $this->assertCount(7, $categories); + + $this->assertEquals( + array( + 'comment', + 'contact', + 'global', + 'host', + 'hostgroup', + 'service', + 'servicegroup' + ), + $categories + ); + } + + public function testRawCommands3() + { + $meta = new Meta(); + + $this->assertCount(9, $meta->getRawCommandsForCategory('hostgroup')); + $this->assertCount(14, $meta->getRawCommandsForCategory('servicegroup')); + + $test1 = $meta->getRawCommandsForCategory('global'); + $this->count(26, $test1); + + $this->assertTrue(in_array('DISABLE_NOTIFICATIONS', $test1)); + $this->assertTrue(in_array('RESTART_PROCESS', $test1)); + $this->assertTrue(in_array('ENABLE_FLAP_DETECTION', $test1)); + $this->assertTrue(in_array('PROCESS_FILE', $test1)); + } + + /** + * @expectedException Icinga\Exception\ProgrammingError + * @expectedExceptionMessage Category does not exists: DOES_NOT_EXIST + */ + public function testRawCommands4() + { + $meta = new Meta(); + $meta->getRawCommandsForCategory('DOES_NOT_EXIST'); + } + + public function testObjectForCommand1() + { + $meta = new Meta(); + + $object = new HostStruct(); + + $commands = $meta->getCommandForObject($object, Meta::TYPE_SMALL); + + $this->assertEquals(3, $commands[0]->id); + $this->assertEquals(27, $commands[1]->id); + + $object->host_state = '0'; + + $commands = $meta->getCommandForObject($object, Meta::TYPE_SMALL); + + $this->assertEquals(3, $commands[0]->id); + $this->assertFalse(isset($commands[1])); // STATE IS OK AGAIN + + $object->host_state = '1'; + $object->host_acknowledged = '0'; + + $commands = $meta->getCommandForObject($object, Meta::TYPE_SMALL); + + $this->assertEquals(3, $commands[0]->id); + $this->assertEquals(26, $commands[1]->id); + } + + public function testObjectForCommand2() + { + $meta = new Meta(); + + $object = new HostStruct(); + + $object->host_obsess_over_host = '0'; + $object->host_flap_detection_enabled = '0'; + $object->host_active_checks_enabled = '0'; + + $commands = $meta->getCommandForObject($object, Meta::TYPE_FULL); + + $this->assertEquals(2, $commands[0]->id); + $this->assertEquals(6, $commands[3]->id); + } + + /** + * @expectedException Icinga\Exception\ProgrammingError + * @expectedExceptionMessage Type has no commands defined: UNKNOWN + */ + public function testObjectForCommand3() + { + $meta = new Meta(); + + $test = new \stdClass(); + $test->UNKNOWN_state = '2'; + $test->UNKNOWN_flap_detection_enabled = '1'; + + $commands = $meta->getCommandForObject($test, Meta::TYPE_FULL); + } +} \ No newline at end of file From 4ededd5179d928a60b01e89edb4b40dff71731fd Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jannis=20Mo=C3=9Fhammer?= Date: Mon, 22 Jul 2013 17:10:43 +0200 Subject: [PATCH 2/3] Add servicegroup and icon image to service overview Add icon images for hosts and services, notes and action url for hosts refs #4181 --- .../controllers/ShowController.php | 37 +++++++++++++------ .../application/views/helpers/Perfdata.php | 7 ++++ .../views/scripts/show/header.phtml | 37 ++++++++++++++++--- .../views/scripts/show/service.phtml | 6 ++- .../Monitoring/Backend/AbstractBackend.php | 6 ++- 5 files changed, 74 insertions(+), 19 deletions(-) diff --git a/modules/monitoring/application/controllers/ShowController.php b/modules/monitoring/application/controllers/ShowController.php index aab3ccb0e..1a800aa5b 100644 --- a/modules/monitoring/application/controllers/ShowController.php +++ b/modules/monitoring/application/controllers/ShowController.php @@ -79,17 +79,30 @@ class Monitoring_ShowController extends ModuleActionController if ($grapher = Hook::get('grapher')) { if ($grapher->hasGraph( - $this->view->host->host_name, + $this->view->service->host_name, $this->view->service->service_description ) ) { $this->view->preview_image = $grapher->getPreviewImage( - $this->view->host->host_name, + $this->view->service->host_name, $this->view->service->service_description ); } } + $this->view->servicegroups = $this->backend->select() + ->from( + 'servicegroup', + array( + 'servicegroup_name', + 'servicegroup_alias' + ) + ) + ->where('host_name', $this->view->host->host_name) + ->where('service_description', $this->view->service->service_description) + + ->fetchPairs(); + $this->view->contacts = $this->backend->select() ->from( 'contact', @@ -350,15 +363,17 @@ class Monitoring_ShowController extends ModuleActionController 'urlParams' => $hostParams, ) ); - $tabs->add( - 'services', - array( - 'title' => 'Services', - 'icon' => 'img/classic/service.png', - 'url' => 'monitoring/show/services', - 'urlParams' => $params, - ) - ); + if (!isset($this->view->service)) { + $tabs->add( + 'services', + array( + 'title' => 'Services', + 'icon' => 'img/classic/service.png', + 'url' => 'monitoring/show/services', + 'urlParams' => $params, + ) + ); + } if (isset($params['service'])) { $tabs->add( 'service', diff --git a/modules/monitoring/application/views/helpers/Perfdata.php b/modules/monitoring/application/views/helpers/Perfdata.php index f7ae4672f..eee779911 100644 --- a/modules/monitoring/application/views/helpers/Perfdata.php +++ b/modules/monitoring/application/views/helpers/Perfdata.php @@ -6,6 +6,7 @@ class Zend_View_Helper_Perfdata extends Zend_View_Helper_Abstract { public function perfdata($perfdata, $compact = false, $float = 'right') { + if (empty($perfdata)) { return ''; } @@ -75,9 +76,15 @@ class Zend_View_Helper_Perfdata extends Zend_View_Helper_Abstract . ''; } } + if ($result == '') { + $result = $perfdata; + } if (! $compact && $result !== '') { $result = '' . $result . '
'; } + + + return $result; } } diff --git a/modules/monitoring/application/views/scripts/show/header.phtml b/modules/monitoring/application/views/scripts/show/header.phtml index 7a69b5535..a9d29fabe 100644 --- a/modules/monitoring/application/views/scripts/show/header.phtml +++ b/modules/monitoring/application/views/scripts/show/header.phtml @@ -1,6 +1,7 @@ service) && $this->tabs->getActiveName() !== 'host') { $showService = true; } @@ -30,9 +31,10 @@ if (!$this->compact) { + + host->host_action_url || $this->host->host_notes_url): ?> + + + + + + + service->service_action_url || $this->service->service_notes_url): ?> + +
- service->host_icon_image): ?> + + host->host_icon_image) : ?>
- Host image + Host image
@@ -55,6 +57,25 @@ if (!$this->compact) {
+ host->host_action_url): ?> + + Host actions + + + host->host_notes_url): ?> + + Host notes + + +
@@ -76,19 +97,25 @@ if (!$this->compact) {
+ service->service_action_url): ?> - Actions + Service actions + + service->service_notes_url): ?> - Notes + Service notes - +
diff --git a/modules/monitoring/application/views/scripts/show/service.phtml b/modules/monitoring/application/views/scripts/show/service.phtml index 8c6f20111..9bcf1021d 100644 --- a/modules/monitoring/application/views/scripts/show/service.phtml +++ b/modules/monitoring/application/views/scripts/show/service.phtml @@ -1,7 +1,8 @@ hostgroups)) { - foreach ($this->hostgroups as $name => $alias) { +if (!empty($this->servicegroups)) { + foreach ($this->servicegroups as $name => $alias) { $servicegroupLinkList[] = $this->qlink( $alias, 'monitoring/list/services', @@ -68,6 +69,7 @@ $this->partial( service->service_perfdata): ?>
+
Perfdata
diff --git a/modules/monitoring/library/Monitoring/Backend/AbstractBackend.php b/modules/monitoring/library/Monitoring/Backend/AbstractBackend.php index 4eb32067a..e896def4f 100644 --- a/modules/monitoring/library/Monitoring/Backend/AbstractBackend.php +++ b/modules/monitoring/library/Monitoring/Backend/AbstractBackend.php @@ -98,6 +98,7 @@ class AbstractBackend implements DatasourceInterface 'host_address', 'host_state', 'host_handled', + 'host_icon_image', 'host_in_downtime', 'host_acknowledged', 'host_check_command', @@ -105,7 +106,9 @@ class AbstractBackend implements DatasourceInterface 'host_alias', 'host_output', 'host_long_output', - 'host_perfdata' + 'host_perfdata', + 'host_notes_url', + 'host_action_url' ); if ($fetchAll === true) { @@ -236,6 +239,7 @@ class AbstractBackend implements DatasourceInterface $select = $this->select() ->from('status', $fields) + ->where('service_description', $service) ->where('host_name', $host); return $select->fetchRow(); From 14922457888c339ef2abac0aea54f369bf8e164d Mon Sep 17 00:00:00 2001 From: Marius Hein Date: Tue, 23 Jul 2013 14:03:32 +0200 Subject: [PATCH 3/3] Service detail view: Template fixes refs #4181 --- .../views/helpers/MonitoringCommands.php | 6 ++- .../views/helpers/MonitoringFlags.php | 31 +++++++++++--- .../views/helpers/MonitoringProperties.php | 41 ++++++++++++++----- .../scripts/show/components/comments.phtml | 4 +- .../scripts/show/components/downtime.phtml | 4 +- .../views/scripts/show/components/flags.phtml | 10 ++--- .../scripts/show/components/properties.phtml | 4 +- .../views/scripts/show/header.phtml | 22 +++++----- .../application/views/scripts/show/host.phtml | 4 +- .../Backend/Ido/Query/DowntimeQuery.php | 28 ++++++------- .../library/Monitoring/Command/Meta.php | 2 - .../library/Monitoring/View/DowntimeView.php | 2 +- 12 files changed, 99 insertions(+), 59 deletions(-) diff --git a/modules/monitoring/application/views/helpers/MonitoringCommands.php b/modules/monitoring/application/views/helpers/MonitoringCommands.php index 6a1a9b57b..d035fbf4c 100644 --- a/modules/monitoring/application/views/helpers/MonitoringCommands.php +++ b/modules/monitoring/application/views/helpers/MonitoringCommands.php @@ -26,7 +26,7 @@ use Icinga\Monitoring\Command\Meta; /** - * Class MonitoringCommands + * Display a bunch of commands * * Helper which produces a list of command buttons * depending on object states @@ -34,8 +34,10 @@ use Icinga\Monitoring\Command\Meta; class Zend_View_Helper_MonitoringCommands extends Zend_View_Helper_Abstract { /** + * Helper function called externally + * * @param stdClass $object host or service object or something other - * @param string $type small or full + * @param string $type small or full * @return string html output */ public function monitoringCommands(\stdClass $object, $type) diff --git a/modules/monitoring/application/views/helpers/MonitoringFlags.php b/modules/monitoring/application/views/helpers/MonitoringFlags.php index 13064e568..8edacd439 100644 --- a/modules/monitoring/application/views/helpers/MonitoringFlags.php +++ b/modules/monitoring/application/views/helpers/MonitoringFlags.php @@ -1,10 +1,29 @@ + * @author Icinga Development Team + */ // {{{ICINGA_LICENSE_HEADER}}} /** - * Class Zend_View_Helper_MonitoringFlags - * * Rendering helper for flags depending on objects */ class Zend_View_Helper_MonitoringFlags extends Zend_View_Helper_Abstract @@ -15,10 +34,10 @@ class Zend_View_Helper_MonitoringFlags extends Zend_View_Helper_Abstract */ private static $keys = array( 'passive_checks_enabled' => 'Passive checks', - 'active_checks_enabled' => 'Active checks', - 'obsess_over_host' => 'Obsessing', - 'notifications_enabled' => 'Notifications', - 'event_handler_enabled' => 'Event handler', + 'active_checks_enabled' => 'Active checks', + 'obsess_over_host' => 'Obsessing', + 'notifications_enabled' => 'Notifications', + 'event_handler_enabled' => 'Event handler', 'flap_detection_enabled' => 'Flap detection', ); diff --git a/modules/monitoring/application/views/helpers/MonitoringProperties.php b/modules/monitoring/application/views/helpers/MonitoringProperties.php index 13c7a52c5..60ef97828 100644 --- a/modules/monitoring/application/views/helpers/MonitoringProperties.php +++ b/modules/monitoring/application/views/helpers/MonitoringProperties.php @@ -1,9 +1,30 @@ + * @author Icinga Development Team + */ // {{{ICINGA_LICENSE_HEADER}}} /** - * Class Zend_View_Helper_MonitoringProperties + * Helper to display monitoring properties */ class Zend_View_Helper_MonitoringProperties extends Zend_View_Helper_Abstract { @@ -45,16 +66,16 @@ class Zend_View_Helper_MonitoringProperties extends Zend_View_Helper_Abstract * @var array */ private static $keys = array( - 'buildAttempt' => 'Current attempt', - 'last_check' => 'Last check time', - 'buildCheckType' => 'Check type', - 'buildLatency' => 'Check latency / duration', - 'buildNextCheck' => 'Next scheduled active check', - 'buildLastStateChange' => 'Last state change', - 'buildLastNotification' => 'Last notification', - 'buildFlapping' => 'Is this %s flapping?', + 'buildAttempt' => 'Current attempt', + 'last_check' => 'Last check time', + 'buildCheckType' => 'Check type', + 'buildLatency' => 'Check latency / duration', + 'buildNextCheck' => 'Next scheduled active check', + 'buildLastStateChange' => 'Last state change', + 'buildLastNotification' => 'Last notification', + 'buildFlapping' => 'Is this %s flapping?', 'buildScheduledDowntime' => 'In scheduled downtime?', - 'status_update_time' => 'Last update' + 'status_update_time' => 'Last update' ); /** diff --git a/modules/monitoring/application/views/scripts/show/components/comments.phtml b/modules/monitoring/application/views/scripts/show/components/comments.phtml index 2273fcaee..9bd3ceaff 100644 --- a/modules/monitoring/application/views/scripts/show/components/comments.phtml +++ b/modules/monitoring/application/views/scripts/show/components/comments.phtml @@ -1,5 +1,5 @@ -comments)) { ?> +comments)): ?> comments as $comment) { @@ -28,4 +28,4 @@ foreach ($this->comments as $comment) {
', $list) ?>
- \ No newline at end of file + \ 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 cb2effe0b..a396ed2d7 100644 --- a/modules/monitoring/application/views/scripts/show/components/downtime.phtml +++ b/modules/monitoring/application/views/scripts/show/components/downtime.phtml @@ -1,4 +1,4 @@ -downtimes)) { ?> +downtimes)): ?> downtimes as $downtime) { @@ -40,4 +40,4 @@ - \ No newline at end of file + \ No newline at end of file diff --git a/modules/monitoring/application/views/scripts/show/components/flags.phtml b/modules/monitoring/application/views/scripts/show/components/flags.phtml index 435cee465..9f83501cd 100644 --- a/modules/monitoring/application/views/scripts/show/components/flags.phtml +++ b/modules/monitoring/application/views/scripts/show/components/flags.phtml @@ -10,16 +10,16 @@ $flags = $this->monitoringFlags($object); ?> - $value) { ?> + $value): ?> - +
- + ENABLED - + DISABLED - +
\ 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 8d43736ad..51b7a0612 100644 --- a/modules/monitoring/application/views/scripts/show/components/properties.phtml +++ b/modules/monitoring/application/views/scripts/show/components/properties.phtml @@ -10,10 +10,10 @@ if (isset($this->service)) { $properties = $this->monitoringProperties($object); ?> - $value) { ?> + $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 a9d29fabe..324902105 100644 --- a/modules/monitoring/application/views/scripts/show/header.phtml +++ b/modules/monitoring/application/views/scripts/show/header.phtml @@ -17,7 +17,7 @@ if (!$this->compact) { } ?>
- +
monitoringCommands( @@ -26,35 +26,35 @@ if (!$this->compact) { ); ?>
- + @@ -91,9 +91,9 @@ if (!$this->compact) { diff --git a/modules/monitoring/application/views/scripts/show/host.phtml b/modules/monitoring/application/views/scripts/show/host.phtml index cc41be532..40ed03abc 100644 --- a/modules/monitoring/application/views/scripts/show/host.phtml +++ b/modules/monitoring/application/views/scripts/show/host.phtml @@ -52,10 +52,10 @@
Groups and Contacts
- + Hostgroups: - + render('show/components/contacts.phtml') ?> diff --git a/modules/monitoring/library/Monitoring/Backend/Ido/Query/DowntimeQuery.php b/modules/monitoring/library/Monitoring/Backend/Ido/Query/DowntimeQuery.php index 58097ce49..75f8f820d 100644 --- a/modules/monitoring/library/Monitoring/Backend/Ido/Query/DowntimeQuery.php +++ b/modules/monitoring/library/Monitoring/Backend/Ido/Query/DowntimeQuery.php @@ -26,7 +26,7 @@ namespace Icinga\Monitoring\Backend\Ido\Query; /** - * Class DowntimeQuery + * Handling downtime queries */ class DowntimeQuery extends AbstractQuery { @@ -36,25 +36,25 @@ class DowntimeQuery extends AbstractQuery */ protected $columnMap = array( 'downtime' => array( - 'downtime_type' => 'sd.downtime_type', - 'downtime_author_name' => 'sd.author_name', - 'downtime_comment_data' => 'sd.comment_data', - 'downtime_is_fixed' => 'sd.is_fixed', - 'downtime_duration' => 'sd.duration', - 'downtime_scheduled_start_time' => 'sd.scheduled_start_time', - 'downtime_scheduled_end_time' => 'sd.scheduled_end_time', - 'downtime_was_started' => 'sd.was_started', - 'downtime_actual_start_time' => 'sd.actual_start_time', + 'downtime_type' => 'sd.downtime_type', + 'downtime_author_name' => 'sd.author_name', + 'downtime_comment_data' => 'sd.comment_data', + 'downtime_is_fixed' => 'sd.is_fixed', + 'downtime_duration' => 'sd.duration', + 'downtime_scheduled_start_time' => 'sd.scheduled_start_time', + 'downtime_scheduled_end_time' => 'sd.scheduled_end_time', + 'downtime_was_started' => 'sd.was_started', + 'downtime_actual_start_time' => 'sd.actual_start_time', 'downtime_actual_start_time_usec' => 'sd.actual_start_time_usec', - 'downtime_is_in_effect' => 'sd.is_in_effect', - 'downtime_trigger_time' => 'sd.trigger_time', - 'downtime_internal_downtime_id' => 'sd.internal_downtime_id' + 'downtime_is_in_effect' => 'sd.is_in_effect', + 'downtime_trigger_time' => 'sd.trigger_time', + 'downtime_internal_downtime_id' => 'sd.internal_downtime_id' ), 'hosts' => array( 'host_name' => 'ho.name1', ), 'services' => array( - 'service_host_name' => 'so.name1', + 'service_host_name' => 'so.name1', 'service_description' => 'so.name2', ) ); diff --git a/modules/monitoring/library/Monitoring/Command/Meta.php b/modules/monitoring/library/Monitoring/Command/Meta.php index 3648fa703..50bdd03b4 100644 --- a/modules/monitoring/library/Monitoring/Command/Meta.php +++ b/modules/monitoring/library/Monitoring/Command/Meta.php @@ -29,8 +29,6 @@ use Icinga\Authentication\User; use Icinga\Exception\ProgrammingError; /** - * Class Meta - * * Deals with objects and available commands which can be used on the object */ class Meta diff --git a/modules/monitoring/library/Monitoring/View/DowntimeView.php b/modules/monitoring/library/Monitoring/View/DowntimeView.php index 4884db1f7..4504c6caf 100644 --- a/modules/monitoring/library/Monitoring/View/DowntimeView.php +++ b/modules/monitoring/library/Monitoring/View/DowntimeView.php @@ -25,7 +25,7 @@ namespace Icinga\Monitoring\View; /** - * Class DowntimeView + * View for downtimes */ class DowntimeView extends MonitoringView {
- host->host_icon_image) : ?> + host->host_icon_image): ?>
Host image
escape($this->host->host_name); ?> - host->host_address && $this->host->host_address !== $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) && $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); ?> - host->host_acknowledged === '1') { ?> + host->host_acknowledged === '1'): ?> (Has been acknowledged) - +
util()->getServiceStateName($this->service->service_state); ?> since timeSince($this->service->service_last_state_change); ?> - service->service_acknowledged === '1') { ?> + service->service_acknowledged === '1'): ?> (Has been acknowledged) - +