commit
d8bbd7a0a0
|
@ -740,18 +740,6 @@ file { '/etc/icingaweb/modules/monitoring/instances.ini':
|
|||
group => 'apache',
|
||||
}
|
||||
|
||||
file { '/etc/icingaweb/dashboard':
|
||||
ensure => 'directory',
|
||||
owner => 'apache',
|
||||
group => 'apache',
|
||||
}
|
||||
|
||||
file { '/etc/icingaweb/dashboard/dashboard.ini':
|
||||
source => 'puppet:////vagrant/config/dashboard/dashboard.ini',
|
||||
owner => 'apache',
|
||||
group => 'apache',
|
||||
}
|
||||
|
||||
# pear::package { 'deepend/Mockery':
|
||||
# channel => 'pear.survivethedeepend.com'
|
||||
# }
|
||||
|
|
|
@ -111,19 +111,23 @@ class DashboardController extends ActionController
|
|||
*/
|
||||
public function indexAction()
|
||||
{
|
||||
$dashboard = $this->getDashboard();
|
||||
if ($this->_getParam('pane')) {
|
||||
$pane = $this->_getParam('pane');
|
||||
$dashboard->activate($pane);
|
||||
}
|
||||
$dashboard = Dashboard::load();
|
||||
|
||||
$this->view->configPath = IcingaConfig::resolvePath(self::DEFAULT_CONFIG);
|
||||
|
||||
if ($dashboard === null) {
|
||||
if (! $dashboard->hasPanes()) {
|
||||
$this->view->title = 'Dashboard';
|
||||
} else {
|
||||
$this->view->title = $dashboard->getActivePane()->getTitle() . ' :: Dashboard';
|
||||
$this->view->tabs = $dashboard->getTabs();
|
||||
if ($this->_getParam('pane')) {
|
||||
$pane = $this->_getParam('pane');
|
||||
$dashboard->activate($pane);
|
||||
}
|
||||
|
||||
$this->view->configPath = IcingaConfig::resolvePath(self::DEFAULT_CONFIG);
|
||||
|
||||
if ($dashboard === null) {
|
||||
$this->view->title = 'Dashboard';
|
||||
} else {
|
||||
$this->view->title = $dashboard->getActivePane()->getTitle() . ' :: Dashboard';
|
||||
$this->view->tabs = $dashboard->getTabs();
|
||||
|
||||
/* Temporarily removed
|
||||
$this->view->tabs->add(
|
||||
|
@ -135,8 +139,8 @@ class DashboardController extends ActionController
|
|||
);
|
||||
*/
|
||||
|
||||
$this->view->dashboard = $dashboard;
|
||||
|
||||
$this->view->dashboard = $dashboard;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -2,6 +2,11 @@
|
|||
<?= $this->tabs ?>
|
||||
</div>
|
||||
|
||||
<div class="content" >
|
||||
<?= $this->form ?>
|
||||
</div>
|
||||
<div class="content">
|
||||
<h1><?= $this->escape($this->translate('This feature is deactivated at the moment.')); ?></h1>
|
||||
<p>
|
||||
<?=
|
||||
$this->escape($this->translate('Please have a little patience, we are hard working on it, take a look at icingaweb2 issues.'));
|
||||
?>
|
||||
</p>
|
||||
</div>
|
|
@ -7,16 +7,10 @@
|
|||
</div>
|
||||
<?php else: ?>
|
||||
<div class="content">
|
||||
<h1>No dashboard configuration found!</h1>
|
||||
<p>
|
||||
<?=
|
||||
$this->translate('We tried to load a dashboard configuration with no success.'
|
||||
. ' Please have look that the configuration does exist:');
|
||||
?>
|
||||
|
||||
<code>
|
||||
<?= $this->escape($this->configPath) ?>.ini
|
||||
</code>
|
||||
</p>
|
||||
<h1><?= $this->escape($this->translate('Welcome to Icinga Web!')) ?></h1>
|
||||
<p><?= sprintf(
|
||||
$this->escape($this->translate('Currently there is no dashlet available. This might change once you enabled some of the available %s.')),
|
||||
$this->qlink($this->translate('modules'), 'config/modules')
|
||||
) ?></p>
|
||||
</div>
|
||||
<?php endif; ?>
|
||||
<?php endif ?>
|
|
@ -1,39 +0,0 @@
|
|||
[Incidents]
|
||||
title = "Current incidents"
|
||||
|
||||
[Incidents.Service Problems]
|
||||
url = "monitoring/list/services"
|
||||
service_problem = 1
|
||||
limit = 10
|
||||
sort = service_severity
|
||||
|
||||
[Incidents.Recently Recovered Services]
|
||||
url = "monitoring/list/services"
|
||||
sort = "service_last_state_change"
|
||||
service_state = 0
|
||||
limit = 10
|
||||
dir = "desc"
|
||||
|
||||
[Incidents.Host Problems]
|
||||
url = "monitoring/list/hosts"
|
||||
host_problem = 1
|
||||
sort = host_severity
|
||||
|
||||
[Landing]
|
||||
title = "Landing page"
|
||||
|
||||
[Landing.Hostgroups]
|
||||
url = "monitoring/chart/hostgroup"
|
||||
|
||||
[Landing.Servicegroups]
|
||||
url = "monitoring/chart/servicegroup"
|
||||
|
||||
[Landing.Unhandled Problem Services]
|
||||
url = "monitoring/list/services"
|
||||
service_handled = 0
|
||||
service_problem = 1
|
||||
|
||||
[Landing.Unhandled Problem Hosts]
|
||||
url = "monitoring/list/hosts"
|
||||
host_handled = 0
|
||||
host_problem = 1
|
|
@ -14,30 +14,4 @@ the objects you're interested in and can add and remove elements.
|
|||
* The dashboard itself is just the view containing the panes
|
||||
|
||||
|
||||
## Configuration files
|
||||
|
||||
By default, the config/dashboard/dashboard.ini is used for storing dashboards in the following format:
|
||||
|
||||
[PaneName] ; Define a new Pane
|
||||
title = "PaneTitle" ; The title of the pane as displayed in the tabls
|
||||
|
||||
[PaneName.Component1] ; Define a new component 'Component 1' underneat the pane
|
||||
url = "/url/for/component1" ; the url that will be displayed, with view=compact as URL parameter appended
|
||||
height = "500px" ; optional height setting
|
||||
width = "400px" ; optional width setting
|
||||
|
||||
[test.My hosts] ; Another component, here with host
|
||||
url = "monitoring/list/hosts" ; the url of the component
|
||||
; Notice the missing height/width definition
|
||||
|
||||
[test.My services] ; And another pane
|
||||
url = "monitoring/list/services" ; With service url
|
||||
|
||||
[test2] ; Define a second pane
|
||||
title = "test2" ; with the title
|
||||
|
||||
[test2.test] ; Add a component to the second pane
|
||||
url = "/monitoring/show/host/host1" ; ...and define it's url
|
||||
|
||||
|
||||
[dashboards1]: res/Dashboard.png
|
||||
|
|
|
@ -185,8 +185,6 @@ install -D -m0644 packages/rpm/etc/httpd/conf.d/icingaweb.conf %{buildroot}/%{ap
|
|||
install -D -m0644 packages/rpm/etc/icingaweb/authentication.ini %{buildroot}/%{_sysconfdir}/icingaweb/authentication.ini
|
||||
# custom resource paths
|
||||
install -D -m0644 packages/rpm/etc/icingaweb/resources.ini %{buildroot}/%{_sysconfdir}/icingaweb/resources.ini
|
||||
# dashboard
|
||||
install -D -m0644 config/dashboard/dashboard.ini %{buildroot}/%{_sysconfdir}/icingaweb/dashboard/dashboard.ini
|
||||
# monitoring module (icinga2)
|
||||
install -D -m0644 packages/rpm/etc/icingaweb/modules/monitoring/backends.ini %{buildroot}/%{_sysconfdir}/icingaweb/modules/monitoring/backends.ini
|
||||
install -D -m0644 packages/rpm/etc/icingaweb/modules/monitoring/instances.ini %{buildroot}/%{_sysconfdir}/icingaweb/modules/monitoring/instances.ini
|
||||
|
|
|
@ -16,6 +16,7 @@ use Icinga\Util\Translator;
|
|||
use Icinga\Web\Hook;
|
||||
use Icinga\Web\Menu;
|
||||
use Icinga\Web\Widget;
|
||||
use Icinga\Web\Widget\Dashboard\Pane;
|
||||
use Icinga\Util\File;
|
||||
use Icinga\Exception\ProgrammingError;
|
||||
|
||||
|
@ -154,6 +155,36 @@ class Module
|
|||
*/
|
||||
protected $menuItems = array();
|
||||
|
||||
/**
|
||||
* A set of Pane elements
|
||||
*
|
||||
* @var array
|
||||
*/
|
||||
protected $paneItems = array();
|
||||
|
||||
/**
|
||||
* Get all Menu Items
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public function getPaneItems()
|
||||
{
|
||||
$this->launchConfigScript();
|
||||
return $this->paneItems;
|
||||
}
|
||||
|
||||
/**
|
||||
* Add a pane to dashboard
|
||||
*
|
||||
* @param $name
|
||||
* @return Pane
|
||||
*/
|
||||
protected function dashboard($name)
|
||||
{
|
||||
$this->paneItems[$name] = new Pane($name);
|
||||
return $this->paneItems[$name];
|
||||
}
|
||||
|
||||
/**
|
||||
* Get all Menu Items
|
||||
*
|
||||
|
|
|
@ -63,6 +63,46 @@ class Dashboard extends AbstractWidget
|
|||
$this->getTabs()->activate($name);
|
||||
}
|
||||
|
||||
/**
|
||||
* Load Pane items provided by all enabled modules
|
||||
*
|
||||
* @return self
|
||||
*/
|
||||
public static function load()
|
||||
{
|
||||
/** @var $dashboard Dashboard */
|
||||
$dashboard = new static('dashboard');
|
||||
$manager = Icinga::app()->getModuleManager();
|
||||
foreach ($manager->getLoadedModules() as $module) {
|
||||
/** @var $module \Icinga\Application\Modules\Module */
|
||||
$dashboard->mergePanes($module->getPaneItems());
|
||||
|
||||
}
|
||||
return $dashboard;
|
||||
}
|
||||
|
||||
/**
|
||||
* Merge panes with existing panes
|
||||
*
|
||||
* @param array $panes
|
||||
* @return $this
|
||||
*/
|
||||
public function mergePanes(array $panes)
|
||||
{
|
||||
/** @var $pane Pane */
|
||||
foreach ($panes as $pane) {
|
||||
if (array_key_exists($pane->getName(), $this->panes)) {
|
||||
/** @var $current Pane */
|
||||
$current = $this->panes[$pane->getName()];
|
||||
$current->addComponents($pane->getComponents());
|
||||
} else {
|
||||
$this->panes = array_filter(array_merge($this->panes, $panes));
|
||||
}
|
||||
}
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Return the tab object used to navigate through this dashboard
|
||||
*
|
||||
|
@ -147,6 +187,16 @@ class Dashboard extends AbstractWidget
|
|||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Checks if the current dashboard has any panes
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
public function hasPanes()
|
||||
{
|
||||
return ! empty($this->panes);
|
||||
}
|
||||
|
||||
/**
|
||||
* Return true if a pane doesn't exist or doesn't have any components in it
|
||||
*
|
||||
|
|
|
@ -162,6 +162,47 @@ class Pane extends AbstractWidget
|
|||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Add new components to existing components
|
||||
*
|
||||
* @param array $components
|
||||
* @return $this
|
||||
*/
|
||||
public function addComponents(array $components)
|
||||
{
|
||||
/* @var $component Component */
|
||||
foreach ($components as $component) {
|
||||
if (array_key_exists($component->getTitle(), $this->components)) {
|
||||
if (preg_match('/_(\d+)$/', $component->getTitle(), $m)) {
|
||||
$name = preg_replace('/_\d+$/', $m[1]++, $component->getTitle());
|
||||
} else {
|
||||
$name = $component->getTitle() . '_2';
|
||||
}
|
||||
$this->components[$name] = $component;
|
||||
} else {
|
||||
$this->components[$component->getTitle()] = $component;
|
||||
}
|
||||
}
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Add a component to the current pane
|
||||
*
|
||||
* @param $title
|
||||
* @param $url
|
||||
* @return Component
|
||||
*
|
||||
* @see addComponent()
|
||||
*/
|
||||
public function add($title, $url = null)
|
||||
{
|
||||
$this->addComponent($title, $url);
|
||||
|
||||
return $this->components[$title];
|
||||
}
|
||||
|
||||
/**
|
||||
* Return the this pane's structure as array
|
||||
*
|
||||
|
|
|
@ -125,10 +125,18 @@ $section->add($this->translate('Performance Info'), array(
|
|||
));
|
||||
|
||||
/*
|
||||
|
||||
$dashboard = $this->dashboard('Current Incidents'); // Web\Widget\Dashboard\Pane
|
||||
$dashboard->add('Service Problems', array(
|
||||
|
||||
));
|
||||
|
||||
*/
|
||||
* Dashboard
|
||||
*/
|
||||
$dashboard = $this->dashboard($this->translate('Current Incidents'));
|
||||
$dashboard->add(
|
||||
$this->translate('Service Problems'),
|
||||
'monitoring/list/services?service_problem=1&limit=10&sort=service_severity'
|
||||
);
|
||||
$dashboard->add(
|
||||
$this->translate('Recently Recovered Services'),
|
||||
'monitoring/list/services?service_state=0&limit=10&sort=service_last_state_change&dir=desc'
|
||||
);
|
||||
$dashboard->add(
|
||||
$this->translate('Host Problems'),
|
||||
'monitoring/list/hosts?host_problem=1&sort=host_severity'
|
||||
);
|
||||
|
|
Loading…
Reference in New Issue