ServiceActions: newly introduced, provide "inspect"

This commit is contained in:
Thomas Gelf 2015-11-26 18:55:00 +01:00
parent 9ac82db6ef
commit ffe17cf58c
2 changed files with 42 additions and 0 deletions

View File

@ -0,0 +1,41 @@
<?php
namespace Icinga\Module\Director\ProvidedHook\Monitoring;
use Icinga\Application\Config;
use Icinga\Module\Director\Db;
use Icinga\Module\Director\Objects\IcingaHost;
use Icinga\Module\Monitoring\Web\Hook\ServiceActionsHook;
use Icinga\Module\Monitoring\Object\Service;
use Icinga\Web\Url;
class ServiceActions extends ServiceActionsHook
{
public function getActionsForService(Service $service)
{
$db = $this->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'));
}
}

View File

@ -1,6 +1,7 @@
<?php <?php
$this->provideHook('monitoring/HostActions'); $this->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\\ImportSourceSql', 'sql');
$this->registerHook('Director\\ImportSource', '\\Icinga\\Module\\Director\\Import\\ImportSourceLdap', 'ldap'); $this->registerHook('Director\\ImportSource', '\\Icinga\\Module\\Director\\Import\\ImportSourceLdap', 'ldap');