mirror of
https://github.com/Icinga/icingaweb2-module-businessprocess.git
synced 2025-12-20 23:00:16 -05:00
NodeController: add business impact action
Show all paths to a specific node to visualize it's business impact fixes #8573
This commit is contained in:
parent
6155bb5e2b
commit
b3df39d1b0
6 changed files with 126 additions and 3 deletions
50
application/controllers/NodeController.php
Normal file
50
application/controllers/NodeController.php
Normal file
|
|
@ -0,0 +1,50 @@
|
||||||
|
<?php
|
||||||
|
|
||||||
|
namespace Icinga\Module\Businessprocess\Controllers;
|
||||||
|
|
||||||
|
use Icinga\Module\Businessprocess\Renderer\Breadcrumb;
|
||||||
|
use Icinga\Module\Businessprocess\Renderer\TileRenderer;
|
||||||
|
use Icinga\Module\Businessprocess\Web\Controller;
|
||||||
|
use Icinga\Module\Businessprocess\Web\Url;
|
||||||
|
|
||||||
|
class NodeController extends Controller
|
||||||
|
{
|
||||||
|
public function impactAction()
|
||||||
|
{
|
||||||
|
$content = $this->content();
|
||||||
|
$this->controls()->add(
|
||||||
|
$this->singleTab($this->translate('Node Impact'))
|
||||||
|
);
|
||||||
|
$name = $this->params->get('name');
|
||||||
|
$this->addTitle($this->translate('Business Impact (%s)'), $name);
|
||||||
|
|
||||||
|
foreach ($this->storage()->listProcessNames() as $configName) {
|
||||||
|
$config = $this->storage()->loadProcess($configName);
|
||||||
|
|
||||||
|
// TODO: Fix issues with children, they do not exist unless resolved :-/
|
||||||
|
// This is a workaround:
|
||||||
|
foreach ($config->getRootNodes() as $node) {
|
||||||
|
$node->getState();
|
||||||
|
}
|
||||||
|
|
||||||
|
if (! $config->hasNode($name)) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
foreach ($config->getNode($name)->getPaths() as $path) {
|
||||||
|
$node = array_pop($path);
|
||||||
|
$renderer = new TileRenderer($config, $config->getNode($node));
|
||||||
|
$renderer->setUrl(
|
||||||
|
Url::fromPath(
|
||||||
|
'businessprocess/process/show',
|
||||||
|
array('config' => $configName)
|
||||||
|
)
|
||||||
|
)->setPath($path);
|
||||||
|
|
||||||
|
$bc = Breadcrumb::create($renderer);
|
||||||
|
$bc->attributes()->set('data-base-target', '_next');
|
||||||
|
$content->add($bc);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
@ -309,15 +309,33 @@ abstract class Node
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return Node[]
|
||||||
|
*/
|
||||||
public function getParents()
|
public function getParents()
|
||||||
{
|
{
|
||||||
return $this->parents;
|
return $this->parents;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return array
|
||||||
|
*/
|
||||||
public function getPaths()
|
public function getPaths()
|
||||||
{
|
{
|
||||||
|
if ($this->bp->hasRootNode($this->getName())) {
|
||||||
|
return array(array($this->getName()));
|
||||||
|
}
|
||||||
|
|
||||||
|
$paths = array();
|
||||||
|
foreach ($this->parents as $parent) {
|
||||||
|
foreach ($parent->getPaths() as $path) {
|
||||||
|
// $path[] = $this->getName();
|
||||||
|
$paths[] = $path;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
// TODO! -> for delete etc
|
// TODO! -> for delete etc
|
||||||
return $this->parents;
|
return $paths;
|
||||||
}
|
}
|
||||||
|
|
||||||
protected function stateToSortState($state)
|
protected function stateToSortState($state)
|
||||||
|
|
|
||||||
|
|
@ -0,0 +1,18 @@
|
||||||
|
<?php
|
||||||
|
|
||||||
|
namespace Icinga\Module\Businessprocess\ProvidedHook\Monitoring;
|
||||||
|
|
||||||
|
use Icinga\Module\Monitoring\Hook\HostActionsHook;
|
||||||
|
use Icinga\Module\Monitoring\Object\Host;
|
||||||
|
|
||||||
|
class HostActions extends HostActionsHook
|
||||||
|
{
|
||||||
|
public function getActionsForHost(Host $host)
|
||||||
|
{
|
||||||
|
$label = mt('businessprocess', 'Business Impact');
|
||||||
|
return array(
|
||||||
|
$label => 'businessprocess/node/impact?name='
|
||||||
|
. rawurlencode($host->getName() . ';Hoststatus')
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,25 @@
|
||||||
|
<?php
|
||||||
|
|
||||||
|
namespace Icinga\Module\Businessprocess\ProvidedHook\Monitoring;
|
||||||
|
|
||||||
|
use Exception;
|
||||||
|
use Icinga\Application\Config;
|
||||||
|
use Icinga\Module\Monitoring\Hook\ServiceActionsHook;
|
||||||
|
use Icinga\Module\Monitoring\Object\Service;
|
||||||
|
use Icinga\Web\Url;
|
||||||
|
|
||||||
|
class ServiceActions extends ServiceActionsHook
|
||||||
|
{
|
||||||
|
public function getActionsForService(Service $service)
|
||||||
|
{
|
||||||
|
$label = mt('businessprocess', 'Business Impact');
|
||||||
|
return array(
|
||||||
|
$label => sprintf(
|
||||||
|
'businessprocess/node/impact?name=%s',
|
||||||
|
rawurlencode(
|
||||||
|
sprintf('%s;%s', $service->getHost()->getName(), $service->getName())
|
||||||
|
)
|
||||||
|
)
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
@ -4,6 +4,7 @@ namespace Icinga\Module\Businessprocess\Web;
|
||||||
|
|
||||||
use Icinga\Application\Icinga;
|
use Icinga\Application\Icinga;
|
||||||
use Icinga\Module\Businessprocess\BusinessProcess;
|
use Icinga\Module\Businessprocess\BusinessProcess;
|
||||||
|
use Icinga\Module\Businessprocess\Html\HtmlTag;
|
||||||
use Icinga\Module\Businessprocess\Modification\ProcessChanges;
|
use Icinga\Module\Businessprocess\Modification\ProcessChanges;
|
||||||
use Icinga\Module\Businessprocess\Storage\LegacyStorage;
|
use Icinga\Module\Businessprocess\Storage\LegacyStorage;
|
||||||
use Icinga\Module\Businessprocess\Storage\Storage;
|
use Icinga\Module\Businessprocess\Storage\Storage;
|
||||||
|
|
@ -42,8 +43,8 @@ class Controller extends ModuleController
|
||||||
if (! $m->hasLoaded('monitoring') && $m->hasInstalled('monitoring')) {
|
if (! $m->hasLoaded('monitoring') && $m->hasInstalled('monitoring')) {
|
||||||
$m->loadModule('monitoring');
|
$m->loadModule('monitoring');
|
||||||
}
|
}
|
||||||
$this->view->errors = array();
|
$this->controls();
|
||||||
|
$this->content();
|
||||||
$this->url();
|
$this->url();
|
||||||
$this->view->showFullscreen
|
$this->view->showFullscreen
|
||||||
= $this->showFullscreen
|
= $this->showFullscreen
|
||||||
|
|
@ -175,6 +176,15 @@ class Controller extends ModuleController
|
||||||
return $this;
|
return $this;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
protected function addTitle($title)
|
||||||
|
{
|
||||||
|
$args = func_get_args();
|
||||||
|
array_shift($args);
|
||||||
|
$this->view->title = vsprintf($title, $args);
|
||||||
|
$this->controls()->add(HtmlTag::h1($this->view->title));
|
||||||
|
return $this;
|
||||||
|
}
|
||||||
|
|
||||||
protected function loadModifiedBpConfig()
|
protected function loadModifiedBpConfig()
|
||||||
{
|
{
|
||||||
$bp = $this->loadBpConfig();
|
$bp = $this->loadBpConfig();
|
||||||
|
|
|
||||||
2
run.php
2
run.php
|
|
@ -1,3 +1,5 @@
|
||||||
<?php
|
<?php
|
||||||
|
|
||||||
|
$this->provideHook('monitoring/HostActions');
|
||||||
|
$this->provideHook('monitoring/ServiceActions');
|
||||||
//$this->provideHook('director/shipConfigFiles');
|
//$this->provideHook('director/shipConfigFiles');
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue