mirror of
https://github.com/Icinga/icingaweb2.git
synced 2025-07-13 17:04:24 +02:00
parent
533c980a29
commit
62d8c441f8
@ -49,6 +49,11 @@ class Monitoring_HostController extends MonitoredObjectController
|
|||||||
$this->getTabs()->activate('host');
|
$this->getTabs()->activate('host');
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get host actions from hook
|
||||||
|
*
|
||||||
|
* @return array
|
||||||
|
*/
|
||||||
protected function getHostActions()
|
protected function getHostActions()
|
||||||
{
|
{
|
||||||
$urls = array();
|
$urls = array();
|
||||||
@ -67,7 +72,7 @@ class Monitoring_HostController extends MonitoredObjectController
|
|||||||
*/
|
*/
|
||||||
public function showAction()
|
public function showAction()
|
||||||
{
|
{
|
||||||
$this->view->hostActions = $this->getHostActions();
|
$this->view->actions = $this->getHostActions();
|
||||||
parent::showAction();
|
parent::showAction();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -10,6 +10,7 @@ use Icinga\Module\Monitoring\Forms\Command\Object\ScheduleServiceDowntimeCommand
|
|||||||
use Icinga\Module\Monitoring\Forms\Command\Object\SendCustomNotificationCommandForm;
|
use Icinga\Module\Monitoring\Forms\Command\Object\SendCustomNotificationCommandForm;
|
||||||
use Icinga\Module\Monitoring\Object\Service;
|
use Icinga\Module\Monitoring\Object\Service;
|
||||||
use Icinga\Module\Monitoring\Web\Controller\MonitoredObjectController;
|
use Icinga\Module\Monitoring\Web\Controller\MonitoredObjectController;
|
||||||
|
use Icinga\Web\Hook;
|
||||||
|
|
||||||
class Monitoring_ServiceController extends MonitoredObjectController
|
class Monitoring_ServiceController extends MonitoredObjectController
|
||||||
{
|
{
|
||||||
@ -48,6 +49,34 @@ class Monitoring_ServiceController extends MonitoredObjectController
|
|||||||
$this->getTabs()->activate('service');
|
$this->getTabs()->activate('service');
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get service actions from hook
|
||||||
|
*
|
||||||
|
* @return array
|
||||||
|
*/
|
||||||
|
protected function getServiceActions()
|
||||||
|
{
|
||||||
|
$urls = array();
|
||||||
|
|
||||||
|
foreach (Hook::all('Monitoring\\ServiceActions') as $hook) {
|
||||||
|
foreach ($hook->getActionsForService($this->object) as $id => $url) {
|
||||||
|
$urls[$id] = $url;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return $urls;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Show a service
|
||||||
|
*/
|
||||||
|
public function showAction()
|
||||||
|
{
|
||||||
|
$this->view->actions = $this->getServiceActions();
|
||||||
|
parent::showAction();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Acknowledge a service problem
|
* Acknowledge a service problem
|
||||||
*/
|
*/
|
||||||
|
@ -33,8 +33,8 @@ if ($object->action_url) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (isset($this->hostActions)) {
|
if (isset($this->actions)) {
|
||||||
foreach ($this->hostActions as $id => $action) {
|
foreach ($this->actions as $id => $action) {
|
||||||
$links[] = sprintf($localLinkText, $action, $id);
|
$links[] = sprintf($localLinkText, $action, $id);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -0,0 +1,46 @@
|
|||||||
|
<?php
|
||||||
|
/* Icinga Web 2 | (c) 2013-2015 Icinga Development Team | GPLv2+ */
|
||||||
|
|
||||||
|
namespace Icinga\Module\Monitoring\Web\Hook;
|
||||||
|
|
||||||
|
use Icinga\Module\Monitoring\Object\Service;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Base class for host action hooks
|
||||||
|
*/
|
||||||
|
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:
|
||||||
|
* <code>
|
||||||
|
* return array(
|
||||||
|
* 'Wiki' => 'http://my.wiki/host=' . rawurlencode($service->service_name),
|
||||||
|
* 'Logstash' => Url::fromPath(
|
||||||
|
* 'logstash/search/syslog',
|
||||||
|
* array('service' => $service->host_name)
|
||||||
|
* )
|
||||||
|
* );
|
||||||
|
* </code>
|
||||||
|
*
|
||||||
|
* 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);
|
||||||
|
}
|
Loading…
x
Reference in New Issue
Block a user