summaryrefslogtreecommitdiffstats
path: root/application
diff options
context:
space:
mode:
authorDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-14 13:29:56 +0000
committerDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-14 13:29:56 +0000
commit01e5e7250560da81eaf37c5804f5cb4577095d01 (patch)
treea65fbd55f24f51d2397da13cf3e90ba3f98a29d4 /application
parentInitial commit. (diff)
downloadicingaweb2-module-statusmap-01e5e7250560da81eaf37c5804f5cb4577095d01.tar.xz
icingaweb2-module-statusmap-01e5e7250560da81eaf37c5804f5cb4577095d01.zip
Adding upstream version 20160720.upstream/20160720upstream
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'application')
-rw-r--r--application/controllers/IndexController.php59
-rw-r--r--application/views/scripts/index/index.phtml6
2 files changed, 65 insertions, 0 deletions
diff --git a/application/controllers/IndexController.php b/application/controllers/IndexController.php
new file mode 100644
index 0000000..705ed53
--- /dev/null
+++ b/application/controllers/IndexController.php
@@ -0,0 +1,59 @@
+<?php
+
+use Icinga\Data\Filter\Filter;
+use Icinga\Module\Monitoring\Controller as MonitoringController;
+use Icinga\Module\Monitoring\Object\HostList;
+use Icinga\Web\Url;
+
+class StatusMap_IndexController extends MonitoringController {
+
+ protected $hostList;
+
+ public function init() {
+ $this->hostList = new HostList($this->backend);
+ $this->hostList->addFilter(Filter::matchAll());
+
+ $this->getTabs()->add(
+ 'show',
+ array(
+ 'title' => 'Show Status Map',
+ 'label' => 'Status Map',
+ 'url' => Url::fromRequest(),
+ )
+ )->activate('show');
+ }
+
+ public function indexAction() {
+ $this->hostList->setColumns(array(
+ 'host_name',
+ 'host_display_name',
+ 'host_state',
+ ));
+
+ $hosts = $this->hostList->fetch();
+
+ $dependencies = $this->backend->select()
+ ->from('hostdependency', array('host_name', 'dependent_host_name'))
+ ->fetchAll();
+
+ $data_dep = array();
+ foreach ($dependencies as $dependency) {
+ $data_dep[] = array(
+ 'parent' => $dependency->host_name,
+ 'child' => $dependency->dependent_host_name,
+ );
+ }
+ $this->view->data_dependencies = json_encode($data_dep);
+
+ $data_hosts = array();
+ foreach ($hosts as $host) {
+ $data_hosts[] = array(
+ 'host_name' => $host->host_name,
+ 'display_name' => $host->host_display_name,
+ 'state' => (int) $host->host_state,
+ );
+ }
+ $this->view->data_hosts = json_encode($data_hosts);
+ }
+
+}
diff --git a/application/views/scripts/index/index.phtml b/application/views/scripts/index/index.phtml
new file mode 100644
index 0000000..6402d71
--- /dev/null
+++ b/application/views/scripts/index/index.phtml
@@ -0,0 +1,6 @@
+<div class="controls">
+ <?= $this->tabs ?>
+</div>
+<div class="content" style="width:100%; height:100%;">
+ <div id="yolocontainer" data-hosts="<?= $this->escape($data_hosts); ?>" data-dependencies="<?= $this->escape($data_dependencies); ?>" style="width: 100%;height:100%;"></div>
+</div>