/** 
  * Generate modules configuration files
  * @param array $filesList
  * @param int $pollerId
  * @param string $path
  * @param object $event
  * @return value
  */
 public function generate(&$filesList, $pollerId, $path, $event)
 {
     $di = Di::getDefault();
     /* Get Database Connexion */
     $dbconn = $di->get('db_centreon');
     $modules = array();
     /* Retrieve broker modules */
     $events = Di::getDefault()->get('events');
     $moduleEvent = new BrokerModuleEvent($pollerId);
     $events->emit('centreon-configuration.broker.module', array($moduleEvent));
     $brokerModules = $moduleEvent->getModules();
     foreach ($brokerModules as $brokerModule) {
         $modules[]['broker_module'] = $brokerModule;
     }
     /* External command module */
     $moduleDir = Engine::getParameters($pollerId, 'module_dir');
     $modules[]['broker_module'] = rtrim($moduleDir['module_dir'], '/') . '/externalcmd.so';
     /* Write modules configuration files */
     foreach ($modules as $module) {
         $filename = preg_match('/\\/?(\\w+)\\.so/', $module['broker_module'], $matches);
         if (!empty($matches[1])) {
             WriteConfigFile::writeParamsFile($module, $path . $pollerId . "/conf.d/" . $matches[1] . '.cfg', $filesList, $user = "******");
         }
     }
 }
 public function testSave()
 {
     $params['log_initial_states'] = 1;
     EngineRepository::save(1, $params);
     $value = Engine::get(1, 'log_initial_states');
     $this->assertEquals(1, $value['log_initial_states']);
 }
Example #3
0
 /**
  * @param Core\Events\LoadFormDatas $event
  */
 public static function execute(LoadFormDatasEvent $event)
 {
     $route = $event->getRoute();
     $objectId = $event->getObjectId();
     $parameters = $event->getParameters();
     if ($route === '/centreon-configuration/poller/update') {
         try {
             $engineParameters = Engine::getParameters($objectId, "*");
             $engineCompleteParameters = array();
             foreach ($engineParameters as $key => $value) {
                 $engineCompleteParameters['centreon-engine__' . $key] = $value;
             }
             $event->addParameters($engineCompleteParameters);
         } catch (\Exception $e) {
         }
     }
 }
Example #4
0
 /**
  * Execute the event
  *
  * @param \CentreonMain\Events\Generic $event The object for event
  */
 public static function execute(GenericEvent $event)
 {
     $input = $event->getInput();
     if (false === isset($input['poller_id'])) {
         throw new \InvalidArgumentException();
     }
     $pollerInformation = Engine::get($input['poller_id']);
     $delimiter = '';
     if (isset($input['delimiter'])) {
         $delimiter = $input['delimiter'];
     }
     $keys = array_map(function ($name) use($delimiter) {
         return $delimiter . 'engine_' . $name . $delimiter;
     }, array_keys($pollerInformation));
     $values = array_combine($keys, array_values($pollerInformation));
     $event->setOutput($values);
 }