2015-04-24 14:26:44 +02:00
|
|
|
<?php
|
|
|
|
|
|
|
|
namespace Icinga\Module\Director\Forms;
|
|
|
|
|
|
|
|
use Icinga\Module\Director\Web\Form\DirectorObjectForm;
|
|
|
|
|
|
|
|
class IcingaCommandForm extends DirectorObjectForm
|
|
|
|
{
|
|
|
|
public function setup()
|
|
|
|
{
|
2016-02-17 21:58:28 +01:00
|
|
|
$this->addObjectTypeElement();
|
2016-03-07 14:20:58 +01:00
|
|
|
if (! $this->hasObjectType()) {
|
|
|
|
return;
|
|
|
|
}
|
2016-02-17 21:58:28 +01:00
|
|
|
|
|
|
|
$this->addElement('select', 'methods_execute', array(
|
|
|
|
'label' => $this->translate('Command type'),
|
|
|
|
'multiOptions' => array(
|
|
|
|
null => '- please choose -',
|
2016-03-22 21:22:09 +01:00
|
|
|
$this->translate('Plugin commands') => array(
|
|
|
|
'PluginCheck' => 'Plugin Check Command',
|
|
|
|
'PluginNotification' => 'Notification Plugin Command',
|
|
|
|
'PluginEvent' => 'Event Plugin Command',
|
|
|
|
),
|
|
|
|
$this->translate('Internal commands') => array(
|
|
|
|
'IcingaCheck' => 'Icinga Check Command',
|
|
|
|
'ClusterCheck' => 'Icinga Cluster Check Command',
|
|
|
|
'ClusterZoneCheck' => 'Icinga Cluster Zone Check Command',
|
|
|
|
'IdoCheck' => 'Ido Check Command',
|
|
|
|
'RandomCheck' => 'Random Check Command',
|
|
|
|
'CrlCheck' => 'Crl Check Command',
|
|
|
|
)
|
2016-02-17 21:58:28 +01:00
|
|
|
),
|
2016-03-09 19:38:15 +01:00
|
|
|
'required' => ! $this->isTemplate(),
|
|
|
|
'description' => $this->translate(
|
|
|
|
'Plugin Check commands are what you need when running checks agains'
|
|
|
|
. ' your infrastructure. Notification commands will be used when it'
|
|
|
|
. ' comes to notify your users. Event commands allow you to trigger'
|
|
|
|
. ' specific actions when problems occur. Some people use them for'
|
|
|
|
. ' auto-healing mechanisms, like restarting services or rebooting'
|
|
|
|
. ' systems at specific thresholds'
|
|
|
|
),
|
|
|
|
'class' => 'autosubmit'
|
2016-02-17 21:58:28 +01:00
|
|
|
));
|
2015-04-24 14:26:44 +02:00
|
|
|
|
|
|
|
$this->addElement('text', 'object_name', array(
|
|
|
|
'label' => $this->translate('Command name'),
|
|
|
|
'required' => true,
|
|
|
|
'description' => $this->translate('Identifier for the Icinga command you are going to create')
|
|
|
|
));
|
|
|
|
|
2015-11-06 09:12:19 +01:00
|
|
|
$this->addImportsElement();
|
|
|
|
|
2015-08-28 23:37:06 +02:00
|
|
|
$this->addElement('text', 'command', array(
|
|
|
|
'label' => $this->translate('Command'),
|
2015-12-02 02:45:16 +01:00
|
|
|
'required' => ! $this->isTemplate(),
|
2016-02-26 12:42:21 +01:00
|
|
|
'description' => $this->translate(
|
|
|
|
'The command Icinga should run. Absolute paths are accepted as provided,'
|
|
|
|
. ' relative paths are prefixed with "PluginDir + ", similar Constant prefixes are allowed.'
|
|
|
|
. ' Spaces will lead to separation of command path and standalone arguments. Please note that'
|
|
|
|
. ' this means that we do not support spaces in plugin names and paths right now.'
|
|
|
|
)
|
2015-08-28 23:37:06 +02:00
|
|
|
));
|
|
|
|
|
2015-04-24 14:26:44 +02:00
|
|
|
$this->addElement('text', 'timeout', array(
|
|
|
|
'label' => $this->translate('Timeout'),
|
2016-03-09 18:33:03 +01:00
|
|
|
'description' => $this->translate(
|
|
|
|
'Optional command timeout. Allowed values are seconds or durations postfixed with a'
|
|
|
|
. ' specific unit (e.g. 1m or also 3m 30s).'
|
|
|
|
)
|
2015-04-24 14:26:44 +02:00
|
|
|
));
|
2016-02-17 20:10:22 +01:00
|
|
|
$this->addDisabledElement();
|
2015-04-24 14:26:44 +02:00
|
|
|
|
2015-11-06 09:12:19 +01:00
|
|
|
$this->setButtons();
|
2015-04-24 14:26:44 +02:00
|
|
|
}
|
|
|
|
}
|