/** * Execute action * * @param \CentreonConfiguration\Events\SynchronizeDatabase $event * @throws Exception */ public static function execute(SynchronizeDatabaseEvent $event) { try { BrokerRepository::sendCommand($event->getPollerId(), 'SYNC_CFG_DB;' . $event->getPollerId()); } catch (\Exception $e) { $event->setOutput($e->getMessage()); } }
/** * Execute action * * @param \CentreonConfiguration\Events\UpdateDatabase $event * @throws Exception */ public static function execute(UpdateDatabaseEvent $event) { $command = sprintf("[%u] UPDATE_CFG_DB;", time()); try { BrokerRepository::sendCommand($command . $event->getPollerId() . "\n"); } catch (\Exception $e) { $event->setOutput($e->getMessage()); } }
/** * Execute action * * @param \CentreonConfiguration\Events\SynchronizeFiles $event * @throws Exception */ public static function execute(SynchronizeFilesEvent $event) { $endpoints = BrokerRepository::getConfigEndpoints($event->getPollerId()); foreach ($endpoints as $endpoint) { try { BrokerRepository::sendCommand($event->getPollerId(), $endpoint . ';DUMP_DIR'); } catch (\Exception $e) { $event->setOutput($e->getMessage()); } } }
public static function execute(ExternalCommand $command) { // @todo found poller where I am $dbconn = Di::getDefault()->get('db_centreon'); $query = 'SELECT config_id' . ' FROM cfg_centreonbroker' . ' WHERE poller_id = :poller_id' . ' AND config_name = "central-broker"'; $stmt = $dbconn->prepare($query); $stmt->bindParam(':poller_id', $command->getPollerId(), \PDO::PARAM_INT); $stmt->execute(); $row = $stmt->fetch(); if ($row === false) { throw new \Exception("Can't get config id"); } $brokerId = $row['config_id']; $nodeEvents = BrokerRepository::getBrokerEndpointFromBrokerId($brokerId, 'node_events'); $nodeEvent = ""; if (isset($nodeEvents[0]) && isset($nodeEvents[0]['name'])) { $nodeEvent = $nodeEvents[0]['name']; } if ($command->getType() === 'broker') { BrokerRepository::sendCommand($command->getPollerId(), $nodeEvent . ';' . $command->getCommand()); } }