From ffe17cf58ca6e586e8fd3ab6c2c4ba6d0dcf3bfb Mon Sep 17 00:00:00 2001 From: Thomas Gelf Date: Thu, 26 Nov 2015 18:55:00 +0100 Subject: [PATCH] ServiceActions: newly introduced, provide "inspect" --- .../Monitoring/ServiceActions.php | 41 +++++++++++++++++++ run.php | 1 + 2 files changed, 42 insertions(+) create mode 100644 library/Director/ProvidedHook/Monitoring/ServiceActions.php diff --git a/library/Director/ProvidedHook/Monitoring/ServiceActions.php b/library/Director/ProvidedHook/Monitoring/ServiceActions.php new file mode 100644 index 00000000..6f35bc05 --- /dev/null +++ b/library/Director/ProvidedHook/Monitoring/ServiceActions.php @@ -0,0 +1,41 @@ +db(); + if (IcingaHost::exists($service->host_name, $db)) { + return array( + 'Inspect' => Url::fromPath( + 'director/inspect/object', + array( + 'type' => 'service', + 'plural' => 'services', + 'name' => sprintf( + '%s!%s', + $service->host_name, + $service->service_description + ) + ) + ) + ); + } else { + return array(); + } + } + + protected function db() + { + return Db::fromResourceName(Config::module('director')->get('db', 'resource')); + } +} diff --git a/run.php b/run.php index 81805aec..53775ce2 100644 --- a/run.php +++ b/run.php @@ -1,6 +1,7 @@ provideHook('monitoring/HostActions'); +$this->provideHook('monitoring/ServiceActions'); $this->registerHook('Director\\ImportSource', '\\Icinga\\Module\\Director\\Import\\ImportSourceSql', 'sql'); $this->registerHook('Director\\ImportSource', '\\Icinga\\Module\\Director\\Import\\ImportSourceLdap', 'ldap');