monitoring/commands: Add schedule host check command form

refs #6593
This commit is contained in:
Eric Lippmann 2014-09-16 18:48:36 +02:00
parent 4d8b6dddf1
commit 71ffd0ed74
3 changed files with 69 additions and 7 deletions

View File

@ -31,8 +31,8 @@ class CheckNowCommandForm extends ObjectsCommandForm
{
$this->addElements(array(
array(
'note',
'icon',
'note', // Bogus
'icon', // Bogus
array(
'decorators' => array(array(
'HtmlTag',

View File

@ -0,0 +1,57 @@
<?php
// {{{ICINGA_LICENSE_HEADER}}}
// {{{ICINGA_LICENSE_HEADER}}}
namespace Icinga\Module\Monitoring\Form\Command\Object;
use Icinga\Module\Monitoring\Command\Object\ScheduleHostCheckCommand;
use Icinga\Web\Notification;
use Icinga\Web\Request;
/**
* Form for scheduling host checks
*/
class ScheduleHostCheckCommandForm extends ScheduleServiceCheckCommandForm
{
/**
* (non-PHPDoc)
* @see \Icinga\Web\Form::createElements() For the method documentation.
*/
public function createElements(array $formData = array())
{
parent::createElements($formData);
$this->addElements(array(
array(
'checkbox',
'all_services',
array(
'label' => mt('monitoring', 'All Services'),
'value' => true,
'description' => mt(
'monitoring',
'Schedule check for all services on the hosts and the hosts themself.'
)
)
)
));
return $this;
}
/**
* (non-PHPDoc)
* @see \Icinga\Web\Form::onSuccess() For the method documentation.
*/
public function onSuccess(Request $request)
{
foreach ($this->objects as $object) {
/** @var \Icinga\Module\Monitoring\Object\Host $object */
$check = new ScheduleHostCheckCommand();
$check
->setObject($object)
->setOfAllServices($this->getElement('all_services')->isChecked());
$this->scheduleCheck($check, $request);
}
Notification::success(mt('monitoring', 'Scheduling host check..'));
return true;
}
}

View File

@ -70,6 +70,14 @@ class ScheduleServiceCheckCommandForm extends ObjectsCommandForm
return $this;
}
public function scheduleCheck(ScheduleServiceCheckCommand $check, Request $request)
{
$check
->setForced($this->getElement('force_check')->isChecked())
->setCheckTime($this->getElement('check_time')->getValue()->getTimestamp());
$this->getTransport($request)->send($check);
}
/**
* (non-PHPDoc)
* @see \Icinga\Web\Form::onSuccess() For the method documentation.
@ -79,11 +87,8 @@ class ScheduleServiceCheckCommandForm extends ObjectsCommandForm
foreach ($this->objects as $object) {
/** @var \Icinga\Module\Monitoring\Object\Service $object */
$check = new ScheduleServiceCheckCommand();
$check
->setObject($object)
->setForced((bool) $this->getElement('force_check')->getValue())
->setCheckTime($this->getElement('check_time')->getValue());
$this->getTransport($request)->send($check);
$check->setObject($object);
$this->scheduleCheck($check, $request);
}
Notification::success(mt('monitoring', 'Scheduling service check..'));
return true;