summaryrefslogtreecommitdiffstats
path: root/library/Cube/ProvidedHook/Cube/IcingaDbActions.php
diff options
context:
space:
mode:
Diffstat (limited to 'library/Cube/ProvidedHook/Cube/IcingaDbActions.php')
-rw-r--r--library/Cube/ProvidedHook/Cube/IcingaDbActions.php48
1 files changed, 48 insertions, 0 deletions
diff --git a/library/Cube/ProvidedHook/Cube/IcingaDbActions.php b/library/Cube/ProvidedHook/Cube/IcingaDbActions.php
new file mode 100644
index 0000000..1fbd05d
--- /dev/null
+++ b/library/Cube/ProvidedHook/Cube/IcingaDbActions.php
@@ -0,0 +1,48 @@
+<?php
+
+namespace Icinga\Module\Cube\ProvidedHook\Cube;
+
+use Icinga\Module\Cube\Hook\IcingaDbActionsHook;
+use Icinga\Module\Cube\IcingaDb\IcingaDbCube;
+use Icinga\Module\Cube\IcingaDb\IcingaDbServiceStatusCube;
+use ipl\Stdlib\Filter;
+use ipl\Web\Url;
+
+class IcingaDbActions extends IcingaDbActionsHook
+{
+ public function createActionLinks(IcingaDbCube $cube)
+ {
+ $type = 'host';
+ if ($cube instanceof IcingaDbServiceStatusCube) {
+ $type = 'service';
+ }
+
+ $filter = Filter::all();
+ if ($cube->hasBaseFilter()) {
+ $filter->add($cube->getBaseFilter());
+ }
+
+ foreach ($cube->getSlices() as $dimension => $slice) {
+ $filter->add(Filter::equal($dimension, $slice));
+ }
+
+ $url = Url::fromPath('icingadb/' . $type . 's');
+ $url->setFilter($filter);
+
+ if ($type === 'host') {
+ $this->addActionLink(
+ $url,
+ t('Show hosts status'),
+ t('This shows all matching hosts and their current state in Icinga DB Web'),
+ 'server'
+ );
+ } else {
+ $this->addActionLink(
+ $url,
+ t('Show services status'),
+ t('This shows all matching hosts and their current state in Icinga DB Web'),
+ 'cog'
+ );
+ }
+ }
+}