Example #1
0
 /**
  * Return whether a single icinga instance is writing to the given resource
  *
  * @param   Form            $form
  * @param   ConfigObject    $resourceConfig
  *
  * @return  bool                                True if it's a single instance, false if none
  *                                              or multiple instances are writing to it
  */
 public static function isValidIdoInstance(Form $form, ConfigObject $resourceConfig)
 {
     $db = ResourceFactory::createResource($resourceConfig);
     $rowCount = $db->select()->from('icinga_instances')->count();
     if ($rowCount === 0) {
         $form->warning($form->translate('There is currently no icinga instance writing to the IDO. Make sure ' . 'that a icinga instance is configured and able to write to the IDO.'));
         return false;
     } elseif ($rowCount > 1) {
         $form->warning($form->translate('There is currently more than one icinga instance writing to the IDO. You\'ll see all objects from all' . ' instances without any differentation. If this is not desired, consider setting up a separate IDO' . ' for each instance.'));
         return false;
     }
     return true;
 }
Example #2
0
 /**
  * Validate the ido instance availability
  *
  * @param   Form            $form
  * @param   ConfigObject    $resourceConfig
  *
  * @return  bool                                Whether validation succeeded or not
  */
 public static function isValidIdoInstance(Form $form, ConfigObject $resourceConfig)
 {
     $resource = ResourceFactory::createResource($resourceConfig);
     $result = $resource->select()->from('icinga_instances', array('instance_name'));
     $instances = $result->fetchAll();
     if (count($instances) === 1) {
         return true;
     } elseif (count($instances) > 1) {
         $form->warning($form->translate('IDO instance validation failed, because there are multiple instances available.'));
         return false;
     }
     $form->error($form->translate('IDO instance validation failed, because there is no IDO instance available.'));
     return false;
 }