From e6903b3834d5826c558192b44cae2416742e3c20 Mon Sep 17 00:00:00 2001 From: Thomas Gelf Date: Thu, 12 Nov 2015 18:06:59 +0100 Subject: [PATCH] Monitoring\Hook: moved from Monitoring\Web\Hook refs #10613 --- .../Monitoring/Hook/HostActionsHook.php | 46 +++++++++++++++++++ .../Monitoring/Hook/ServiceActionsHook.php | 46 +++++++++++++++++++ .../Monitoring/Hook/TimelineProviderHook.php | 37 +++++++++++++++ .../Monitoring/Web/Hook/HostActionsHook.php | 43 ++--------------- .../Web/Hook/ServiceActionsHook.php | 43 ++--------------- .../Web/Hook/TimelineProviderHook.php | 34 ++------------ 6 files changed, 144 insertions(+), 105 deletions(-) create mode 100644 modules/monitoring/library/Monitoring/Hook/HostActionsHook.php create mode 100644 modules/monitoring/library/Monitoring/Hook/ServiceActionsHook.php create mode 100644 modules/monitoring/library/Monitoring/Hook/TimelineProviderHook.php diff --git a/modules/monitoring/library/Monitoring/Hook/HostActionsHook.php b/modules/monitoring/library/Monitoring/Hook/HostActionsHook.php new file mode 100644 index 000000000..b7923bcc8 --- /dev/null +++ b/modules/monitoring/library/Monitoring/Hook/HostActionsHook.php @@ -0,0 +1,46 @@ + url, where title will + * be used as link caption. Url should be an Icinga\Web\Url object when + * the link should point to an Icinga Web url - otherwise a string would + * be fine. + * + * Mixed example: + * + * return array( + * 'Wiki' => 'http://my.wiki/host=' . rawurlencode($host->host_name), + * 'Logstash' => Url::fromPath( + * 'logstash/search/syslog', + * array('host' => $host->host_name) + * ) + * ); + * + * + * One might also provide ssh:// or rdp:// urls if equipped with fitting + * (safe) URL handlers for his browser(s). + * + * TODO: I'd love to see some kind of a Link/LinkSet object implemented + * for this and similar hooks. + * + * @param Host $host Monitoring host object + * + * @return array An array containing a list of host action links + */ + abstract public function getActionsForHost(Host $host); +} diff --git a/modules/monitoring/library/Monitoring/Hook/ServiceActionsHook.php b/modules/monitoring/library/Monitoring/Hook/ServiceActionsHook.php new file mode 100644 index 000000000..6c1ef25ce --- /dev/null +++ b/modules/monitoring/library/Monitoring/Hook/ServiceActionsHook.php @@ -0,0 +1,46 @@ + url, where title will + * be used as link caption. Url should be an Icinga\Web\Url object when + * the link should point to an Icinga Web url - otherwise a string would + * be fine. + * + * Mixed example: + * + * return array( + * 'Wiki' => 'http://my.wiki/host=' . rawurlencode($service->service_name), + * 'Logstash' => Url::fromPath( + * 'logstash/search/syslog', + * array('service' => $service->host_name) + * ) + * ); + * + * + * One might also provide ssh:// or rdp:// urls if equipped with fitting + * (safe) URL handlers for his browser(s). + * + * TODO: I'd love to see some kind of a Link/LinkSet object implemented + * for this and similar hooks. + * + * @param Service $service Monitoring service object + * + * @return array An array containing a list of service action links + */ + abstract public function getActionsForService(Service $service); +} diff --git a/modules/monitoring/library/Monitoring/Hook/TimelineProviderHook.php b/modules/monitoring/library/Monitoring/Hook/TimelineProviderHook.php new file mode 100644 index 000000000..2b9524828 --- /dev/null +++ b/modules/monitoring/library/Monitoring/Hook/TimelineProviderHook.php @@ -0,0 +1,37 @@ + url, where title will - * be used as link caption. Url should be an Icinga\Web\Url object when - * the link should point to an Icinga Web url - otherwise a string would - * be fine. - * - * Mixed example: - * - * return array( - * 'Wiki' => 'http://my.wiki/host=' . rawurlencode($host->host_name), - * 'Logstash' => Url::fromPath( - * 'logstash/search/syslog', - * array('host' => $host->host_name) - * ) - * ); - * - * - * One might also provide ssh:// or rdp:// urls if equipped with fitting - * (safe) URL handlers for his browser(s). - * - * TODO: I'd love to see some kind of a Link/LinkSet object implemented - * for this and similar hooks. - * - * @param Host $host Monitoring host object - * - * @return array An array containing a list of host action links - */ - abstract public function getActionsForHost(Host $host); -} +abstract class HostActionsHook extends BaseHook {} diff --git a/modules/monitoring/library/Monitoring/Web/Hook/ServiceActionsHook.php b/modules/monitoring/library/Monitoring/Web/Hook/ServiceActionsHook.php index 2df3c4f55..25ec269f0 100644 --- a/modules/monitoring/library/Monitoring/Web/Hook/ServiceActionsHook.php +++ b/modules/monitoring/library/Monitoring/Web/Hook/ServiceActionsHook.php @@ -3,44 +3,11 @@ namespace Icinga\Module\Monitoring\Web\Hook; -use Icinga\Module\Monitoring\Object\Service; +use Icinga\Module\Monitoring\Hook\HostActionsHook as BaseHook; /** - * Base class for host action hooks + * Compat only + * + * Please implement hooks in our Hook direcory */ -abstract class ServiceActionsHook -{ - /** - * Implementors of this method should return an array containing - * additional action links for a specific host. You get a full Service - * object, which allows you to return specific links only for nodes - * with specific properties. - * - * The result array should be in the form title => url, where title will - * be used as link caption. Url should be an Icinga\Web\Url object when - * the link should point to an Icinga Web url - otherwise a string would - * be fine. - * - * Mixed example: - * - * return array( - * 'Wiki' => 'http://my.wiki/host=' . rawurlencode($service->service_name), - * 'Logstash' => Url::fromPath( - * 'logstash/search/syslog', - * array('service' => $service->host_name) - * ) - * ); - * - * - * One might also provide ssh:// or rdp:// urls if equipped with fitting - * (safe) URL handlers for his browser(s). - * - * TODO: I'd love to see some kind of a Link/LinkSet object implemented - * for this and similar hooks. - * - * @param Service $service Monitoring service object - * - * @return array An array containing a list of service action links - */ - abstract public function getActionsForService(Service $service); -} +abstract class ServiceActionsHook extends BaseHook {} diff --git a/modules/monitoring/library/Monitoring/Web/Hook/TimelineProviderHook.php b/modules/monitoring/library/Monitoring/Web/Hook/TimelineProviderHook.php index 0af65d303..265e6894d 100644 --- a/modules/monitoring/library/Monitoring/Web/Hook/TimelineProviderHook.php +++ b/modules/monitoring/library/Monitoring/Web/Hook/TimelineProviderHook.php @@ -3,35 +3,11 @@ namespace Icinga\Module\Monitoring\Web\Hook; -use Icinga\Module\Monitoring\Timeline\TimeRange; +use Icinga\Module\Monitoring\Hook\HostActionsHook as BaseHook; /** - * Base class for TimeLine providers + * Compat only + * + * Please implement hooks in our Hook direcory */ -abstract class TimelineProviderHook -{ - /** - * Return the names by which to group entries - * - * @return array An array with the names as keys and their attribute-lists as values - */ - abstract public function getIdentifiers(); - - /** - * Return the visible entries supposed to be shown on the timeline - * - * @param TimeRange $range The range of time for which to fetch entries - * - * @return array The entries to display on the timeline - */ - abstract public function fetchEntries(TimeRange $range); - - /** - * Return the entries supposed to be used to calculate forecasts - * - * @param TimeRange $range The range of time for which to fetch forecasts - * - * @return array The entries to calculate forecasts with - */ - abstract public function fetchForecasts(TimeRange $range); -} +abstract class TimelineProviderHook extends BaseHook {}