/**
  * (non-PHPDoc)
  * @see \Icinga\Web\Form::onSuccess() For the method documentation.
  */
 public function onSuccess()
 {
     foreach ($this->objects as $object) {
         /** @var \Icinga\Module\Monitoring\Object\Service $object */
         $check = new ScheduleServiceCheckCommand();
         $check->setObject($object);
         $this->scheduleCheck($check, $this->request);
     }
     Notification::success($this->translatePlural('Scheduling service check..', 'Scheduling service checks..', count($this->objects)));
     return true;
 }
예제 #2
0
 /**
  * (non-PHPDoc)
  * @see \Icinga\Web\Form::onSuccess() For the method documentation.
  */
 public function onSuccess()
 {
     foreach ($this->objects as $object) {
         /** @var \Icinga\Module\Monitoring\Object\MonitoredObject $object */
         if ($object->getType() === $object::TYPE_HOST) {
             $check = new ScheduleHostCheckCommand();
         } else {
             $check = new ScheduleServiceCheckCommand();
         }
         $check->setObject($object)->setForced()->setCheckTime(time());
         $this->getTransport($this->request)->send($check);
     }
     Notification::success(mtp('monitoring', 'Scheduling check..', 'Scheduling checks..', count($this->objects)));
     return true;
 }
 public function renderScheduleCheck(ScheduleServiceCheckCommand $command)
 {
     $object = $command->getObject();
     if ($command->getObject()->getType() === $command::TYPE_HOST) {
         /** @var \Icinga\Module\Monitoring\Object\Host $object */
         /** @var \Icinga\Module\Monitoring\Command\Object\ScheduleHostCheckCommand $command */
         if ($command->getOfAllServices() === true) {
             if ($command->getForced() === true) {
                 $commandName = 'SCHEDULE_FORCED_HOST_SVC_CHECKS';
             } else {
                 $commandName = 'SCHEDULE_HOST_SVC_CHECKS';
             }
         } else {
             if ($command->getForced() === true) {
                 $commandName = 'SCHEDULE_FORCED_HOST_CHECK';
             } else {
                 $commandName = 'SCHEDULE_HOST_CHECK';
             }
         }
         $commandString = sprintf('%s;%s', $commandName, $object->getName());
     } else {
         /** @var \Icinga\Module\Monitoring\Object\Service $object */
         $commandString = sprintf('%s;%s;%s', $command->getForced() === true ? 'SCHEDULE_FORCED_SVC_CHECK' : 'SCHEDULE_SVC_CHECK', $object->getHost()->getName(), $object->getName());
     }
     return sprintf('%s;%u', $commandString, $command->getCheckTime());
 }
 protected function restoreSchedule($hostname)
 {
     $host = $this->getHostObject($hostname);
     $cmd = new ScheduleHostCheckCommand();
     $cmd->setObject($host)->setCheckTime($this->schedule[$hostname]['host']);
     $this->getTransport()->send($cmd);
     foreach ($this->schedule[$hostname]['services'] as $service => $time) {
         $service = $this->getServiceObject($hostname, $service);
         if ($time < time()) {
             continue;
         }
         $cmd = new ScheduleServiceCheckCommand();
         $cmd->setObject($service)->setCheckTime($time);
         $this->getTransport()->send($cmd);
     }
 }
 public function renderScheduleCheck(ScheduleServiceCheckCommand $command)
 {
     $endpoint = 'actions/reschedule-check';
     $data = array('next_check' => $command->getCheckTime(), 'force_check' => $command->getForced());
     $this->applyFilter($data, $command->getObject());
     return IcingaApiCommand::create($endpoint, $data);
 }