diff --git a/application/views/scripts/dashboard/index.phtml b/application/views/scripts/dashboard/index.phtml
index 8550d8a6b..1d561146f 100644
--- a/application/views/scripts/dashboard/index.phtml
+++ b/application/views/scripts/dashboard/index.phtml
@@ -11,10 +11,16 @@
= $this->escape($this->translate('Welcome to Icinga Web!')) ?>
- = sprintf(
+ hasPermission('config/modules')) {
+ echo $this->escape($this->translate(
+ 'Currently there is no dashlet available. Please contact the administrator.'
+ ));
+ } else {
+ printf(
$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')
- ) ?>
+ );
+ } ?>
diff --git a/library/Icinga/Application/Modules/Manager.php b/library/Icinga/Application/Modules/Manager.php
index 8a3970841..f3bf4e016 100644
--- a/library/Icinga/Application/Modules/Manager.php
+++ b/library/Icinga/Application/Modules/Manager.php
@@ -281,7 +281,10 @@ class Manager
public function disableModule($name)
{
if (! $this->hasEnabled($name)) {
- return $this;
+ throw new ConfigurationError(
+ 'Cannot disable module "%s". Module is not installed.',
+ $name
+ );
}
if (! is_writable($this->enableDir)) {
diff --git a/modules/doc/library/Doc/DocController.php b/modules/doc/library/Doc/DocController.php
index 36abe6b10..10a9b1d40 100644
--- a/modules/doc/library/Doc/DocController.php
+++ b/modules/doc/library/Doc/DocController.php
@@ -9,6 +9,21 @@ use Icinga\Web\Controller;
class DocController extends Controller
{
+ /**
+ * {@inheritdoc}
+ */
+ protected function moduleInit()
+ {
+ // Our UrlParams object does not take parameters from custom routes into account which is why we have to set
+ // them explicitly
+ if ($this->hasParam('chapter')) {
+ $this->params->set('chapter', $this->getParam('chapter'));
+ }
+ if ($this->hasParam('moduleName')) {
+ $this->params->set('moduleName', $this->getParam('moduleName'));
+ }
+ }
+
/**
* Render a chapter
*
diff --git a/modules/monitoring/application/controllers/HostController.php b/modules/monitoring/application/controllers/HostController.php
index a7659726e..ffc7fcdd3 100644
--- a/modules/monitoring/application/controllers/HostController.php
+++ b/modules/monitoring/application/controllers/HostController.php
@@ -167,6 +167,7 @@ class Monitoring_HostController extends MonitoredObjectController
$this->assertPermission('monitoring/command/process-check-result');
$form = new ProcessCheckResultCommandForm();
+ $form->setBackend($this->backend);
$form->setTitle($this->translate('Submit Passive Host Check Result'));
$this->handleCommandForm($form);
}
diff --git a/modules/monitoring/application/controllers/HostsController.php b/modules/monitoring/application/controllers/HostsController.php
index 740b5cb5c..9a753adec 100644
--- a/modules/monitoring/application/controllers/HostsController.php
+++ b/modules/monitoring/application/controllers/HostsController.php
@@ -226,6 +226,7 @@ class Monitoring_HostsController extends Controller
$this->assertPermission('monitoring/command/process-check-result');
$form = new ProcessCheckResultCommandForm();
+ $form->setBackend($this->backend);
$form->setTitle($this->translate('Submit Passive Host Check Results'));
$this->handleCommandForm($form);
}
diff --git a/modules/monitoring/application/controllers/ServiceController.php b/modules/monitoring/application/controllers/ServiceController.php
index d9ed0d36b..cf7c4807c 100644
--- a/modules/monitoring/application/controllers/ServiceController.php
+++ b/modules/monitoring/application/controllers/ServiceController.php
@@ -122,6 +122,7 @@ class Monitoring_ServiceController extends MonitoredObjectController
$this->assertPermission('monitoring/command/process-check-result');
$form = new ProcessCheckResultCommandForm();
+ $form->setBackend($this->backend);
$form->setTitle($this->translate('Submit Passive Service Check Result'));
$this->handleCommandForm($form);
}
diff --git a/modules/monitoring/application/controllers/ServicesController.php b/modules/monitoring/application/controllers/ServicesController.php
index faebcd11c..18c427f86 100644
--- a/modules/monitoring/application/controllers/ServicesController.php
+++ b/modules/monitoring/application/controllers/ServicesController.php
@@ -242,6 +242,7 @@ class Monitoring_ServicesController extends Controller
$this->assertPermission('monitoring/command/process-check-result');
$form = new ProcessCheckResultCommandForm();
+ $form->setBackend($this->backend);
$form->setTitle($this->translate('Submit Passive Service Check Results'));
$this->handleCommandForm($form);
}
diff --git a/modules/monitoring/application/forms/Command/Object/ProcessCheckResultCommandForm.php b/modules/monitoring/application/forms/Command/Object/ProcessCheckResultCommandForm.php
index ec80a539f..0239ab657 100644
--- a/modules/monitoring/application/forms/Command/Object/ProcessCheckResultCommandForm.php
+++ b/modules/monitoring/application/forms/Command/Object/ProcessCheckResultCommandForm.php
@@ -52,11 +52,7 @@ class ProcessCheckResultCommandForm extends ObjectsCommandForm
'required' => true,
'label' => $this->translate('Status'),
'description' => $this->translate('The state this check result should report'),
- 'multiOptions' => $object->getType() === $object::TYPE_HOST ? array(
- ProcessCheckResultCommand::HOST_UP => $this->translate('UP', 'icinga.state'),
- ProcessCheckResultCommand::HOST_DOWN => $this->translate('DOWN', 'icinga.state'),
- ProcessCheckResultCommand::HOST_UNREACHABLE => $this->translate('UNREACHABLE', 'icinga.state')
- ) : array(
+ 'multiOptions' => $object->getType() === $object::TYPE_HOST ? $this->getHostMultiOptions() : array(
ProcessCheckResultCommand::SERVICE_OK => $this->translate('OK', 'icinga.state'),
ProcessCheckResultCommand::SERVICE_WARNING => $this->translate('WARNING', 'icinga.state'),
ProcessCheckResultCommand::SERVICE_CRITICAL => $this->translate('CRITICAL', 'icinga.state'),
@@ -115,4 +111,23 @@ class ProcessCheckResultCommandForm extends ObjectsCommandForm
return true;
}
+
+ /**
+ * Returns the available host options based on the program version
+ *
+ * @return array
+ */
+ protected function getHostMultiOptions()
+ {
+ $options = array(
+ ProcessCheckResultCommand::HOST_UP => $this->translate('UP', 'icinga.state'),
+ ProcessCheckResultCommand::HOST_DOWN => $this->translate('DOWN', 'icinga.state')
+ );
+
+ if (substr($this->getBackend()->getProgramVersion(), 0, 2) !== 'v2') {
+ $options[ProcessCheckResultCommand::HOST_UNREACHABLE] = $this->translate('UNREACHABLE', 'icinga.state');
+ }
+
+ return $options;
+ }
}
diff --git a/modules/monitoring/application/forms/Config/Instance/RemoteInstanceForm.php b/modules/monitoring/application/forms/Config/Instance/RemoteInstanceForm.php
index 244bf66d1..e290866cc 100644
--- a/modules/monitoring/application/forms/Config/Instance/RemoteInstanceForm.php
+++ b/modules/monitoring/application/forms/Config/Instance/RemoteInstanceForm.php
@@ -52,24 +52,46 @@ class RemoteInstanceForm extends Form
return $this;
}
+ /**
+ * Check whether ssh identity resources exists or not
+ *
+ * @return boolean
+ */
+ public function hasResources()
+ {
+ $resourceConfig = ResourceFactory::getResourceConfigs();
+
+ foreach ($resourceConfig as $name => $resource) {
+ if ($resource->type === 'ssh') {
+ return true;
+ }
+ }
+ return false;
+ }
+
/**
* (non-PHPDoc)
* @see Form::createElements() For the method documentation.
*/
public function createElements(array $formData = array())
{
- $useResource = isset($formData['use_resource']) ? $formData['use_resource'] : $this->getValue('use_resource');
+ $useResource = false;
- $this->addElement(
- 'checkbox',
- 'use_resource',
- array(
- 'label' => $this->translate('Use SSH Identity'),
- 'description' => $this->translate('Make use of the ssh identity resource'),
- 'autosubmit' => true,
- 'ignore' => true
- )
- );
+ if ($this->hasResources()) {
+ $useResource = isset($formData['use_resource'])
+ ? $formData['use_resource'] : $this->getValue('use_resource');
+
+ $this->addElement(
+ 'checkbox',
+ 'use_resource',
+ array(
+ 'label' => $this->translate('Use SSH Identity'),
+ 'description' => $this->translate('Make use of the ssh identity resource'),
+ 'autosubmit' => true,
+ 'ignore' => true
+ )
+ );
+ }
if ($useResource) {
diff --git a/modules/monitoring/library/Monitoring/Backend/MonitoringBackend.php b/modules/monitoring/library/Monitoring/Backend/MonitoringBackend.php
index 012b7c110..6ee534b17 100644
--- a/modules/monitoring/library/Monitoring/Backend/MonitoringBackend.php
+++ b/modules/monitoring/library/Monitoring/Backend/MonitoringBackend.php
@@ -331,4 +331,14 @@ class MonitoringBackend implements Selectable, Queryable, ConnectionInterface
array_push($parts, 'Query', ucfirst(strtolower($query)) . 'Query');
return implode('\\', $parts);
}
+
+ /**
+ * Fetch and return the program version of the current instance
+ *
+ * @return string
+ */
+ public function getProgramVersion()
+ {
+ return $this->select()->from('programstatus', array('program_version'))->fetchOne();
+ }
}