ServiceActions: newly introduced, provide "inspect"
This commit is contained in:
parent
9ac82db6ef
commit
ffe17cf58c
|
@ -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'));
|
||||||
|
}
|
||||||
|
}
|
1
run.php
1
run.php
|
@ -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');
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue