From 0d606dfc06e8c536c2bdb4e71d6d0fa594af1bea Mon Sep 17 00:00:00 2001 From: "Alexander A. Klimov" Date: Thu, 31 Aug 2017 17:12:26 +0200 Subject: [PATCH 01/15] /list/hosts refs #27 --- application/controllers/ListController.php | 30 +++++++++++++ application/views/scripts/list/hosts.phtml | 51 ++++++++++++++++++++++ application/views/scripts/show/host.phtml | 10 +++++ 3 files changed, 91 insertions(+) create mode 100644 application/controllers/ListController.php create mode 100644 application/views/scripts/list/hosts.phtml diff --git a/application/controllers/ListController.php b/application/controllers/ListController.php new file mode 100644 index 0000000..4608d7c --- /dev/null +++ b/application/controllers/ListController.php @@ -0,0 +1,30 @@ +view->hosts = $hosts = $this->backend->select()->from('hoststatus', ['host_name', 'host_display_name']); + $this->applyRestriction('monitoring/filter/objects', $hosts); + $this->filterQuery($hosts); + $this->setupPaginationControl($hosts); + $this->setupLimitControl(); + $this->setupSortControl(['host_display_name' => mt('monitoring', 'Hostname')], $hosts); + } + + /** + * Apply filters on a DataView + * + * @param DataView $dataView The DataView to apply filters on + */ + protected function filterQuery(DataView $dataView) + { + $this->setupFilterControl($dataView, null, null, ['format', 'stateType', 'addColumns', 'problems']); + $this->handleFormatRequest($dataView); + } +} diff --git a/application/views/scripts/list/hosts.phtml b/application/views/scripts/list/hosts.phtml new file mode 100644 index 0000000..8e65867 --- /dev/null +++ b/application/views/scripts/list/hosts.phtml @@ -0,0 +1,51 @@ + +
+ + +
+ + +
+ +
+ +
+hasResult()): ?> +

+
+ +peekAhead($compact) as $host): ?> +

qlink( + $host->host_name === $host->host_display_name + ? $host->host_display_name + : $host->host_display_name . ' (' . $this->escape($host->host_name) . ')', + Url::fromPath('monitoring/host/show', ['host' => $host->host_name]) + ) ?>

+
is enough", but this seems not to work for me + $this->href('graphite/show/host', [ + 'host' => $host->host_name, + 'view' => 'compact' + ]) + ?>">
+ +hasMore()): ?> + + + diff --git a/application/views/scripts/show/host.phtml b/application/views/scripts/show/host.phtml index d6dc97c..8b4a99e 100644 --- a/application/views/scripts/show/host.phtml +++ b/application/views/scripts/show/host.phtml @@ -1,7 +1,12 @@ +
tabs ?>

hostname ?>

+
images as $type => $imgs): ?> @@ -23,4 +28,9 @@ + + +

translate('No graphs found') ?>

+ +
From e4a58c4568f4baac59aec66451f1b387dc8d2771 Mon Sep 17 00:00:00 2001 From: "Alexander A. Klimov" Date: Thu, 31 Aug 2017 17:43:52 +0200 Subject: [PATCH 02/15] /list/services refs #27 --- application/controllers/ListController.php | 18 ++++++ application/views/scripts/list/services.phtml | 60 +++++++++++++++++++ application/views/scripts/show/service.phtml | 10 ++++ 3 files changed, 88 insertions(+) create mode 100644 application/views/scripts/list/services.phtml diff --git a/application/controllers/ListController.php b/application/controllers/ListController.php index 4608d7c..852b09e 100644 --- a/application/controllers/ListController.php +++ b/application/controllers/ListController.php @@ -17,6 +17,24 @@ class ListController extends Controller $this->setupSortControl(['host_display_name' => mt('monitoring', 'Hostname')], $hosts); } + public function servicesAction() + { + $this->view->services = $services = $this->backend->select()->from('servicestatus', [ + 'host_name', + 'host_display_name', + 'service_description', + 'service_display_name' + ]); + $this->applyRestriction('monitoring/filter/objects', $services); + $this->filterQuery($services); + $this->setupPaginationControl($services); + $this->setupLimitControl(); + $this->setupSortControl([ + 'service_display_name' => mt('monitoring', 'Service Name'), + 'host_display_name' => mt('monitoring', 'Hostname') + ], $services); + } + /** * Apply filters on a DataView * diff --git a/application/views/scripts/list/services.phtml b/application/views/scripts/list/services.phtml new file mode 100644 index 0000000..ec9ca0d --- /dev/null +++ b/application/views/scripts/list/services.phtml @@ -0,0 +1,60 @@ + +
+ + +
+ + +
+ +
+ +
+hasResult()): ?> +

+
+ +peekAhead($compact) as $service): ?> +

qlink( + $service->host_name === $service->host_display_name + ? $service->host_display_name + : $service->host_display_name . ' (' . $this->escape($service->host_name) . ')', + Url::fromPath('monitoring/host/show', ['host' => $service->host_name]) + ) ?>: qlink( + $service->service_description === $service->service_display_name + ? $service->service_display_name + : $service->service_display_name . ' (' . $this->escape($service->service_description) . ')', + Url::fromPath('monitoring/service/show', [ + 'host' => $service->host_name, + 'service' => $service->service_description + ]) + ) ?>

+
is enough", but this seems not to work for me + $this->href('graphite/show/service', [ + 'host' => $service->host_name, + 'service' => $service->service_description, + 'view' => 'compact' + ]) + ?>">
+ +hasMore()): ?> + + + diff --git a/application/views/scripts/show/service.phtml b/application/views/scripts/show/service.phtml index f072481..e29c35c 100644 --- a/application/views/scripts/show/service.phtml +++ b/application/views/scripts/show/service.phtml @@ -1,7 +1,12 @@ +
tabs ?>

hostname ?>: service ?>

+
images as $type => $imgs): ?> @@ -23,4 +28,9 @@ + + +

translate('No graphs found') ?>

+ +
From 6c59b145fbee12232bf8c5374c39d8da55e0ff91 Mon Sep 17 00:00:00 2001 From: "Alexander A. Klimov" Date: Fri, 1 Sep 2017 17:00:20 +0200 Subject: [PATCH 03/15] /list/*: fix missing navigation refs #27 --- application/controllers/ListController.php | 30 ++++++++++++++++++++++ configuration.php | 5 +++- 2 files changed, 34 insertions(+), 1 deletion(-) diff --git a/application/controllers/ListController.php b/application/controllers/ListController.php index 852b09e..7e60b47 100644 --- a/application/controllers/ListController.php +++ b/application/controllers/ListController.php @@ -4,11 +4,18 @@ namespace Icinga\Module\Graphite\Controllers; use Icinga\Module\Monitoring\Controller; use Icinga\Module\Monitoring\DataView\DataView; +use Icinga\Web\Url; class ListController extends Controller { public function hostsAction() { + $this->addTitleTab( + 'hosts', + mt('monitoring', 'Hosts'), + mt('monitoring', 'List hosts') + ); + $this->view->hosts = $hosts = $this->backend->select()->from('hoststatus', ['host_name', 'host_display_name']); $this->applyRestriction('monitoring/filter/objects', $hosts); $this->filterQuery($hosts); @@ -19,6 +26,12 @@ class ListController extends Controller public function servicesAction() { + $this->addTitleTab( + 'services', + mt('monitoring', 'Services'), + mt('monitoring', 'List services') + ); + $this->view->services = $services = $this->backend->select()->from('servicestatus', [ 'host_name', 'host_display_name', @@ -45,4 +58,21 @@ class ListController extends Controller $this->setupFilterControl($dataView, null, null, ['format', 'stateType', 'addColumns', 'problems']); $this->handleFormatRequest($dataView); } + + /** + * Add title tab + * + * @param string $action + * @param string $title + * @param string $tip + */ + protected function addTitleTab($action, $title, $tip) + { + $this->getTabs()->add($action, [ + 'title' => $tip, + 'label' => $title, + 'url' => Url::fromRequest(), + 'active' => true + ]); + } } diff --git a/configuration.php b/configuration.php index 52470fd..6d39c75 100644 --- a/configuration.php +++ b/configuration.php @@ -2,7 +2,10 @@ /** @var \Icinga\Application\Modules\Module $this */ -$this->menuSection(N_('Graphite'), ['icon' => 'chart-area'])->setUrl('graphite/show/overview'); +/** @var \Icinga\Application\Modules\MenuItemContainer $section */ +$section = $this->menuSection(N_('Graphite'), ['icon' => 'chart-area'])->setUrl('graphite/show/overview'); +$section->add(N_('Hosts'), ['url' => 'graphite/list/hosts']); +$section->add(N_('Services'), ['url' => 'graphite/list/services']); $this->provideConfigTab('backend', array( 'title' => $this->translate('Configure the Graphite Web backend'), From 1f03b999c09d7e1e3728170c841022120cd9692e Mon Sep 17 00:00:00 2001 From: "Alexander A. Klimov" Date: Fri, 1 Sep 2017 18:05:36 +0200 Subject: [PATCH 04/15] Display monitored objects' graphs in their detail views refs #27 --- application/views/scripts/list/hosts.phtml | 10 +-- application/views/scripts/list/services.phtml | 11 +-- library/Graphite/EmbedGraphs.php | 67 +++++++++++++++++++ .../Monitoring/DetailviewExtension.php | 34 ++++++++++ run.php | 3 +- 5 files changed, 109 insertions(+), 16 deletions(-) create mode 100644 library/Graphite/EmbedGraphs.php create mode 100644 library/Graphite/ProvidedHook/Monitoring/DetailviewExtension.php diff --git a/application/views/scripts/list/hosts.phtml b/application/views/scripts/list/hosts.phtml index 8e65867..d012cbd 100644 --- a/application/views/scripts/list/hosts.phtml +++ b/application/views/scripts/list/hosts.phtml @@ -1,4 +1,6 @@ : $host->host_display_name . ' (' . $this->escape($host->host_name) . ')', Url::fromPath('monitoring/host/show', ['host' => $host->host_name]) ) ?> -
is enough", but this seems not to work for me - $this->href('graphite/show/host', [ - 'host' => $host->host_name, - 'view' => 'compact' - ]) - ?>">
+ host_name) ?> hasMore()): ?>