diff --git a/modules/monitoring/application/forms/Command/Object/CheckNowCommandForm.php b/modules/monitoring/application/forms/Command/Object/CheckNowCommandForm.php index ade78402c..6cdf620f4 100644 --- a/modules/monitoring/application/forms/Command/Object/CheckNowCommandForm.php +++ b/modules/monitoring/application/forms/Command/Object/CheckNowCommandForm.php @@ -31,8 +31,8 @@ class CheckNowCommandForm extends ObjectsCommandForm { $this->addElements(array( array( - 'note', - 'icon', + 'note', // Bogus + 'icon', // Bogus array( 'decorators' => array(array( 'HtmlTag', diff --git a/modules/monitoring/application/forms/Command/Object/ScheduleHostCheckCommandForm.php b/modules/monitoring/application/forms/Command/Object/ScheduleHostCheckCommandForm.php new file mode 100644 index 000000000..81a277004 --- /dev/null +++ b/modules/monitoring/application/forms/Command/Object/ScheduleHostCheckCommandForm.php @@ -0,0 +1,57 @@ +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; + } +} diff --git a/modules/monitoring/application/forms/Command/Object/ScheduleServiceCheckCommandForm.php b/modules/monitoring/application/forms/Command/Object/ScheduleServiceCheckCommandForm.php index 477fb1733..ae8f23384 100644 --- a/modules/monitoring/application/forms/Command/Object/ScheduleServiceCheckCommandForm.php +++ b/modules/monitoring/application/forms/Command/Object/ScheduleServiceCheckCommandForm.php @@ -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;