mirror of
https://github.com/Icinga/icingaweb2.git
synced 2025-07-29 16:54:04 +02:00
Merge branch 'feature/rename-monitoring-instances-to-command-transports-and-allow-to-link-them-with-a-monitoring-instance-9651'
resolves #9651 resolves #8981 fixes #9765
This commit is contained in:
commit
656e5aad01
@ -275,9 +275,11 @@ The first release candidate of Icinga Web 2 introduces the following non-backwar
|
|||||||
`icingaweb_group_membership` were altered to ensure referential integrity.
|
`icingaweb_group_membership` were altered to ensure referential integrity.
|
||||||
Please use the upgrade script located in **etc/schema/** to update your
|
Please use the upgrade script located in **etc/schema/** to update your
|
||||||
database schema
|
database schema
|
||||||
|
|
||||||
* Users who are using PostgreSQL < v9.1 are required to upgrade their
|
* Users who are using PostgreSQL < v9.1 are required to upgrade their
|
||||||
environment to v9.1+ as this is the new minimum required version
|
environment to v9.1+ as this is the new minimum required version
|
||||||
for utilizing PostgreSQL as database backend
|
for utilizing PostgreSQL as database backend
|
||||||
|
|
||||||
* The restrictions `monitoring/hosts/filter` and `monitoring/services/filter`
|
* The restrictions `monitoring/hosts/filter` and `monitoring/services/filter`
|
||||||
provided by the monitoring module were merged together. The new
|
provided by the monitoring module were merged together. The new
|
||||||
restriction is called `monitoring/filter/objects` and supports only a
|
restriction is called `monitoring/filter/objects` and supports only a
|
||||||
@ -287,12 +289,16 @@ The first release candidate of Icinga Web 2 introduces the following non-backwar
|
|||||||
## <a id="upgrading-to-2.0.0"></a> Upgrading to Icinga Web 2 2.0.0
|
## <a id="upgrading-to-2.0.0"></a> Upgrading to Icinga Web 2 2.0.0
|
||||||
|
|
||||||
* Icinga Web 2 installations from package on RHEL/CentOS 7 now depend on `php-ZendFramework` which is available through
|
* Icinga Web 2 installations from package on RHEL/CentOS 7 now depend on `php-ZendFramework` which is available through
|
||||||
the [EPEL repository](http://fedoraproject.org/wiki/EPEL). Before, Zend was installed as Icinga Web 2 vendor library
|
the [EPEL repository](http://fedoraproject.org/wiki/EPEL). Before, Zend was installed as Icinga Web 2 vendor library
|
||||||
through the package `icingaweb2-vendor-zend`. After upgrading, please make sure to remove the package
|
through the package `icingaweb2-vendor-zend`. After upgrading, please make sure to remove the package
|
||||||
`icingaweb2-vendor-zend`.
|
`icingaweb2-vendor-zend`.
|
||||||
|
|
||||||
* Icinga Web 2 version 2.0.0 requires permissions for accessing modules. Those permissions are automatically generated
|
* Icinga Web 2 version 2.0.0 requires permissions for accessing modules. Those permissions are automatically generated
|
||||||
for each installed module in the format `module/<moduleName>`. Administrators have to grant the module permissions to
|
for each installed module in the format `module/<moduleName>`. Administrators have to grant the module permissions to
|
||||||
users and/or user groups in the roles configuration for permitting access to specific modules.
|
users and/or user groups in the roles configuration for permitting access to specific modules.
|
||||||
In addition, restrictions provided by modules are now configurable for each installed module too. Before,
|
In addition, restrictions provided by modules are now configurable for each installed module too. Before,
|
||||||
a module had to be enabled before having the possibility to configure restrictions.
|
a module had to be enabled before having the possibility to configure restrictions.
|
||||||
|
|
||||||
|
* The **instances.ini** configuration file provided by the monitoring module
|
||||||
|
has been renamed to **commandtransports.ini**. The content and location of
|
||||||
|
the file remains unchanged.
|
||||||
|
@ -8,11 +8,11 @@ use Icinga\Data\ResourceFactory;
|
|||||||
use Icinga\Exception\ConfigurationError;
|
use Icinga\Exception\ConfigurationError;
|
||||||
use Icinga\Exception\NotFoundError;
|
use Icinga\Exception\NotFoundError;
|
||||||
use Icinga\Forms\ConfirmRemovalForm;
|
use Icinga\Forms\ConfirmRemovalForm;
|
||||||
use Icinga\Module\Monitoring\Forms\Config\BackendConfigForm;
|
|
||||||
use Icinga\Module\Monitoring\Forms\Config\InstanceConfigForm;
|
|
||||||
use Icinga\Module\Monitoring\Forms\Config\SecurityConfigForm;
|
|
||||||
use Icinga\Web\Controller;
|
|
||||||
use Icinga\Web\Notification;
|
use Icinga\Web\Notification;
|
||||||
|
use Icinga\Module\Monitoring\Controller;
|
||||||
|
use Icinga\Module\Monitoring\Forms\Config\BackendConfigForm;
|
||||||
|
use Icinga\Module\Monitoring\Forms\Config\SecurityConfigForm;
|
||||||
|
use Icinga\Module\Monitoring\Forms\Config\TransportConfigForm;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Configuration controller for editing monitoring resources
|
* Configuration controller for editing monitoring resources
|
||||||
@ -20,12 +20,12 @@ use Icinga\Web\Notification;
|
|||||||
class ConfigController extends Controller
|
class ConfigController extends Controller
|
||||||
{
|
{
|
||||||
/**
|
/**
|
||||||
* Display a list of available backends and instances
|
* Display a list of available backends and command transports
|
||||||
*/
|
*/
|
||||||
public function indexAction()
|
public function indexAction()
|
||||||
{
|
{
|
||||||
$this->view->backendsConfig = $this->Config('backends');
|
$this->view->backendsConfig = $this->Config('backends');
|
||||||
$this->view->instancesConfig = $this->Config('instances');
|
$this->view->transportConfig = $this->Config('commandtransports');
|
||||||
$this->view->tabs = $this->Module()->getConfigTabs()->activate('backends');
|
$this->view->tabs = $this->Module()->getConfigTabs()->activate('backends');
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -149,31 +149,34 @@ class ConfigController extends Controller
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Remove a monitoring instance
|
* Remove a command transport
|
||||||
*/
|
*/
|
||||||
public function removeinstanceAction()
|
public function removetransportAction()
|
||||||
{
|
{
|
||||||
$instanceName = $this->params->getRequired('instance');
|
$transportName = $this->params->getRequired('transport');
|
||||||
|
|
||||||
$instanceForm = new InstanceConfigForm();
|
$transportForm = new TransportConfigForm();
|
||||||
$instanceForm->setIniConfig($this->Config('instances'));
|
$transportForm->setIniConfig($this->Config('commandtransports'));
|
||||||
$form = new ConfirmRemovalForm();
|
$form = new ConfirmRemovalForm();
|
||||||
$form->setRedirectUrl('monitoring/config');
|
$form->setRedirectUrl('monitoring/config');
|
||||||
$form->setTitle(sprintf($this->translate('Remove Monitoring Instance %s'), $instanceName));
|
$form->setTitle(sprintf($this->translate('Remove Command Transport %s'), $transportName));
|
||||||
$form->addDescription($this->translate(
|
$form->info(
|
||||||
'If you have still any environments or views referring to this instance, '
|
$this->translate(
|
||||||
. 'you won\'t be able to send commands anymore after deletion.'
|
'If you have still any environments or views referring to this transport, '
|
||||||
));
|
. 'you won\'t be able to send commands anymore after deletion.'
|
||||||
$form->setOnSuccess(function (ConfirmRemovalForm $form) use ($instanceName, $instanceForm) {
|
),
|
||||||
|
false
|
||||||
|
);
|
||||||
|
$form->setOnSuccess(function (ConfirmRemovalForm $form) use ($transportName, $transportForm) {
|
||||||
try {
|
try {
|
||||||
$instanceForm->delete($instanceName);
|
$transportForm->delete($transportName);
|
||||||
} catch (Exception $e) {
|
} catch (Exception $e) {
|
||||||
$form->error($e->getMessage());
|
$form->error($e->getMessage());
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
if ($instanceForm->save()) {
|
if ($transportForm->save()) {
|
||||||
Notification::success(sprintf(t('Monitoring instance "%s" successfully removed'), $instanceName));
|
Notification::success(sprintf(t('Command transport "%s" successfully removed'), $transportName));
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -186,19 +189,20 @@ class ConfigController extends Controller
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Edit a monitoring instance
|
* Edit a command transport
|
||||||
*/
|
*/
|
||||||
public function editinstanceAction()
|
public function edittransportAction()
|
||||||
{
|
{
|
||||||
$instanceName = $this->params->getRequired('instance');
|
$transportName = $this->params->getRequired('transport');
|
||||||
|
|
||||||
$form = new InstanceConfigForm();
|
$form = new TransportConfigForm();
|
||||||
$form->setRedirectUrl('monitoring/config');
|
$form->setRedirectUrl('monitoring/config');
|
||||||
$form->setTitle(sprintf($this->translate('Edit Monitoring Instance %s'), $instanceName));
|
$form->setTitle(sprintf($this->translate('Edit Command Transport %s'), $transportName));
|
||||||
$form->setIniConfig($this->Config('instances'));
|
$form->setIniConfig($this->Config('commandtransports'));
|
||||||
$form->setOnSuccess(function (InstanceConfigForm $form) use ($instanceName) {
|
$form->setInstanceNames($this->backend->select()->from('instance', array('instance_name'))->fetchColumn());
|
||||||
|
$form->setOnSuccess(function (TransportConfigForm $form) use ($transportName) {
|
||||||
try {
|
try {
|
||||||
$form->edit($instanceName, array_map(
|
$form->edit($transportName, array_map(
|
||||||
function ($v) {
|
function ($v) {
|
||||||
return $v !== '' ? $v : null;
|
return $v !== '' ? $v : null;
|
||||||
},
|
},
|
||||||
@ -210,7 +214,7 @@ class ConfigController extends Controller
|
|||||||
}
|
}
|
||||||
|
|
||||||
if ($form->save()) {
|
if ($form->save()) {
|
||||||
Notification::success(sprintf(t('Monitoring instance "%s" successfully updated'), $instanceName));
|
Notification::success(sprintf(t('Command transport "%s" successfully updated'), $transportName));
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -218,10 +222,10 @@ class ConfigController extends Controller
|
|||||||
});
|
});
|
||||||
|
|
||||||
try {
|
try {
|
||||||
$form->load($instanceName);
|
$form->load($transportName);
|
||||||
$form->handleRequest();
|
$form->handleRequest();
|
||||||
} catch (NotFoundError $_) {
|
} catch (NotFoundError $_) {
|
||||||
$this->httpNotFound(sprintf($this->translate('Monitoring instance "%s" not found'), $instanceName));
|
$this->httpNotFound(sprintf($this->translate('Command transport "%s" not found'), $transportName));
|
||||||
}
|
}
|
||||||
|
|
||||||
$this->view->form = $form;
|
$this->view->form = $form;
|
||||||
@ -229,15 +233,16 @@ class ConfigController extends Controller
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Create a new monitoring instance
|
* Create a new command transport
|
||||||
*/
|
*/
|
||||||
public function createinstanceAction()
|
public function createtransportAction()
|
||||||
{
|
{
|
||||||
$form = new InstanceConfigForm();
|
$form = new TransportConfigForm();
|
||||||
$form->setRedirectUrl('monitoring/config');
|
$form->setRedirectUrl('monitoring/config');
|
||||||
$form->setTitle($this->translate('Create New Monitoring Instance'));
|
$form->setTitle($this->translate('Create New Command Transport'));
|
||||||
$form->setIniConfig($this->Config('instances'));
|
$form->setIniConfig($this->Config('commandtransports'));
|
||||||
$form->setOnSuccess(function (InstanceConfigForm $form) {
|
$form->setInstanceNames($this->backend->select()->from('instance', array('instance_name'))->fetchColumn());
|
||||||
|
$form->setOnSuccess(function (TransportConfigForm $form) {
|
||||||
try {
|
try {
|
||||||
$form->add(array_filter($form->getValues()));
|
$form->add(array_filter($form->getValues()));
|
||||||
} catch (Exception $e) {
|
} catch (Exception $e) {
|
||||||
@ -246,7 +251,7 @@ class ConfigController extends Controller
|
|||||||
}
|
}
|
||||||
|
|
||||||
if ($form->save()) {
|
if ($form->save()) {
|
||||||
Notification::success(t('Monitoring instance successfully created'));
|
Notification::success(t('Command transport successfully created'));
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -269,6 +274,5 @@ class ConfigController extends Controller
|
|||||||
|
|
||||||
$this->view->form = $form;
|
$this->view->form = $form;
|
||||||
$this->view->tabs = $this->Module()->getConfigTabs()->activate('security');
|
$this->view->tabs = $this->Module()->getConfigTabs()->activate('security');
|
||||||
$this->render('form');
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -3,10 +3,12 @@
|
|||||||
|
|
||||||
namespace Icinga\Module\Monitoring\Forms\Command;
|
namespace Icinga\Module\Monitoring\Forms\Command;
|
||||||
|
|
||||||
use Icinga\Module\Monitoring\Backend\MonitoringBackend;
|
use Icinga\Exception\ConfigurationError;
|
||||||
use Icinga\Module\Monitoring\Command\Transport\CommandTransport;
|
|
||||||
use Icinga\Web\Form;
|
use Icinga\Web\Form;
|
||||||
use Icinga\Web\Request;
|
use Icinga\Web\Request;
|
||||||
|
use Icinga\Module\Monitoring\Backend\MonitoringBackend;
|
||||||
|
use Icinga\Module\Monitoring\Command\Transport\CommandTransport;
|
||||||
|
use Icinga\Module\Monitoring\Command\Transport\CommandTransportInterface;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Base class for command forms
|
* Base class for command forms
|
||||||
@ -46,18 +48,28 @@ abstract class CommandForm extends Form
|
|||||||
/**
|
/**
|
||||||
* Get the transport used to send commands
|
* Get the transport used to send commands
|
||||||
*
|
*
|
||||||
* @param Request $request
|
* @param Request $request
|
||||||
*
|
*
|
||||||
* @return \Icinga\Module\Monitoring\Command\Transport\CommandTransportInterface
|
* @return CommandTransportInterface
|
||||||
|
*
|
||||||
|
* @throws ConfigurationError
|
||||||
*/
|
*/
|
||||||
public function getTransport(Request $request)
|
public function getTransport(Request $request)
|
||||||
{
|
{
|
||||||
$instance = $request->getParam('instance');
|
if (($transportName = $request->getParam('transport')) !== null) {
|
||||||
if ($instance !== null) {
|
$config = CommandTransport::getConfig();
|
||||||
$transport = CommandTransport::create($instance);
|
if ($config->hasSection($transportName)) {
|
||||||
|
$transport = CommandTransport::createTransport($config->getSection($transportName));
|
||||||
|
} else {
|
||||||
|
throw new ConfigurationError(sprintf(
|
||||||
|
mt('monitoring', 'Command transport "%s" not found.'),
|
||||||
|
$transportName
|
||||||
|
));
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
$transport = CommandTransport::first();
|
$transport = new CommandTransport();
|
||||||
}
|
}
|
||||||
|
|
||||||
return $transport;
|
return $transport;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,245 +0,0 @@
|
|||||||
<?php
|
|
||||||
/* Icinga Web 2 | (c) 2013-2015 Icinga Development Team | GPLv2+ */
|
|
||||||
|
|
||||||
namespace Icinga\Module\Monitoring\Forms\Config;
|
|
||||||
|
|
||||||
use InvalidArgumentException;
|
|
||||||
use Icinga\Exception\IcingaException;
|
|
||||||
use Icinga\Exception\NotFoundError;
|
|
||||||
use Icinga\Forms\ConfigForm;
|
|
||||||
use Icinga\Module\Monitoring\Command\Transport\LocalCommandFile;
|
|
||||||
use Icinga\Module\Monitoring\Command\Transport\RemoteCommandFile;
|
|
||||||
use Icinga\Module\Monitoring\Forms\Config\Instance\LocalInstanceForm;
|
|
||||||
use Icinga\Module\Monitoring\Forms\Config\Instance\RemoteInstanceForm;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Form for managing monitoring instances
|
|
||||||
*/
|
|
||||||
class InstanceConfigForm extends ConfigForm
|
|
||||||
{
|
|
||||||
/**
|
|
||||||
* The instance to load when displaying the form for the first time
|
|
||||||
*
|
|
||||||
* @var string
|
|
||||||
*/
|
|
||||||
protected $instanceToLoad;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Initialize this form
|
|
||||||
*/
|
|
||||||
public function init()
|
|
||||||
{
|
|
||||||
$this->setName('form_config_monitoring_instance');
|
|
||||||
$this->setSubmitLabel($this->translate('Save Changes'));
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Return a form object for the given instance type
|
|
||||||
*
|
|
||||||
* @param string $type The instance type for which to return a form
|
|
||||||
*
|
|
||||||
* @return Form
|
|
||||||
*
|
|
||||||
* @throws InvalidArgumentException In case the given instance type is invalid
|
|
||||||
*/
|
|
||||||
public function getInstanceForm($type)
|
|
||||||
{
|
|
||||||
switch (strtolower($type)) {
|
|
||||||
case LocalCommandFile::TRANSPORT:
|
|
||||||
return new LocalInstanceForm();
|
|
||||||
case RemoteCommandFile::TRANSPORT;
|
|
||||||
return new RemoteInstanceForm();
|
|
||||||
default:
|
|
||||||
throw new InvalidArgumentException(
|
|
||||||
sprintf($this->translate('Invalid monitoring instance type "%s" given'), $type)
|
|
||||||
);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Populate the form with the given instance's config
|
|
||||||
*
|
|
||||||
* @param string $name
|
|
||||||
*
|
|
||||||
* @return $this
|
|
||||||
*
|
|
||||||
* @throws NotFoundError In case no instance with the given name is found
|
|
||||||
*/
|
|
||||||
public function load($name)
|
|
||||||
{
|
|
||||||
if (! $this->config->hasSection($name)) {
|
|
||||||
throw new NotFoundError('No monitoring instance called "%s" found', $name);
|
|
||||||
}
|
|
||||||
|
|
||||||
$this->instanceToLoad = $name;
|
|
||||||
return $this;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Add a new instance
|
|
||||||
*
|
|
||||||
* The instance to add is identified by the array-key `name'.
|
|
||||||
*
|
|
||||||
* @param array $data
|
|
||||||
*
|
|
||||||
* @return $this
|
|
||||||
*
|
|
||||||
* @throws InvalidArgumentException In case $data does not contain a instance name
|
|
||||||
* @throws IcingaException In case a instance with the same name already exists
|
|
||||||
*/
|
|
||||||
public function add(array $data)
|
|
||||||
{
|
|
||||||
if (! isset($data['name'])) {
|
|
||||||
throw new InvalidArgumentException('Key \'name\' missing');
|
|
||||||
}
|
|
||||||
|
|
||||||
$instanceName = $data['name'];
|
|
||||||
if ($this->config->hasSection($instanceName)) {
|
|
||||||
throw new IcingaException(
|
|
||||||
$this->translate('A monitoring instance with the name "%s" does already exist'),
|
|
||||||
$instanceName
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
unset($data['name']);
|
|
||||||
$this->config->setSection($instanceName, $data);
|
|
||||||
return $this;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Edit an existing instance
|
|
||||||
*
|
|
||||||
* @param string $name
|
|
||||||
* @param array $data
|
|
||||||
*
|
|
||||||
* @return $this
|
|
||||||
*
|
|
||||||
* @throws NotFoundError In case no instance with the given name is found
|
|
||||||
*/
|
|
||||||
public function edit($name, array $data)
|
|
||||||
{
|
|
||||||
if (! $this->config->hasSection($name)) {
|
|
||||||
throw new NotFoundError('No monitoring instance called "%s" found', $name);
|
|
||||||
}
|
|
||||||
|
|
||||||
$instanceConfig = $this->config->getSection($name);
|
|
||||||
if (isset($data['name'])) {
|
|
||||||
if ($data['name'] !== $name) {
|
|
||||||
$this->config->removeSection($name);
|
|
||||||
$name = $data['name'];
|
|
||||||
}
|
|
||||||
|
|
||||||
unset($data['name']);
|
|
||||||
}
|
|
||||||
|
|
||||||
$instanceConfig->merge($data);
|
|
||||||
foreach ($instanceConfig->toArray() as $k => $v) {
|
|
||||||
if ($v === null) {
|
|
||||||
unset($instanceConfig->$k);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
$this->config->setSection($name, $instanceConfig);
|
|
||||||
return $this;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Remove a instance
|
|
||||||
*
|
|
||||||
* @param string $name
|
|
||||||
*
|
|
||||||
* @return $this
|
|
||||||
*/
|
|
||||||
public function delete($name)
|
|
||||||
{
|
|
||||||
$this->config->removeSection($name);
|
|
||||||
return $this;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Create and add elements to this form
|
|
||||||
*
|
|
||||||
* @param array $formData
|
|
||||||
*/
|
|
||||||
public function createElements(array $formData)
|
|
||||||
{
|
|
||||||
$this->addElement(
|
|
||||||
'text',
|
|
||||||
'name',
|
|
||||||
array(
|
|
||||||
'required' => true,
|
|
||||||
'label' => $this->translate('Instance Name'),
|
|
||||||
'description' => $this->translate(
|
|
||||||
'The name of this monitoring instance that is used to differentiate it from others'
|
|
||||||
),
|
|
||||||
'validators' => array(
|
|
||||||
array(
|
|
||||||
'Regex',
|
|
||||||
false,
|
|
||||||
array(
|
|
||||||
'pattern' => '/^[^\\[\\]:]+$/',
|
|
||||||
'messages' => array(
|
|
||||||
'regexNotMatch' => $this->translate(
|
|
||||||
'The name cannot contain \'[\', \']\' or \':\'.'
|
|
||||||
)
|
|
||||||
)
|
|
||||||
)
|
|
||||||
)
|
|
||||||
)
|
|
||||||
)
|
|
||||||
);
|
|
||||||
|
|
||||||
$instanceTypes = array(
|
|
||||||
LocalCommandFile::TRANSPORT => $this->translate('Local Command File'),
|
|
||||||
RemoteCommandFile::TRANSPORT => $this->translate('Remote Command File')
|
|
||||||
);
|
|
||||||
|
|
||||||
$instanceType = isset($formData['transport']) ? $formData['transport'] : null;
|
|
||||||
if ($instanceType === null) {
|
|
||||||
$instanceType = key($instanceTypes);
|
|
||||||
}
|
|
||||||
|
|
||||||
$this->addElements(array(
|
|
||||||
array(
|
|
||||||
'select',
|
|
||||||
'transport',
|
|
||||||
array(
|
|
||||||
'required' => true,
|
|
||||||
'autosubmit' => true,
|
|
||||||
'label' => $this->translate('Instance Type'),
|
|
||||||
'description' => $this->translate('The type of transport to use for this monitoring instance'),
|
|
||||||
'multiOptions' => $instanceTypes
|
|
||||||
)
|
|
||||||
)
|
|
||||||
));
|
|
||||||
|
|
||||||
$this->addSubForm($this->getInstanceForm($instanceType)->create($formData), 'instance_form');
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Populate the configuration of the instance to load
|
|
||||||
*/
|
|
||||||
public function onRequest()
|
|
||||||
{
|
|
||||||
if ($this->instanceToLoad) {
|
|
||||||
$data = $this->config->getSection($this->instanceToLoad)->toArray();
|
|
||||||
$data['name'] = $this->instanceToLoad;
|
|
||||||
$this->populate($data);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Retrieve all form element values
|
|
||||||
*
|
|
||||||
* @param bool $suppressArrayNotation Ignored
|
|
||||||
*
|
|
||||||
* @return array
|
|
||||||
*/
|
|
||||||
public function getValues($suppressArrayNotation = false)
|
|
||||||
{
|
|
||||||
$values = parent::getValues();
|
|
||||||
$values = array_merge($values, $values['instance_form']);
|
|
||||||
unset($values['instance_form']);
|
|
||||||
return $values;
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,11 +1,11 @@
|
|||||||
<?php
|
<?php
|
||||||
/* Icinga Web 2 | (c) 2013-2015 Icinga Development Team | GPLv2+ */
|
/* Icinga Web 2 | (c) 2013-2015 Icinga Development Team | GPLv2+ */
|
||||||
|
|
||||||
namespace Icinga\Module\Monitoring\Forms\Config\Instance;
|
namespace Icinga\Module\Monitoring\Forms\Config\Transport;
|
||||||
|
|
||||||
use Icinga\Web\Form;
|
use Icinga\Web\Form;
|
||||||
|
|
||||||
class LocalInstanceForm extends Form
|
class LocalTransportForm extends Form
|
||||||
{
|
{
|
||||||
/**
|
/**
|
||||||
* (non-PHPDoc)
|
* (non-PHPDoc)
|
||||||
@ -13,7 +13,7 @@ class LocalInstanceForm extends Form
|
|||||||
*/
|
*/
|
||||||
public function init()
|
public function init()
|
||||||
{
|
{
|
||||||
$this->setName('form_config_monitoring_instance_local');
|
$this->setName('form_config_command_transport_local');
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
@ -1,16 +1,16 @@
|
|||||||
<?php
|
<?php
|
||||||
/* Icinga Web 2 | (c) 2013-2015 Icinga Development Team | GPLv2+ */
|
/* Icinga Web 2 | (c) 2013-2015 Icinga Development Team | GPLv2+ */
|
||||||
|
|
||||||
namespace Icinga\Module\Monitoring\Forms\Config\Instance;
|
namespace Icinga\Module\Monitoring\Forms\Config\Transport;
|
||||||
|
|
||||||
use Icinga\Data\ResourceFactory;
|
use Icinga\Data\ResourceFactory;
|
||||||
use Icinga\Exception\ConfigurationError;
|
use Icinga\Exception\ConfigurationError;
|
||||||
use Icinga\Web\Form;
|
use Icinga\Web\Form;
|
||||||
|
|
||||||
class RemoteInstanceForm extends Form
|
class RemoteTransportForm extends Form
|
||||||
{
|
{
|
||||||
/**
|
/**
|
||||||
* The available monitoring instance resources split by type
|
* The available resources split by type
|
||||||
*
|
*
|
||||||
* @var array
|
* @var array
|
||||||
*/
|
*/
|
||||||
@ -22,7 +22,7 @@ class RemoteInstanceForm extends Form
|
|||||||
*/
|
*/
|
||||||
public function init()
|
public function init()
|
||||||
{
|
{
|
||||||
$this->setName('form_config_monitoring_instance_remote');
|
$this->setName('form_config_command_transport_remote');
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -44,7 +44,7 @@ class RemoteInstanceForm extends Form
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (empty($resources)) {
|
if (empty($resources)) {
|
||||||
throw new ConfigurationError($this->translate('Could not find any valid monitoring instance resources'));
|
throw new ConfigurationError($this->translate('Could not find any valid SSH resources'));
|
||||||
}
|
}
|
||||||
|
|
||||||
$this->resources = $resources;
|
$this->resources = $resources;
|
@ -0,0 +1,290 @@
|
|||||||
|
<?php
|
||||||
|
/* Icinga Web 2 | (c) 2013-2015 Icinga Development Team | GPLv2+ */
|
||||||
|
|
||||||
|
namespace Icinga\Module\Monitoring\Forms\Config;
|
||||||
|
|
||||||
|
use InvalidArgumentException;
|
||||||
|
use Icinga\Exception\IcingaException;
|
||||||
|
use Icinga\Exception\NotFoundError;
|
||||||
|
use Icinga\Forms\ConfigForm;
|
||||||
|
use Icinga\Module\Monitoring\Command\Transport\LocalCommandFile;
|
||||||
|
use Icinga\Module\Monitoring\Command\Transport\RemoteCommandFile;
|
||||||
|
use Icinga\Module\Monitoring\Forms\Config\Transport\LocalTransportForm;
|
||||||
|
use Icinga\Module\Monitoring\Forms\Config\Transport\RemoteTransportForm;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Form for managing command transports
|
||||||
|
*/
|
||||||
|
class TransportConfigForm extends ConfigForm
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* The transport to load when displaying the form for the first time
|
||||||
|
*
|
||||||
|
* @var string
|
||||||
|
*/
|
||||||
|
protected $transportToLoad;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The names of all available Icinga instances
|
||||||
|
*
|
||||||
|
* @var array
|
||||||
|
*/
|
||||||
|
protected $instanceNames;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Initialize this form
|
||||||
|
*/
|
||||||
|
public function init()
|
||||||
|
{
|
||||||
|
$this->setName('form_config_command_transports');
|
||||||
|
$this->setSubmitLabel($this->translate('Save Changes'));
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Set the names of all available Icinga instances
|
||||||
|
*
|
||||||
|
* @param array $names
|
||||||
|
*
|
||||||
|
* @return $this
|
||||||
|
*/
|
||||||
|
public function setInstanceNames(array $names)
|
||||||
|
{
|
||||||
|
$this->instanceNames = $names;
|
||||||
|
return $this;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Return the names of all available Icinga instances
|
||||||
|
*
|
||||||
|
* @return array
|
||||||
|
*/
|
||||||
|
public function getInstanceNames()
|
||||||
|
{
|
||||||
|
return $this->instanceNames ?: array();
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Return a form object for the given transport type
|
||||||
|
*
|
||||||
|
* @param string $type The transport type for which to return a form
|
||||||
|
*
|
||||||
|
* @return Form
|
||||||
|
*
|
||||||
|
* @throws InvalidArgumentException In case the given transport type is invalid
|
||||||
|
*/
|
||||||
|
public function getTransportForm($type)
|
||||||
|
{
|
||||||
|
switch (strtolower($type)) {
|
||||||
|
case LocalCommandFile::TRANSPORT:
|
||||||
|
return new LocalTransportForm();
|
||||||
|
case RemoteCommandFile::TRANSPORT;
|
||||||
|
return new RemoteTransportForm();
|
||||||
|
default:
|
||||||
|
throw new InvalidArgumentException(
|
||||||
|
sprintf($this->translate('Invalid command transport type "%s" given'), $type)
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Populate the form with the given transport's config
|
||||||
|
*
|
||||||
|
* @param string $name
|
||||||
|
*
|
||||||
|
* @return $this
|
||||||
|
*
|
||||||
|
* @throws NotFoundError In case no transport with the given name is found
|
||||||
|
*/
|
||||||
|
public function load($name)
|
||||||
|
{
|
||||||
|
if (! $this->config->hasSection($name)) {
|
||||||
|
throw new NotFoundError('No command transport called "%s" found', $name);
|
||||||
|
}
|
||||||
|
|
||||||
|
$this->transportToLoad = $name;
|
||||||
|
return $this;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Add a new command transport
|
||||||
|
*
|
||||||
|
* The transport to add is identified by the array-key `name'.
|
||||||
|
*
|
||||||
|
* @param array $data
|
||||||
|
*
|
||||||
|
* @return $this
|
||||||
|
*
|
||||||
|
* @throws InvalidArgumentException In case $data does not contain a transport name
|
||||||
|
* @throws IcingaException In case a transport with the same name already exists
|
||||||
|
*/
|
||||||
|
public function add(array $data)
|
||||||
|
{
|
||||||
|
if (! isset($data['name'])) {
|
||||||
|
throw new InvalidArgumentException('Key \'name\' missing');
|
||||||
|
}
|
||||||
|
|
||||||
|
$transportName = $data['name'];
|
||||||
|
if ($this->config->hasSection($transportName)) {
|
||||||
|
throw new IcingaException(
|
||||||
|
$this->translate('A command transport with the name "%s" does already exist'),
|
||||||
|
$transportName
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
unset($data['name']);
|
||||||
|
$this->config->setSection($transportName, $data);
|
||||||
|
return $this;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Edit an existing command transport
|
||||||
|
*
|
||||||
|
* @param string $name
|
||||||
|
* @param array $data
|
||||||
|
*
|
||||||
|
* @return $this
|
||||||
|
*
|
||||||
|
* @throws NotFoundError In case no transport with the given name is found
|
||||||
|
*/
|
||||||
|
public function edit($name, array $data)
|
||||||
|
{
|
||||||
|
if (! $this->config->hasSection($name)) {
|
||||||
|
throw new NotFoundError('No command transport called "%s" found', $name);
|
||||||
|
}
|
||||||
|
|
||||||
|
$transportConfig = $this->config->getSection($name);
|
||||||
|
if (isset($data['name'])) {
|
||||||
|
if ($data['name'] !== $name) {
|
||||||
|
$this->config->removeSection($name);
|
||||||
|
$name = $data['name'];
|
||||||
|
}
|
||||||
|
|
||||||
|
unset($data['name']);
|
||||||
|
}
|
||||||
|
|
||||||
|
$transportConfig->merge($data);
|
||||||
|
foreach ($transportConfig->toArray() as $k => $v) {
|
||||||
|
if ($v === null) {
|
||||||
|
unset($transportConfig->$k);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
$this->config->setSection($name, $transportConfig);
|
||||||
|
return $this;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Remove a command transport
|
||||||
|
*
|
||||||
|
* @param string $name
|
||||||
|
*
|
||||||
|
* @return $this
|
||||||
|
*/
|
||||||
|
public function delete($name)
|
||||||
|
{
|
||||||
|
$this->config->removeSection($name);
|
||||||
|
return $this;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Create and add elements to this form
|
||||||
|
*
|
||||||
|
* @param array $formData
|
||||||
|
*/
|
||||||
|
public function createElements(array $formData)
|
||||||
|
{
|
||||||
|
$instanceNames = $this->getInstanceNames();
|
||||||
|
if (count($instanceNames) > 1) {
|
||||||
|
$options = array('none' => $this->translate('None', 'command transport instance association'));
|
||||||
|
$this->addElement(
|
||||||
|
'select',
|
||||||
|
'instance',
|
||||||
|
array(
|
||||||
|
'label' => $this->translate('Instance Link'),
|
||||||
|
'description' => $this->translate(
|
||||||
|
'The name of the Icinga instance this transport should exclusively transfer commands to.'
|
||||||
|
),
|
||||||
|
'multiOptions' => array_merge($options, array_combine($instanceNames, $instanceNames))
|
||||||
|
)
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
$this->addElement(
|
||||||
|
'text',
|
||||||
|
'name',
|
||||||
|
array(
|
||||||
|
'required' => true,
|
||||||
|
'label' => $this->translate('Transport Name'),
|
||||||
|
'description' => $this->translate(
|
||||||
|
'The name of this command transport that is used to differentiate it from others'
|
||||||
|
),
|
||||||
|
'validators' => array(
|
||||||
|
array(
|
||||||
|
'Regex',
|
||||||
|
false,
|
||||||
|
array(
|
||||||
|
'pattern' => '/^[^\\[\\]:]+$/',
|
||||||
|
'messages' => array(
|
||||||
|
'regexNotMatch' => $this->translate(
|
||||||
|
'The name cannot contain \'[\', \']\' or \':\'.'
|
||||||
|
)
|
||||||
|
)
|
||||||
|
)
|
||||||
|
)
|
||||||
|
)
|
||||||
|
)
|
||||||
|
);
|
||||||
|
|
||||||
|
$transportTypes = array(
|
||||||
|
LocalCommandFile::TRANSPORT => $this->translate('Local Command File'),
|
||||||
|
RemoteCommandFile::TRANSPORT => $this->translate('Remote Command File')
|
||||||
|
);
|
||||||
|
|
||||||
|
$transportType = isset($formData['transport']) ? $formData['transport'] : null;
|
||||||
|
if ($transportType === null) {
|
||||||
|
$transportType = key($transportTypes);
|
||||||
|
}
|
||||||
|
|
||||||
|
$this->addElements(array(
|
||||||
|
array(
|
||||||
|
'select',
|
||||||
|
'transport',
|
||||||
|
array(
|
||||||
|
'required' => true,
|
||||||
|
'autosubmit' => true,
|
||||||
|
'label' => $this->translate('Transport Type'),
|
||||||
|
'multiOptions' => $transportTypes
|
||||||
|
)
|
||||||
|
)
|
||||||
|
));
|
||||||
|
|
||||||
|
$this->addSubForm($this->getTransportForm($transportType)->create($formData), 'transport_form');
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Populate the configuration of the transport to load
|
||||||
|
*/
|
||||||
|
public function onRequest()
|
||||||
|
{
|
||||||
|
if ($this->transportToLoad) {
|
||||||
|
$data = $this->config->getSection($this->transportToLoad)->toArray();
|
||||||
|
$data['name'] = $this->transportToLoad;
|
||||||
|
$this->populate($data);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Retrieve all form element values
|
||||||
|
*
|
||||||
|
* @param bool $suppressArrayNotation Ignored
|
||||||
|
*
|
||||||
|
* @return array
|
||||||
|
*/
|
||||||
|
public function getValues($suppressArrayNotation = false)
|
||||||
|
{
|
||||||
|
$values = parent::getValues();
|
||||||
|
$values = array_merge($values, $values['transport_form']);
|
||||||
|
unset($values['transport_form']);
|
||||||
|
return $values;
|
||||||
|
}
|
||||||
|
}
|
@ -1,32 +0,0 @@
|
|||||||
<?php
|
|
||||||
/* Icinga Web 2 | (c) 2013-2015 Icinga Development Team | GPLv2+ */
|
|
||||||
|
|
||||||
namespace Icinga\Module\Monitoring\Forms\Setup;
|
|
||||||
|
|
||||||
use Icinga\Web\Form;
|
|
||||||
use Icinga\Module\Monitoring\Forms\Config\InstanceConfigForm;
|
|
||||||
|
|
||||||
class InstancePage extends Form
|
|
||||||
{
|
|
||||||
public function init()
|
|
||||||
{
|
|
||||||
$this->setName('setup_monitoring_instance');
|
|
||||||
$this->setTitle($this->translate('Monitoring Instance', 'setup.page.title'));
|
|
||||||
$this->addDescription($this->translate(
|
|
||||||
'Please define the settings specific to your monitoring instance below.'
|
|
||||||
));
|
|
||||||
}
|
|
||||||
|
|
||||||
public function createElements(array $formData)
|
|
||||||
{
|
|
||||||
$instanceConfigForm = new InstanceConfigForm();
|
|
||||||
$this->addSubForm($instanceConfigForm, 'instance_form');
|
|
||||||
$instanceConfigForm->create($formData);
|
|
||||||
$instanceConfigForm->getElement('name')->setValue('icinga');
|
|
||||||
}
|
|
||||||
|
|
||||||
public function getValues($suppressArrayNotation = false)
|
|
||||||
{
|
|
||||||
return $this->getSubForm('instance_form')->getValues($suppressArrayNotation);
|
|
||||||
}
|
|
||||||
}
|
|
33
modules/monitoring/application/forms/Setup/TransportPage.php
Normal file
33
modules/monitoring/application/forms/Setup/TransportPage.php
Normal file
@ -0,0 +1,33 @@
|
|||||||
|
<?php
|
||||||
|
/* Icinga Web 2 | (c) 2013-2015 Icinga Development Team | GPLv2+ */
|
||||||
|
|
||||||
|
namespace Icinga\Module\Monitoring\Forms\Setup;
|
||||||
|
|
||||||
|
use Icinga\Web\Form;
|
||||||
|
use Icinga\Module\Monitoring\Forms\Config\TransportConfigForm;
|
||||||
|
|
||||||
|
class TransportPage extends Form
|
||||||
|
{
|
||||||
|
public function init()
|
||||||
|
{
|
||||||
|
$this->setName('setup_command_transport');
|
||||||
|
$this->setTitle($this->translate('Command Transport', 'setup.page.title'));
|
||||||
|
$this->addDescription($this->translate(
|
||||||
|
'Please define below how you want to send commands to your monitoring instance.'
|
||||||
|
));
|
||||||
|
}
|
||||||
|
|
||||||
|
public function createElements(array $formData)
|
||||||
|
{
|
||||||
|
$transportConfigForm = new TransportConfigForm();
|
||||||
|
$this->addSubForm($transportConfigForm, 'transport_form');
|
||||||
|
$transportConfigForm->create($formData);
|
||||||
|
$transportConfigForm->removeElement('instance');
|
||||||
|
$transportConfigForm->getElement('name')->setValue('icinga2');
|
||||||
|
}
|
||||||
|
|
||||||
|
public function getValues($suppressArrayNotation = false)
|
||||||
|
{
|
||||||
|
return $this->getSubForm('transport_form')->getValues($suppressArrayNotation);
|
||||||
|
}
|
||||||
|
}
|
@ -47,28 +47,28 @@
|
|||||||
<?php endforeach; ?>
|
<?php endforeach; ?>
|
||||||
</tbody>
|
</tbody>
|
||||||
</table>
|
</table>
|
||||||
<h1><?= $this->translate('Monitoring Instances') ?></h1>
|
<h1><?= $this->translate('Command Transports') ?></h1>
|
||||||
<p>
|
<p>
|
||||||
<a href="<?= $this->href('/monitoring/config/createinstance'); ?>">
|
<a href="<?= $this->href('/monitoring/config/createtransport'); ?>">
|
||||||
<?= $this->icon('plus'); ?> <?= $this->translate('Create New Instance'); ?>
|
<?= $this->icon('plus'); ?> <?= $this->translate('Create New Transport'); ?>
|
||||||
</a>
|
</a>
|
||||||
</p>
|
</p>
|
||||||
<table class="action alternating">
|
<table class="action alternating">
|
||||||
<thead>
|
<thead>
|
||||||
<th><?= $this->translate('Instance'); ?></th>
|
<th><?= $this->translate('Transport'); ?></th>
|
||||||
<th style="width: 5em"><?= $this->translate('Remove'); ?></th>
|
<th style="width: 5em"><?= $this->translate('Remove'); ?></th>
|
||||||
</thead>
|
</thead>
|
||||||
<tbody>
|
<tbody>
|
||||||
<?php foreach ($this->instancesConfig as $instanceName => $config): ?>
|
<?php foreach ($this->transportConfig as $transportName => $config): ?>
|
||||||
<tr>
|
<tr>
|
||||||
<td>
|
<td>
|
||||||
<?= $this->qlink(
|
<?= $this->qlink(
|
||||||
$instanceName,
|
$transportName,
|
||||||
'/monitoring/config/editinstance',
|
'/monitoring/config/edittransport',
|
||||||
array('instance' => $instanceName),
|
array('transport' => $transportName),
|
||||||
array(
|
array(
|
||||||
'icon' => 'edit',
|
'icon' => 'edit',
|
||||||
'title' => sprintf($this->translate('Edit monitoring instance %s'), $instanceName)
|
'title' => sprintf($this->translate('Edit command transport %s'), $transportName)
|
||||||
)
|
)
|
||||||
); ?>
|
); ?>
|
||||||
<small>(<?= sprintf(
|
<small>(<?= sprintf(
|
||||||
@ -79,11 +79,11 @@
|
|||||||
<td>
|
<td>
|
||||||
<?= $this->qlink(
|
<?= $this->qlink(
|
||||||
'',
|
'',
|
||||||
'/monitoring/config/removeinstance',
|
'/monitoring/config/removetransport',
|
||||||
array('instance' => $instanceName),
|
array('transport' => $transportName),
|
||||||
array(
|
array(
|
||||||
'icon' => 'trash',
|
'icon' => 'trash',
|
||||||
'title' => sprintf($this->translate('Remove monitoring instance %s'), $instanceName)
|
'title' => sprintf($this->translate('Remove command transport %s'), $transportName)
|
||||||
)
|
)
|
||||||
); ?>
|
); ?>
|
||||||
</td>
|
</td>
|
||||||
|
@ -0,0 +1,6 @@
|
|||||||
|
<div class="controls">
|
||||||
|
<?= $tabs; ?>
|
||||||
|
</div>
|
||||||
|
<div class="content">
|
||||||
|
<?= $form; ?>
|
||||||
|
</div>
|
96
modules/monitoring/doc/commandtransports.md
Normal file
96
modules/monitoring/doc/commandtransports.md
Normal file
@ -0,0 +1,96 @@
|
|||||||
|
# <a id="commandtransports"></a> The commandtransports.ini configuration file
|
||||||
|
|
||||||
|
## Abstract
|
||||||
|
|
||||||
|
The commandtransports.ini defines how Icinga Web 2 accesses the command pipe of
|
||||||
|
your Icinga instance in order to submit external commands. Depending on the
|
||||||
|
config path (default: /etc/icingaweb2) of your Icinga Web 2 installation you can
|
||||||
|
find it under ./modules/monitoring/commandtransports.ini.
|
||||||
|
|
||||||
|
## Syntax
|
||||||
|
|
||||||
|
You can define multiple command transports in the commandtransports.ini. Every
|
||||||
|
transport starts with a section header containing its name, followed by the
|
||||||
|
config directives for this transport in the standard INI-format.
|
||||||
|
|
||||||
|
Icinga Web 2 will try one transport after another to send a command, depending
|
||||||
|
on the respective Icinga instance, until the command is successfully sent. The
|
||||||
|
order in which Icinga Web 2 processes the configured transports is defined by
|
||||||
|
the order of sections in the commandtransports.ini.
|
||||||
|
|
||||||
|
## Using a local command pipe
|
||||||
|
|
||||||
|
A local Icinga instance requires the following directives:
|
||||||
|
|
||||||
|
````
|
||||||
|
[icinga2]
|
||||||
|
transport = local
|
||||||
|
path = /var/run/icinga2/cmd/icinga2.cmd
|
||||||
|
````
|
||||||
|
|
||||||
|
When sending commands to the Icinga instance, Icinga Web 2 opens the file found
|
||||||
|
on the local filesystem underneath 'path' and writes the external command to it.
|
||||||
|
|
||||||
|
## Using SSH for accessing a remote command pipe
|
||||||
|
|
||||||
|
A command pipe on a remote host's filesystem can be accessed by configuring a
|
||||||
|
SSH based command transport and requires the following directives:
|
||||||
|
|
||||||
|
````
|
||||||
|
[icinga2]
|
||||||
|
transport = remote
|
||||||
|
path = /var/run/icinga2/cmd/icinga2.cmd
|
||||||
|
host = example.tld
|
||||||
|
;port = 22 ; Optional. The default is 22
|
||||||
|
user = icinga
|
||||||
|
````
|
||||||
|
|
||||||
|
To make this example work, you'll need to permit your web-server's user
|
||||||
|
public-key based access to the defined remote host so that Icinga Web 2 can
|
||||||
|
connect to it and login as the defined user.
|
||||||
|
|
||||||
|
You can also make use of a dedicated SSH resource to permit access for a
|
||||||
|
different user than the web-server's one. This way, you can provide a private
|
||||||
|
key file on the local filesystem that is used to access the remote host.
|
||||||
|
|
||||||
|
To accomplish this, a new resource is required that is defined in your
|
||||||
|
transport's configuration instead of a user:
|
||||||
|
|
||||||
|
````
|
||||||
|
[icinga2]
|
||||||
|
transport = remote
|
||||||
|
path = /var/run/icinga2/cmd/icinga2.cmd
|
||||||
|
host = example.tld
|
||||||
|
;port = 22 ; Optional. The default is 22
|
||||||
|
resource = example.tld-icinga2
|
||||||
|
````
|
||||||
|
|
||||||
|
The resource's configuration needs to be put into the resources.ini file:
|
||||||
|
|
||||||
|
````
|
||||||
|
[example.tld-icinga2]
|
||||||
|
type = ssh
|
||||||
|
user = icinga
|
||||||
|
private_key = /etc/icingaweb2/ssh/icinga
|
||||||
|
````
|
||||||
|
|
||||||
|
## Configuring transports for different Icinga instances
|
||||||
|
|
||||||
|
If there are multiple but different Icinga instances writing to your IDO you can
|
||||||
|
define which transport belongs to which Icinga instance by providing the
|
||||||
|
directive 'instance'. This directive should contain the name of the Icinga
|
||||||
|
instance you want to assign to the transport:
|
||||||
|
|
||||||
|
````
|
||||||
|
[icinga1]
|
||||||
|
...
|
||||||
|
instance = icinga1
|
||||||
|
|
||||||
|
[icinga2]
|
||||||
|
...
|
||||||
|
instance = icinga2
|
||||||
|
````
|
||||||
|
|
||||||
|
Associating a transport to a specific Icinga instance causes this transport to
|
||||||
|
be used to send commands to the linked instance only. Transports without a
|
||||||
|
linked Icinga instance are utilized to send commands to all instances.
|
@ -10,7 +10,7 @@ stored in `/etc/icingaweb2` by default (depending on your config setup).
|
|||||||
modules/monitoring | Directory | `monitoring` module specific configuration
|
modules/monitoring | Directory | `monitoring` module specific configuration
|
||||||
modules/monitoring | config.ini | Security settings (e.g. protected custom vars) for the `monitoring` module
|
modules/monitoring | config.ini | Security settings (e.g. protected custom vars) for the `monitoring` module
|
||||||
modules/monitoring | backends.ini | Backend type and resources (e.g. Icinga IDO DB)
|
modules/monitoring | backends.ini | Backend type and resources (e.g. Icinga IDO DB)
|
||||||
modules/monitoring | [instances.ini](instances.md#instances) | Instances and their transport (e.g. local external command pipe)
|
modules/monitoring | [commandtransports.ini](commandtransports.md#commandtransports) | Command transports for specific Icinga instances
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
@ -1,55 +0,0 @@
|
|||||||
# <a id="instances"></a> The instance.ini configuration file
|
|
||||||
|
|
||||||
## Abstract
|
|
||||||
|
|
||||||
The instance.ini defines how icingaweb accesses the command pipe of your icinga process in order to submit external
|
|
||||||
commands. Depending on the config path (default: /etc/icingaweb2) of your icingaweb installation you can find it
|
|
||||||
under ./modules/monitoring/instances.ini.
|
|
||||||
|
|
||||||
## Syntax
|
|
||||||
|
|
||||||
You can define multiple instances in the instances.ini, icingaweb will use the first one as the default instance.
|
|
||||||
|
|
||||||
Every instance starts with a section header containing the name of the instance, followed by the config directives for
|
|
||||||
this instance in the standard ini format used by icingaweb.
|
|
||||||
|
|
||||||
## Using a local icinga pipe
|
|
||||||
|
|
||||||
A local icinga instance can be easily setup and only requires the 'path' parameter:
|
|
||||||
|
|
||||||
[icinga]
|
|
||||||
path=/usr/local/icinga/var/rw/icinga.cmd
|
|
||||||
|
|
||||||
When sending commands to the icinga instance, icingaweb just opens the file found underneath 'path' and writes the external
|
|
||||||
command to it.
|
|
||||||
|
|
||||||
## Using ssh for accessing an icinga pipe
|
|
||||||
|
|
||||||
When providing at least a host directive to the instances.ini, SSH will be used for accessing the pipe. You must have
|
|
||||||
setup key authentication at the endpoint and allow your icingweb's user to access the machine without a password at this time:
|
|
||||||
|
|
||||||
[icinga]
|
|
||||||
path=/usr/local/icinga/var/rw/icinga.cmd ; the path on the remote machine where the icinga.cmd can be found
|
|
||||||
host=my.remote.machine.com ; the hostname or address of the remote machine
|
|
||||||
port=22 ; the port to use (22 if none is given)
|
|
||||||
user=jdoe ; the user to authenticate with
|
|
||||||
|
|
||||||
You can also make use of the ssh resource for accessing an icinga pipe with key-based authentication, which will give
|
|
||||||
you the possibility to define the location of the private key for a specific user, let's have a look:
|
|
||||||
|
|
||||||
[icinga]
|
|
||||||
path=/usr/local/icinga/var/rw/icinga.cmd ; the path on the remote machine where the icinga.cmd can be found
|
|
||||||
host=my.remote.machine.com ; the hostname or address of the remote machine
|
|
||||||
port=22 ; the port to use (22 if none is given)
|
|
||||||
resource=ssh ; the ssh resource which contains the username and the location of the private key
|
|
||||||
|
|
||||||
And the associated ssh resource:
|
|
||||||
|
|
||||||
[ssh]
|
|
||||||
type = "ssh"
|
|
||||||
user = "ssh-user"
|
|
||||||
private_key = "/etc/icingaweb2/ssh/ssh-user"
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
@ -4,15 +4,19 @@
|
|||||||
namespace Icinga\Module\Monitoring\Command\Transport;
|
namespace Icinga\Module\Monitoring\Command\Transport;
|
||||||
|
|
||||||
use Icinga\Application\Config;
|
use Icinga\Application\Config;
|
||||||
|
use Icinga\Application\Logger;
|
||||||
use Icinga\Data\ConfigObject;
|
use Icinga\Data\ConfigObject;
|
||||||
use Icinga\Exception\ConfigurationError;
|
use Icinga\Exception\ConfigurationError;
|
||||||
|
use Icinga\Module\Monitoring\Command\IcingaCommand;
|
||||||
|
use Icinga\Module\Monitoring\Command\Object\ObjectCommand;
|
||||||
|
use Icinga\Module\Monitoring\Exception\CommandTransportException;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Command transport factory
|
* Command transport
|
||||||
*
|
*
|
||||||
* This class is subject to change as we do not have environments yet (#4471).
|
* This class is subject to change as we do not have environments yet (#4471).
|
||||||
*/
|
*/
|
||||||
abstract class CommandTransport
|
class CommandTransport implements CommandTransportInterface
|
||||||
{
|
{
|
||||||
/**
|
/**
|
||||||
* Transport configuration
|
* Transport configuration
|
||||||
@ -24,21 +28,25 @@ abstract class CommandTransport
|
|||||||
/**
|
/**
|
||||||
* Get transport configuration
|
* Get transport configuration
|
||||||
*
|
*
|
||||||
* @return Config
|
* @return Config
|
||||||
* @throws ConfigurationError
|
*
|
||||||
|
* @throws ConfigurationError
|
||||||
*/
|
*/
|
||||||
public static function getConfig()
|
public static function getConfig()
|
||||||
{
|
{
|
||||||
if (! isset(self::$config)) {
|
if (static::$config === null) {
|
||||||
self::$config = Config::module('monitoring', 'instances');
|
$config = Config::module('monitoring', 'commandtransports');
|
||||||
if (self::$config->isEmpty()) {
|
if ($config->isEmpty()) {
|
||||||
throw new ConfigurationError(
|
throw new ConfigurationError(
|
||||||
'No instances have been configured in \'%s\'.',
|
mt('monitoring', 'No command transports have been configured in "%s".'),
|
||||||
self::$config->getConfigFile()
|
$config->getConfigFile()
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static::$config = $config;
|
||||||
}
|
}
|
||||||
return self::$config;
|
|
||||||
|
return static::$config;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -47,9 +55,10 @@ abstract class CommandTransport
|
|||||||
* @param ConfigObject $config
|
* @param ConfigObject $config
|
||||||
*
|
*
|
||||||
* @return LocalCommandFile|RemoteCommandFile
|
* @return LocalCommandFile|RemoteCommandFile
|
||||||
|
*
|
||||||
* @throws ConfigurationError
|
* @throws ConfigurationError
|
||||||
*/
|
*/
|
||||||
public static function fromConfig(ConfigObject $config)
|
public static function createTransport(ConfigObject $config)
|
||||||
{
|
{
|
||||||
$config = clone $config;
|
$config = clone $config;
|
||||||
switch (strtolower($config->transport)) {
|
switch (strtolower($config->transport)) {
|
||||||
@ -62,14 +71,18 @@ abstract class CommandTransport
|
|||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
throw new ConfigurationError(
|
throw new ConfigurationError(
|
||||||
'Can\'t create command transport \'%s\'. Invalid transport defined in \'%s\'.'
|
mt(
|
||||||
. ' Use one of \'%s\' or \'%s\'.',
|
'monitoring',
|
||||||
|
'Cannot create command transport "%s". Invalid transport'
|
||||||
|
. ' defined in "%s". Use one of "%s" or "%s".'
|
||||||
|
),
|
||||||
$config->transport,
|
$config->transport,
|
||||||
self::$config->getConfigFile(),
|
static::getConfig()->getConfigFile(),
|
||||||
LocalCommandFile::TRANSPORT,
|
LocalCommandFile::TRANSPORT,
|
||||||
RemoteCommandFile::TRANSPORT
|
RemoteCommandFile::TRANSPORT
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
unset($config->transport);
|
unset($config->transport);
|
||||||
foreach ($config as $key => $value) {
|
foreach ($config as $key => $value) {
|
||||||
$method = 'set' . ucfirst($key);
|
$method = 'set' . ucfirst($key);
|
||||||
@ -79,37 +92,80 @@ abstract class CommandTransport
|
|||||||
// when being about to send a command
|
// when being about to send a command
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
$transport->$method($value);
|
$transport->$method($value);
|
||||||
}
|
}
|
||||||
|
|
||||||
return $transport;
|
return $transport;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Create a transport by name
|
* Send the given command over an appropriate Icinga command transport
|
||||||
*
|
*
|
||||||
* @param string $name
|
* This will try one configured transport after another until the command has been successfully sent.
|
||||||
*
|
*
|
||||||
* @return LocalCommandFile|RemoteCommandFile
|
* @param IcingaCommand $command The command to send
|
||||||
* @throws ConfigurationError
|
* @param int|null $now Timestamp of the command or null for now
|
||||||
|
*
|
||||||
|
* @throws CommandTransportException If sending the Icinga command failed
|
||||||
*/
|
*/
|
||||||
public static function create($name)
|
public function send(IcingaCommand $command, $now = null)
|
||||||
{
|
{
|
||||||
$config = self::getConfig()->getSection($name);
|
$tries = 0;
|
||||||
if ($config->isEmpty()) {
|
foreach (static::getConfig() as $transportConfig) {
|
||||||
throw new ConfigurationError();
|
$transport = static::createTransport($transportConfig);
|
||||||
|
|
||||||
|
if ($this->transferPossible($command, $transport)) {
|
||||||
|
try {
|
||||||
|
$transport->send($command, $now);
|
||||||
|
} catch (CommandTransportException $e) {
|
||||||
|
Logger::error($e);
|
||||||
|
$tries += 1;
|
||||||
|
continue; // Try the next transport
|
||||||
|
}
|
||||||
|
|
||||||
|
return; // The command was successfully sent
|
||||||
|
}
|
||||||
}
|
}
|
||||||
return self::fromConfig($config);
|
|
||||||
|
if ($tries > 0) {
|
||||||
|
throw new CommandTransportException(
|
||||||
|
mt(
|
||||||
|
'monitoring',
|
||||||
|
'Failed to send external Icinga command. None of the configured transports'
|
||||||
|
. ' was able to transfer the command. Please see the log for more details.'
|
||||||
|
)
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
throw new CommandTransportException(
|
||||||
|
mt(
|
||||||
|
'monitoring',
|
||||||
|
'Failed to send external Icinga command. No transport has been configured'
|
||||||
|
. ' for this instance. Please contact your Icinga Web administrator.'
|
||||||
|
)
|
||||||
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Create a transport by the first section of the configuration
|
* Return whether it is possible to send the given command using the given transport
|
||||||
*
|
*
|
||||||
* @return LocalCommandFile|RemoteCommandFile
|
* @param IcingaCommand $command
|
||||||
|
* @param CommandTransportInterface $transport
|
||||||
|
*
|
||||||
|
* @return bool
|
||||||
*/
|
*/
|
||||||
public static function first()
|
protected function transferPossible($command, $transport)
|
||||||
{
|
{
|
||||||
$config = self::getConfig();
|
if (! method_exists($transport, 'getInstance') || !$command instanceof ObjectCommand) {
|
||||||
$config->rewind();
|
return true;
|
||||||
return self::fromConfig($config->current());
|
}
|
||||||
|
|
||||||
|
$transportInstance = $transport->getInstance();
|
||||||
|
if (! $transportInstance || $transportInstance === 'none') {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
return strtolower($transportInstance) === strtolower($command->getObject()->instance_name);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -22,6 +22,13 @@ class LocalCommandFile implements CommandTransportInterface
|
|||||||
*/
|
*/
|
||||||
const TRANSPORT = 'local';
|
const TRANSPORT = 'local';
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The name of the Icinga instance this transport will transfer commands to
|
||||||
|
*
|
||||||
|
* @var string
|
||||||
|
*/
|
||||||
|
protected $instanceName;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Path to the icinga command file
|
* Path to the icinga command file
|
||||||
*
|
*
|
||||||
@ -51,6 +58,29 @@ class LocalCommandFile implements CommandTransportInterface
|
|||||||
$this->renderer = new IcingaCommandFileCommandRenderer();
|
$this->renderer = new IcingaCommandFileCommandRenderer();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Set the name of the Icinga instance this transport will transfer commands to
|
||||||
|
*
|
||||||
|
* @param string $name
|
||||||
|
*
|
||||||
|
* @return $this
|
||||||
|
*/
|
||||||
|
public function setInstance($name)
|
||||||
|
{
|
||||||
|
$this->instanceName = $name;
|
||||||
|
return $this;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Return the name of the Icinga instance this transport will transfer commands to
|
||||||
|
*
|
||||||
|
* @return string
|
||||||
|
*/
|
||||||
|
public function getInstance()
|
||||||
|
{
|
||||||
|
return $this->instanceName;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Set the path to the local Icinga command file
|
* Set the path to the local Icinga command file
|
||||||
*
|
*
|
||||||
|
@ -22,6 +22,13 @@ class RemoteCommandFile implements CommandTransportInterface
|
|||||||
*/
|
*/
|
||||||
const TRANSPORT = 'remote';
|
const TRANSPORT = 'remote';
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The name of the Icinga instance this transport will transfer commands to
|
||||||
|
*
|
||||||
|
* @var string
|
||||||
|
*/
|
||||||
|
protected $instanceName;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Remote host
|
* Remote host
|
||||||
*
|
*
|
||||||
@ -74,6 +81,29 @@ class RemoteCommandFile implements CommandTransportInterface
|
|||||||
$this->renderer = new IcingaCommandFileCommandRenderer();
|
$this->renderer = new IcingaCommandFileCommandRenderer();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Set the name of the Icinga instance this transport will transfer commands to
|
||||||
|
*
|
||||||
|
* @param string $name
|
||||||
|
*
|
||||||
|
* @return $this
|
||||||
|
*/
|
||||||
|
public function setInstance($name)
|
||||||
|
{
|
||||||
|
$this->instanceName = $name;
|
||||||
|
return $this;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Return the name of the Icinga instance this transport will transfer commands to
|
||||||
|
*
|
||||||
|
* @return string
|
||||||
|
*/
|
||||||
|
public function getInstance()
|
||||||
|
{
|
||||||
|
return $this->instanceName;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Set the remote host
|
* Set the remote host
|
||||||
*
|
*
|
||||||
|
@ -12,8 +12,8 @@ use Icinga\Module\Setup\RequirementSet;
|
|||||||
use Icinga\Module\Setup\Forms\SummaryPage;
|
use Icinga\Module\Setup\Forms\SummaryPage;
|
||||||
use Icinga\Module\Monitoring\Forms\Setup\WelcomePage;
|
use Icinga\Module\Monitoring\Forms\Setup\WelcomePage;
|
||||||
use Icinga\Module\Monitoring\Forms\Setup\BackendPage;
|
use Icinga\Module\Monitoring\Forms\Setup\BackendPage;
|
||||||
use Icinga\Module\Monitoring\Forms\Setup\InstancePage;
|
|
||||||
use Icinga\Module\Monitoring\Forms\Setup\SecurityPage;
|
use Icinga\Module\Monitoring\Forms\Setup\SecurityPage;
|
||||||
|
use Icinga\Module\Monitoring\Forms\Setup\TransportPage;
|
||||||
use Icinga\Module\Monitoring\Forms\Setup\IdoResourcePage;
|
use Icinga\Module\Monitoring\Forms\Setup\IdoResourcePage;
|
||||||
use Icinga\Module\Monitoring\Forms\Setup\LivestatusResourcePage;
|
use Icinga\Module\Monitoring\Forms\Setup\LivestatusResourcePage;
|
||||||
use Icinga\Module\Setup\Requirement\ClassRequirement;
|
use Icinga\Module\Setup\Requirement\ClassRequirement;
|
||||||
@ -33,7 +33,7 @@ class MonitoringWizard extends Wizard implements SetupWizard
|
|||||||
$this->addPage(new BackendPage());
|
$this->addPage(new BackendPage());
|
||||||
$this->addPage(new IdoResourcePage());
|
$this->addPage(new IdoResourcePage());
|
||||||
$this->addPage(new LivestatusResourcePage());
|
$this->addPage(new LivestatusResourcePage());
|
||||||
$this->addPage(new InstancePage());
|
$this->addPage(new TransportPage());
|
||||||
$this->addPage(new SecurityPage());
|
$this->addPage(new SecurityPage());
|
||||||
$this->addPage(new SummaryPage(array('name' => 'setup_monitoring_summary')));
|
$this->addPage(new SummaryPage(array('name' => 'setup_monitoring_summary')));
|
||||||
}
|
}
|
||||||
@ -150,8 +150,8 @@ class MonitoringWizard extends Wizard implements SetupWizard
|
|||||||
);
|
);
|
||||||
|
|
||||||
$setup->addStep(
|
$setup->addStep(
|
||||||
new InstanceStep(array(
|
new TransportStep(array(
|
||||||
'instanceConfig' => $pageData['setup_monitoring_instance']
|
'transportConfig' => $pageData['setup_command_transport']
|
||||||
))
|
))
|
||||||
);
|
);
|
||||||
|
|
||||||
|
@ -8,7 +8,7 @@ use Icinga\Module\Setup\Step;
|
|||||||
use Icinga\Application\Config;
|
use Icinga\Application\Config;
|
||||||
use Icinga\Exception\IcingaException;
|
use Icinga\Exception\IcingaException;
|
||||||
|
|
||||||
class InstanceStep extends Step
|
class TransportStep extends Step
|
||||||
{
|
{
|
||||||
protected $data;
|
protected $data;
|
||||||
|
|
||||||
@ -21,13 +21,13 @@ class InstanceStep extends Step
|
|||||||
|
|
||||||
public function apply()
|
public function apply()
|
||||||
{
|
{
|
||||||
$instanceConfig = $this->data['instanceConfig'];
|
$transportConfig = $this->data['transportConfig'];
|
||||||
$instanceName = $instanceConfig['name'];
|
$transportName = $transportConfig['name'];
|
||||||
unset($instanceConfig['name']);
|
unset($transportConfig['name']);
|
||||||
|
|
||||||
try {
|
try {
|
||||||
Config::fromArray(array($instanceName => $instanceConfig))
|
Config::fromArray(array($transportName => $transportConfig))
|
||||||
->setConfigFile(Config::resolvePath('modules/monitoring/instances.ini'))
|
->setConfigFile(Config::resolvePath('modules/monitoring/commandtransports.ini'))
|
||||||
->saveIni();
|
->saveIni();
|
||||||
} catch (Exception $e) {
|
} catch (Exception $e) {
|
||||||
$this->error = $e;
|
$this->error = $e;
|
||||||
@ -40,16 +40,16 @@ class InstanceStep extends Step
|
|||||||
|
|
||||||
public function getSummary()
|
public function getSummary()
|
||||||
{
|
{
|
||||||
$pageTitle = '<h2>' . mt('monitoring', 'Monitoring Instance', 'setup.page.title') . '</h2>';
|
$pageTitle = '<h2>' . mt('monitoring', 'Command Transport', 'setup.page.title') . '</h2>';
|
||||||
|
|
||||||
if (isset($this->data['instanceConfig']['host'])) {
|
if (isset($this->data['transportConfig']['host'])) {
|
||||||
$pipeHtml = '<p>' . sprintf(
|
$pipeHtml = '<p>' . sprintf(
|
||||||
mt(
|
mt(
|
||||||
'monitoring',
|
'monitoring',
|
||||||
'Icinga Web 2 will use the named pipe located on a remote machine at "%s" to send commands'
|
'Icinga Web 2 will use the named pipe located on a remote machine at "%s" to send commands'
|
||||||
. ' to your monitoring instance by using the connection details listed below:'
|
. ' to your monitoring instance by using the connection details listed below:'
|
||||||
),
|
),
|
||||||
$this->data['instanceConfig']['path']
|
$this->data['transportConfig']['path']
|
||||||
) . '</p>';
|
) . '</p>';
|
||||||
|
|
||||||
$pipeHtml .= ''
|
$pipeHtml .= ''
|
||||||
@ -57,15 +57,15 @@ class InstanceStep extends Step
|
|||||||
. '<tbody>'
|
. '<tbody>'
|
||||||
. '<tr>'
|
. '<tr>'
|
||||||
. '<td><strong>' . mt('monitoring', 'Remote Host') . '</strong></td>'
|
. '<td><strong>' . mt('monitoring', 'Remote Host') . '</strong></td>'
|
||||||
. '<td>' . $this->data['instanceConfig']['host'] . '</td>'
|
. '<td>' . $this->data['transportConfig']['host'] . '</td>'
|
||||||
. '</tr>'
|
. '</tr>'
|
||||||
. '<tr>'
|
. '<tr>'
|
||||||
. '<td><strong>' . mt('monitoring', 'Remote SSH Port') . '</strong></td>'
|
. '<td><strong>' . mt('monitoring', 'Remote SSH Port') . '</strong></td>'
|
||||||
. '<td>' . $this->data['instanceConfig']['port'] . '</td>'
|
. '<td>' . $this->data['transportConfig']['port'] . '</td>'
|
||||||
. '</tr>'
|
. '</tr>'
|
||||||
. '<tr>'
|
. '<tr>'
|
||||||
. '<td><strong>' . mt('monitoring', 'Remote SSH User') . '</strong></td>'
|
. '<td><strong>' . mt('monitoring', 'Remote SSH User') . '</strong></td>'
|
||||||
. '<td>' . $this->data['instanceConfig']['user'] . '</td>'
|
. '<td>' . $this->data['transportConfig']['user'] . '</td>'
|
||||||
. '</tr>'
|
. '</tr>'
|
||||||
. '</tbody>'
|
. '</tbody>'
|
||||||
. '</table>';
|
. '</table>';
|
||||||
@ -76,7 +76,7 @@ class InstanceStep extends Step
|
|||||||
'Icinga Web 2 will use the named pipe located at "%s"'
|
'Icinga Web 2 will use the named pipe located at "%s"'
|
||||||
. ' to send commands to your monitoring instance.'
|
. ' to send commands to your monitoring instance.'
|
||||||
),
|
),
|
||||||
$this->data['instanceConfig']['path']
|
$this->data['transportConfig']['path']
|
||||||
) . '</p>';
|
) . '</p>';
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -87,17 +87,17 @@ class InstanceStep extends Step
|
|||||||
{
|
{
|
||||||
if ($this->error === false) {
|
if ($this->error === false) {
|
||||||
return array(sprintf(
|
return array(sprintf(
|
||||||
mt('monitoring', 'Monitoring instance configuration has been successfully created: %s'),
|
mt('monitoring', 'Command transport configuration has been successfully created: %s'),
|
||||||
Config::resolvePath('modules/monitoring/instances.ini')
|
Config::resolvePath('modules/monitoring/commandtransports.ini')
|
||||||
));
|
));
|
||||||
} elseif ($this->error !== null) {
|
} elseif ($this->error !== null) {
|
||||||
return array(
|
return array(
|
||||||
sprintf(
|
sprintf(
|
||||||
mt(
|
mt(
|
||||||
'monitoring',
|
'monitoring',
|
||||||
'Monitoring instance configuration could not be written to: %s. An error occured:'
|
'Command transport configuration could not be written to: %s. An error occured:'
|
||||||
),
|
),
|
||||||
Config::resolvePath('modules/monitoring/instances.ini')
|
Config::resolvePath('modules/monitoring/commandtransports.ini')
|
||||||
),
|
),
|
||||||
sprintf(mt('setup', 'ERROR: %s'), IcingaException::describe($this->error))
|
sprintf(mt('setup', 'ERROR: %s'), IcingaException::describe($this->error))
|
||||||
);
|
);
|
@ -89,7 +89,7 @@ By default the Icinga 2 DB IDO is used by the monitoring module in
|
|||||||
|
|
||||||
The external command pipe is required for sending commands
|
The external command pipe is required for sending commands
|
||||||
and configured for Icinga 2 in
|
and configured for Icinga 2 in
|
||||||
`/etc/icingaweb2/modules/monitoring/instances.ini`
|
`/etc/icingaweb2/modules/monitoring/commandtransports.ini`
|
||||||
|
|
||||||
#### Authentication configuration
|
#### Authentication configuration
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user