diff --git a/lang/es_ES.UTF-8/LC_MESSAGES/help.po b/lang/es_ES.UTF-8/LC_MESSAGES/help.po index 7d3a9b40a7d..440429e5a48 100644 --- a/lang/es_ES.UTF-8/LC_MESSAGES/help.po +++ b/lang/es_ES.UTF-8/LC_MESSAGES/help.po @@ -160,16 +160,16 @@ msgid "Target DBMS." msgstr "Tipo de base de datos." #: centreon-web/help.php:39 -msgid "The TCP port used to communicate with rrdcached. This is a global option, go to Administration > Options > RRDTool to modify it." -msgstr "" -"Puerto de conexión para comunicarse con el proceso RRDCacheD. \n" -"Esta opción se configura globalmente en el menú \"Administración> Opciones> RRDTool\"." +#~ msgid "The TCP port used to communicate with rrdcached. This is a global option, go to Administration > Options > RRDTool to modify it." +#~ msgstr "" +#~ "Puerto de conexión para comunicarse con el proceso RRDCacheD. \n" +#~ "Esta opción se configura globalmente en el menú \"Administración> Opciones> RRDTool\"." #: centreon-web/help.php:40 -msgid "The Unix socket used to communicate with rrdcached. This is a global option, go to Administration > Options > RRDTool to modify it." -msgstr "" -"Ruta de socket Unix para comunicarse con el proceso RRDCacheD. \n" -"Esta opción se configura globalmente en el menú \"Administración> Opciones> RRDTool\"." +#~ msgid "The Unix socket used to communicate with rrdcached. This is a global option, go to Administration > Options > RRDTool to modify it." +#~ msgstr "" +#~ "Ruta de socket Unix para comunicarse con el proceso RRDCacheD. \n" +#~ "Esta opción se configura globalmente en el menú \"Administración> Opciones> RRDTool\"." #: centreon-web/help.php:41 msgid "The higher the buffer size is, the best compression. This however increase data streaming latency. Use with caution." @@ -926,20 +926,6 @@ msgstr "Estilo de fuente de las filigranas." msgid "Font size of watermarks." msgstr "Tamaño de letra de las marcas de agua." -#: centreon-web/www/include/Administration/parameters/rrdtool/help.php:50 -msgid "Enable the rrdcached for Centreon. This option is valid only with Centreon Broker" -msgstr "" -"Habilitar RRDCached para Centreon. \n" -"Esta opción solo se utiliza con Centreon Broker." - -#: centreon-web/www/include/Administration/parameters/rrdtool/help.php:52 -msgid "Port for communicating with rrdcached" -msgstr "Puerto de comunicación con RRDCached" - -#: centreon-web/www/include/Administration/parameters/rrdtool/help.php:55 -msgid "The absolute path to unix socket for communicating with rrdcached" -msgstr "La ruta del socket Unix para comunicarse con RRDCached" - #: centreon-web/www/include/options/accessLists/resourcesACL/help.php:8 msgid "Name of resource rule." msgstr "Nombre de la regla de recursos." @@ -4154,21 +4140,21 @@ msgstr "" "Este proceso normalmente lo realiza Centreon y la modificación de esta opción debe realizarse a sabiendas." #: centreon-web/www/include/configuration/configCentreonBroker/help.php:75 -msgid "" -"The Unix socket used to communicate with rrdcached.\n" -" This is a global option, go to Administration > Options > RRDTool to modify it." -msgstr "" -"Ruta de socket Unix para comunicarse con el proceso RRDCacheD. \n" -"Esta opción se configura globalmente en el menú \"Administración> Opciones> RRDTool\"." +#~ msgid "" +#~ "The Unix socket used to communicate with rrdcached.\n" +#~ " This is a global option, go to Administration > Options > RRDTool to modify it." +#~ msgstr "" +#~ "Ruta de socket Unix para comunicarse con el proceso RRDCacheD. \n" +#~ "Esta opción se configura globalmente en el menú \"Administración> Opciones> RRDTool\"." #: centreon-web/www/include/configuration/configCentreonBroker/help.php:79 -msgid "" -"The TCP port used to communicate with rrdcached.\n" -" This is a global option, go to Administration > Options > RRDTool to modify it." -msgstr "" -"Puerto de conexión para comunicarse con el proceso RRDCacheD.\n" -" \n" -"Esta opción se configura globalmente en el menú \"Administración> Opciones> RRDTool\"." +#~ msgid "" +#~ "The TCP port used to communicate with rrdcached.\n" +#~ " This is a global option, go to Administration > Options > RRDTool to modify it." +#~ msgstr "" +#~ "Puerto de conexión para comunicarse con el proceso RRDCacheD.\n" +#~ " \n" +#~ "Esta opción se configura globalmente en el menú \"Administración> Opciones> RRDTool\"." #: centreon-web/www/include/configuration/configCentreonBroker/help.php:90 msgid "" diff --git a/lang/fr_FR.UTF-8/LC_MESSAGES/help.po b/lang/fr_FR.UTF-8/LC_MESSAGES/help.po index 29e15bd8a4e..61e9c4c9a68 100644 --- a/lang/fr_FR.UTF-8/LC_MESSAGES/help.po +++ b/lang/fr_FR.UTF-8/LC_MESSAGES/help.po @@ -234,23 +234,6 @@ msgstr "Protocole de sérialisation des données" msgid "Target DBMS." msgstr "Type de base de données." -#: centreon-web/help.php:39 -msgid "" -"The TCP port used to communicate with rrdcached. This is a global option, go " -"to Administration > Options > RRDTool to modify it." -msgstr "" -"Port de connexion pour communiquer avec le processus RRDCacheD. Cette option " -"est définie globalement dans le menu \"Administration > Options > RRDTool\"." - -#: centreon-web/help.php:40 -msgid "" -"The Unix socket used to communicate with rrdcached. This is a global option, " -"go to Administration > Options > RRDTool to modify it." -msgstr "" -"Chemin d'accès au socket Unix pour communiquer avec le processus RRDCacheD. " -"Cette option est définie globalement dans le menu \"Administration > Options > " -"RRDTool\"." - #: centreon-web/help.php:41 msgid "" "The higher the buffer size is, the best compression. This however increase " @@ -1227,22 +1210,6 @@ msgstr "Style de la police des filigranes." msgid "Font size of watermarks." msgstr "Taille de la police des filigranes." -#: centreon-web/www/include/Administration/parameters/rrdtool/help.php:50 -msgid "" -"Enable the rrdcached for Centreon. This option is valid only with Centreon " -"Broker" -msgstr "" -"Activer RRDCached pour Centreon. Cette option est utilisée uniquement avec " -"Centreon Broker." - -#: centreon-web/www/include/Administration/parameters/rrdtool/help.php:52 -msgid "Port for communicating with rrdcached" -msgstr "Port de communication avec RRDCached " - -#: centreon-web/www/include/Administration/parameters/rrdtool/help.php:55 -msgid "The absolute path to unix socket for communicating with rrdcached" -msgstr "Le chemin d'accès au socket Unix pour communiquer avec RRDCached " - #: centreon-web/www/include/options/accessLists/resourcesACL/help.php:8 msgid "Name of resource rule." msgstr "Nom de la règle des ressources." @@ -6305,23 +6272,15 @@ msgstr "" #: centreon-web/www/include/configuration/configCentreonBroker/help.php:75 msgid "" -"The Unix socket used to communicate with rrdcached.\n" -" This is a global option, go to Administration > Options > RRDTool to modify " -"it." +"Enable rrdcached option for Centreon, please see Centreon documentation to configure it." msgstr "" -"Chemin d'accès au socket Unix pour communiquer avec le processus RRDCacheD. " -"Cette option est définie globalement dans le menu \"Administration > Options > " -"RRDTool\"." +"Activer l'option rrdcached pour Centreon, veuillez consulter la documentation de Centreon pour le configurer." #: centreon-web/www/include/configuration/configCentreonBroker/help.php:79 msgid "" -"The TCP port used to communicate with rrdcached.\n" -" This is a global option, go to Administration > Options > RRDTool to modify " -"it." +"The absolute path to unix socket or TCP port for communicating with rrdcached daemon." msgstr "" -"Port de connexion pour communiquer avec le processus RRDCacheD.\n" -" Cette option est définie globalement dans le menu \"Administration > Options " -"> RRDTool\"." +"Le chemin absolu vers la socket Unix ou le port TCP pour communiquer avec le démon rrdcached." #: centreon-web/www/include/configuration/configCentreonBroker/help.php:90 msgid "" diff --git a/lang/pt_BR.UTF-8/LC_MESSAGES/help.po b/lang/pt_BR.UTF-8/LC_MESSAGES/help.po index 46c7e778dfb..dd331b4130e 100644 --- a/lang/pt_BR.UTF-8/LC_MESSAGES/help.po +++ b/lang/pt_BR.UTF-8/LC_MESSAGES/help.po @@ -710,14 +710,6 @@ msgstr "" "Ative o RRDCached para o Centreon. \n" "Essa opção é usada apenas com o Centreon Broker." -#: centreon-web/www/include/Administration/parameters/rrdtool/help.php:52 -msgid "Port for communicating with rrdcached" -msgstr "Porta de comunicação com RRDCached" - -#: centreon-web/www/include/Administration/parameters/rrdtool/help.php:55 -msgid "The absolute path to unix socket for communicating with rrdcached" -msgstr "O caminho do soquete Unix para se comunicar com o RRDCached" - #: centreon-web/www/include/Administration/parameters/knowledgeBase/help.php:9 msgid "Knowledge wiki url. Exemple: http://wiki/mywiki" msgstr "" @@ -1714,12 +1706,12 @@ msgstr "" "Permite que você mantenha dados até que uma conexão de entrada os recupere." #: centreon-web/www/include/configuration/configCentreonBroker/help.php:75 -msgid "" -"The Unix socket used to communicate with rrdcached.\n" -" This is a global option, go to Administration > Options > RRDTool to modify it." -msgstr "" -"Caminho do soquete Unix para se comunicar com o processo RRDCacheD. \n" -"Esta opção é definida globalmente no menu \"Administração> Opções> RRDTool\"." +#~ msgid "" +#~ "The Unix socket used to communicate with rrdcached.\n" +#~ " This is a global option, go to Administration > Options > RRDTool to modify it." +#~ msgstr "" +#~ "Caminho do soquete Unix para se comunicar com o processo RRDCacheD. \n" +#~ "Esta opção é definida globalmente no menu \"Administração> Opções> RRDTool\"." #: centreon-web/www/include/configuration/configCentreonBroker/help.php:77 msgid "Path to the file." @@ -1732,13 +1724,13 @@ msgstr "" " para conectar (se um endereço remoto tiver sido inserido)." #: centreon-web/www/include/configuration/configCentreonBroker/help.php:79 -msgid "" -"The TCP port used to communicate with rrdcached.\n" -" This is a global option, go to Administration > Options > RRDTool to modify it." -msgstr "" -"Porta de conexão para se comunicar com o processo RRDCacheD.\n" -" \n" -"Esta opção é definida globalmente no menu \"Administração> Opções> RRDTool\"." +#~ msgid "" +#~ "The TCP port used to communicate with rrdcached.\n" +#~ " This is a global option, go to Administration > Options > RRDTool to modify it." +#~ msgstr "" +#~ "Porta de conexão para se comunicar com o processo RRDCacheD.\n" +#~ " \n" +#~ "Esta opção é definida globalmente no menu \"Administração> Opções> RRDTool\"." #: centreon-web/www/include/configuration/configCentreonBroker/help.php:81 msgid "Private key file path when TLS encryption is used." diff --git a/lang/pt_PT.UTF-8/LC_MESSAGES/help.po b/lang/pt_PT.UTF-8/LC_MESSAGES/help.po index e60ffe9ce81..3c538b6165f 100644 --- a/lang/pt_PT.UTF-8/LC_MESSAGES/help.po +++ b/lang/pt_PT.UTF-8/LC_MESSAGES/help.po @@ -163,16 +163,16 @@ msgid "Target DBMS." msgstr "Tipo de base de dados." #: centreon-web/help.php:39 -msgid "The TCP port used to communicate with rrdcached. This is a global option, go to Administration > Options > RRDTool to modify it." -msgstr "" -"Porta de conexão para se comunicar com o processo RRDCacheD. \n" -"Esta opção é definida globalmente no menu \"Administração> Opções> RRDTool\"." +#~ msgid "The TCP port used to communicate with rrdcached. This is a global option, go to Administration > Options > RRDTool to modify it." +#~ msgstr "" +#~ "Porta de conexão para se comunicar com o processo RRDCacheD. \n" +#~ "Esta opção é definida globalmente no menu \"Administração> Opções> RRDTool\"." #: centreon-web/help.php:40 -msgid "The Unix socket used to communicate with rrdcached. This is a global option, go to Administration > Options > RRDTool to modify it." -msgstr "" -"Caminho do soquete Unix para se comunicar com o processo RRDCacheD. \n" -"Esta opção é definida globalmente no menu \"Administração> Opções> RRDTool\"." +#~ msgid "The Unix socket used to communicate with rrdcached. This is a global option, go to Administration > Options > RRDTool to modify it." +#~ msgstr "" +#~ "Caminho do soquete Unix para se comunicar com o processo RRDCacheD. \n" +#~ "Esta opção é definida globalmente no menu \"Administração> Opções> RRDTool\"." #: centreon-web/help.php:41 msgid "The higher the buffer size is, the best compression. This however increase data streaming latency. Use with caution." @@ -929,20 +929,6 @@ msgstr "Estilo de fonte de marcas d'água." msgid "Font size of watermarks." msgstr "Tamanho da fonte das marcas d'água." -#: centreon-web/www/include/Administration/parameters/rrdtool/help.php:50 -msgid "Enable the rrdcached for Centreon. This option is valid only with Centreon Broker" -msgstr "" -"Ative o RRDCached para o Centreon. \n" -"Essa opção é usada apenas com o Centreon Broker." - -#: centreon-web/www/include/Administration/parameters/rrdtool/help.php:52 -msgid "Port for communicating with rrdcached" -msgstr "Porta de comunicação com RRDCached" - -#: centreon-web/www/include/Administration/parameters/rrdtool/help.php:55 -msgid "The absolute path to unix socket for communicating with rrdcached" -msgstr "O caminho do soquete Unix para se comunicar com o RRDCached" - #: centreon-web/www/include/options/accessLists/resourcesACL/help.php:8 msgid "Name of resource rule." msgstr "Nome da regra de recurso." @@ -4151,21 +4137,21 @@ msgstr "" "Este processo é normalmente feito pelo Centreon e a modificação desta opção deve ser feita conscientemente." #: centreon-web/www/include/configuration/configCentreonBroker/help.php:75 -msgid "" -"The Unix socket used to communicate with rrdcached.\n" -" This is a global option, go to Administration > Options > RRDTool to modify it." -msgstr "" -"Caminho do soquete Unix para se comunicar com o processo RRDCacheD. \n" -"Esta opção é definida globalmente no menu \"Administração> Opções> RRDTool\"." +#~ msgid "" +#~ "The Unix socket used to communicate with rrdcached.\n" +#~ " This is a global option, go to Administration > Options > RRDTool to modify it." +#~ msgstr "" +#~ "Caminho do soquete Unix para se comunicar com o processo RRDCacheD. \n" +#~ "Esta opção é definida globalmente no menu \"Administração> Opções> RRDTool\"." #: centreon-web/www/include/configuration/configCentreonBroker/help.php:79 -msgid "" -"The TCP port used to communicate with rrdcached.\n" -" This is a global option, go to Administration > Options > RRDTool to modify it." -msgstr "" -"Porta de conexão para se comunicar com o processo RRDCacheD.\n" -" \n" -"Esta opção é definida globalmente no menu \"Administração> Opções> RRDTool\"." +#~ msgid "" +#~ "The TCP port used to communicate with rrdcached.\n" +#~ " This is a global option, go to Administration > Options > RRDTool to modify it." +#~ msgstr "" +#~ "Porta de conexão para se comunicar com o processo RRDCacheD.\n" +#~ " \n" +#~ "Esta opção é definida globalmente no menu \"Administração> Opções> RRDTool\"." #: centreon-web/www/include/configuration/configCentreonBroker/help.php:90 msgid "" diff --git a/tests/rest_api/rest_api.postman_collection.json b/tests/rest_api/rest_api.postman_collection.json index f9f4c512c23..6a467b3b7d6 100644 --- a/tests/rest_api/rest_api.postman_collection.json +++ b/tests/rest_api/rest_api.postman_collection.json @@ -1,6 +1,6 @@ { "info": { - "_postman_id": "550c1759-3532-4931-9f0e-3ee750bb27f6", + "_postman_id": "977609fc-e339-4f33-bddc-7eec145a0f55", "name": "Centreon Web Rest API", "schema": "https://schema.getpostman.com/json/collection/v2.1.0/collection.json" }, @@ -10150,114 +10150,6 @@ }, "response": [] }, - { - "name": "Setoutput port", - "event": [ - { - "listen": "test", - "script": { - "type": "text/javascript", - "exec": [ - "tests[\"Status code is 200\"] = responseCode.code === 200;" - ] - } - } - ], - "request": { - "method": "POST", - "header": [ - { - "key": "Content-Type", - "value": "application/json" - }, - { - "key": "centreon-auth-token", - "value": "{{token}}" - } - ], - "body": { - "mode": "raw", - "raw": "{\n \"action\": \"setoutput\",\n \"object\": \"centbrokercfg\",\n \"values\": \"{{broker_name}};{{output_rrd_id}};port;{{output_port}}\"\n}" - }, - "url": { - "raw": "http://{{url}}/centreon/api/index.php?action=action&object=centreon_clapi", - "protocol": "http", - "host": [ - "{{url}}" - ], - "path": [ - "centreon", - "api", - "index.php" - ], - "query": [ - { - "key": "action", - "value": "action" - }, - { - "key": "object", - "value": "centreon_clapi" - } - ] - } - }, - "response": [] - }, - { - "name": "Setoutput path", - "event": [ - { - "listen": "test", - "script": { - "type": "text/javascript", - "exec": [ - "tests[\"Status code is 200\"] = responseCode.code === 200;" - ] - } - } - ], - "request": { - "method": "POST", - "header": [ - { - "key": "Content-Type", - "value": "application/json" - }, - { - "key": "centreon-auth-token", - "value": "{{token}}" - } - ], - "body": { - "mode": "raw", - "raw": "{\n \"action\": \"setoutput\",\n \"object\": \"centbrokercfg\",\n \"values\": \"{{broker_name}};{{output_rrd_id}};path;{{output_path}}\"\n}" - }, - "url": { - "raw": "http://{{url}}/centreon/api/index.php?action=action&object=centreon_clapi", - "protocol": "http", - "host": [ - "{{url}}" - ], - "path": [ - "centreon", - "api", - "index.php" - ], - "query": [ - { - "key": "action", - "value": "action" - }, - { - "key": "object", - "value": "centreon_clapi" - } - ] - } - }, - "response": [] - }, { "name": "Setoutput metrics_path", "event": [ diff --git a/www/class/centreonConfigCentreonBroker.php b/www/class/centreonConfigCentreonBroker.php index af83cab712a..4516b7325b2 100644 --- a/www/class/centreonConfigCentreonBroker.php +++ b/www/class/centreonConfigCentreonBroker.php @@ -213,15 +213,13 @@ public function getTagName($tagId) if (!is_null($this->tagsCache) && isset($this->tagsCache[$tagId])) { return $this->tagsCache[$tagId]; } - $query = "SELECT tagname - FROM cb_tag - WHERE cb_tag_id = %d"; + $query = "SELECT tagname FROM cb_tag WHERE cb_tag_id = %d"; try { $res = $this->db->query(sprintf($query, $tagId)); } catch (\PDOException $e) { return null; } - $row = $res->fetchRow(); + $row = $res->fetch(); if (is_null($row)) { return null; } @@ -239,15 +237,13 @@ public function getTypeShortname($typeId) if (!is_null($this->typesCache) && isset($this->typesCache[$typeId])) { return $this->typesCache[$typeId]; } - $query = "SELECT type_shortname - FROM cb_type - WHERE cb_type_id = %d"; + $query = "SELECT type_shortname FROM cb_type WHERE cb_type_id = %d"; try { $res = $this->db->query(sprintf($query, $typeId)); } catch (\PDOException $e) { return null; } - $row = $res->fetchRow(); + $row = $res->fetch(); if (is_null($row)) { return null; } @@ -266,15 +262,13 @@ public function getTypeName($typeId) if (!is_null($this->typesNameCache) && isset($this->typesNameCache[$typeId])) { return $this->typesNameCache[$typeId]; } - $query = 'SELECT type_name - FROM cb_type - WHERE cb_type_id = %d'; + $query = 'SELECT type_name FROM cb_type WHERE cb_type_id = %d'; try { $res = $this->db->query(sprintf($query, $typeId)); } catch (\PDOException $e) { return null; } - $row = $res->fetchRow(); + $row = $res->fetch(); if (is_null($row)) { return null; } @@ -305,7 +299,7 @@ public function getListConfigBlock($tagId) return array(); } $this->blockCache[$tagId] = array(); - while ($row = $res->fetchRow()) { + while ($row = $res->fetch()) { $name = $row['name'] . ' - ' . $row['type_name']; $id = $tagId . '_' . $row['cb_type_id']; $this->blockCache[$tagId][] = array('id' => $id, 'name' => $name, 'unique' => $row['cb_type_uniq']); @@ -321,7 +315,9 @@ public function getListConfigBlock($tagId) * @param int $blockId The block id ('tag_id'_'type_id') * @param int $page The centreon page id * @param int $formId The form post - * @return HTML_QuickForm + * @param int $config_id + * @return HTML_QuickFormCustom + * @throws HTML_QuickForm_Error */ public function quickFormById($blockId, $page, $formId = 1, $config_id = 0) { @@ -391,6 +387,14 @@ public function quickFormById($blockId, $page, $formId = 1, $config_id = 0) )); } + if ($field['hook_name'] != '') { + $elementAttr = array_merge($elementAttr, array( + 'onchange' => $field['hook_name'] . '.onChange(' . $field['hook_arguments'] . ')(this)', + 'data-ontab-fn' => $field['hook_name'], + 'data-ontab-arg' => $field['hook_arguments'] + )); + } + foreach ($this->getListValues($field['id']) as $key => $value) { $tmpRadio[] = $qf->createElement( 'radio', @@ -420,9 +424,7 @@ public function quickFormById($blockId, $page, $formId = 1, $config_id = 0) break; } - /* - * If get information for read-only in database - */ + // If get information for read-only in database if (!is_null($field['value']) && $field['value'] !== false) { $elementType = null; $roValue = $this->getInfoDb($field['value']); @@ -435,9 +437,7 @@ public function quickFormById($blockId, $page, $formId = 1, $config_id = 0) $qf->freeze($elementName); } - /* - * Add required informations - */ + // Add required informations if ($field['required'] && is_null($field['value']) && $elementType != 'select') { $elementAttr = array_merge($elementAttr, array( 'id' => $elementName, @@ -474,9 +474,7 @@ public function quickFormById($blockId, $page, $formId = 1, $config_id = 0) } } - /* - * Add elements - */ + // Add elements if (!is_null($elementType)) { if ($elementType == 'advmultiselect') { $el = $qf->addElement( @@ -495,9 +493,7 @@ public function quickFormById($blockId, $page, $formId = 1, $config_id = 0) } } - /* - * Defaults values - */ + // Defaults values if (!is_null($field['value']) && $field['value'] !== false) { if ($field['fieldtype'] != 'radio') { $qf->setDefaults(array($elementName => $field['value'])); @@ -544,9 +540,7 @@ public function getBlockInfos($typeId) return $this->blockInfoCache[$typeId]; } - /* - * Get the list of fields for a block - */ + // Get the list of fields for a block $fields = array(); $query = "SELECT f.cb_field_id, f.fieldname, f.displayname, f.fieldtype, f.description, f.external, tfr.is_required, tfr.order_display, tfr.jshook_name, tfr.jshook_arguments, f.cb_fieldgroup_id @@ -564,7 +558,7 @@ public function getBlockInfos($typeId) } catch (\PDOException $e) { return false; } - while ($row = $res->fetchRow()) { + while ($row = $res->fetch()) { $field = array(); $field['id'] = $row['cb_field_id']; $field['fieldname'] = $row['fieldname']; @@ -601,7 +595,7 @@ public function getTypeId($typeName) $res = $this->db->query($queryGetType); if ($res) { - while ($row = $res->fetchRow()) { + while ($row = $res->fetch()) { $typeId = $row['cb_type_id']; } } @@ -631,9 +625,7 @@ public function insertConfig($values) $this->db->escape($values['command_file']['command_file']) : ''; - /* - * Insert the Centreon Broker configuration - */ + // Insert the Centreon Broker configuration $query = "INSERT INTO cfg_centreonbroker " . "(config_name, config_filename, ns_nagios_server, config_activate, daemon, config_write_timestamp, " . "config_write_thread_id, stats_activate, cache_directory, " @@ -671,7 +663,7 @@ public function insertConfig($values) } catch (\PDOException $e) { return false; } - $row = $res->fetchRow(); + $row = $res->fetch(); $id = $row['config_id']; $this->updateCentreonBrokerInfos($id, $values); } @@ -810,10 +802,10 @@ public function updateCentreonBrokerInfos($id, $values) $info = explode('__', $fieldname, 3); $grp_name = $info[0]; $grp_id = $info[1]; - $query = "INSERT INTO cfg_centreonbroker_info - (config_id, config_key, config_value, config_group, config_group_id, grp_level, - subgrp_id, parent_grp_id) VALUES (" . $id . ", '" . $grp_name . "', '', '" - . $group . "', " . $gid . ", " . $lvl . ", " . $grp_id . ", " . $parent_id . ")"; + $query = 'INSERT INTO cfg_centreonbroker_info (config_id, config_key, config_value,' + . 'config_group, config_group_id, grp_level, subgrp_id, parent_grp_id) VALUES (' + . $id . ', "' . $grp_name . '", "", "' . $group . '", ' . $gid . ', ' . $lvl + . ', ' . $grp_id . ', ' . $parent_id . ')'; $this->db->query($query); $lvl++; $parent_id = $grp_id; @@ -821,10 +813,10 @@ public function updateCentreonBrokerInfos($id, $values) } $grp_id = 'NULL'; foreach ($fieldvalue as $value) { - $query = "INSERT INTO cfg_centreonbroker_info (config_id, config_key, config_value, - config_group, config_group_id, grp_level, subgrp_id, parent_grp_id) - VALUES (" . $id . ", '" . $fieldname . "', '" . $value . "', '" . $group . "', " - . $gid . ", " . $lvl . ", " . $grp_id . ", " . $parent_id . ")"; + $query = 'INSERT INTO cfg_centreonbroker_info (config_id, config_key, config_value, ' + . 'config_group, config_group_id, grp_level, subgrp_id, parent_grp_id) VALUES (' + . $id . ', "' . $fieldname . '", "' . $value . '", "' . $group . '", ' + . $gid . ', ' . $lvl . ', ' . $grp_id . ', ' . $parent_id . ')'; $this->db->query($query); } } @@ -838,17 +830,17 @@ public function updateCentreonBrokerInfos($id, $values) /** * Get the list of forms for a config_id * - * @param int $config_id The id of config - * @param string $tag The tag name - * @param int $page The page topology - * @param Smarty $tpl The template Smarty + * @param $config_id int $config_id The id of config + * @param $tag string $tag The tag name + * @param $page int $page The page topology + * @param $tpl Smarty $tpl The template Smarty * @return array + * @throws HTML_QuickForm_Error */ public function getForms($config_id, $tag, $page, $tpl) { $query = "SELECT config_key, config_value, config_group_id, grp_level, parent_grp_id, fieldIndex - FROM cfg_centreonbroker_info - WHERE config_id = %d + FROM cfg_centreonbroker_info WHERE config_id = %d AND config_group = '%s' AND subgrp_id IS NULL ORDER BY config_group_id"; @@ -859,7 +851,7 @@ public function getForms($config_id, $tag, $page, $tpl) } $formsInfos = array(); $arrayMultipleValues = array(); - while ($row = $res->fetchRow()) { + while ($row = $res->fetch()) { $fieldname = $tag . '[' . $row['config_group_id'] . '][' . $this->getConfigFieldName($config_id, $tag, $row) . ']'; // Multi value for a multiselect @@ -890,10 +882,7 @@ public function getForms($config_id, $tag, $page, $tpl) foreach (array_keys($formsInfos) as $key) { $qf = $this->quickFormById($formsInfos[$key]['blockId'], $page, $key, $config_id); - /* - * Replace loaded configuration with defaults external values - */ - + //Replace loaded configuration with defaults external values list($tagId, $typeId) = explode('_', $formsInfos[$key]['blockId']); $tag = $this->getTagName($tagId); $fields = $this->getBlockInfos($typeId); @@ -941,9 +930,7 @@ public function getForms($config_id, $tag, $page, $tpl) */ public function getCorrelationFile() { - $query = "SELECT - config_id, config_group_id - FROM cfg_centreonbroker_info + $query = "SELECT config_id, config_group_id FROM cfg_centreonbroker_info WHERE config_key = 'type' AND config_value = 'correlation'"; $error = false; try { @@ -958,8 +945,8 @@ public function getCorrelationFile() $row = $res->fetchRow(); $configId = $row['config_id']; $correlationGroupId = $row['config_group_id']; - $query = 'SELECT config_value FROM cfg_centreonbroker_info - WHERE config_key = "file" AND config_id = ' . $configId . ' AND config_group_id = ' . $correlationGroupId; + $query = 'SELECT config_value FROM cfg_centreonbroker_info WHERE config_key = "file" AND config_id = ' + . $configId . ' AND config_group_id = ' . $correlationGroupId; $error = false; try { $res = $this->db->query($query); @@ -1003,12 +990,12 @@ public function getFieldtypes($typeId) if (isset($this->fieldtypeCache[$typeId])) { return $this->fieldtypeCache[$typeId]; } - $fieldtypes = array(); + $fieldTypes = array(); $block = $this->getBlockInfos($typeId); foreach ($block as $fieldInfos) { - $fieldtypes[$fieldInfos['fieldname']] = $fieldInfos['fieldtype']; + $fieldTypes[$fieldInfos['fieldname']] = $fieldInfos['fieldtype']; } - $this->fieldtypeCache[$typeId] = $fieldtypes; + $this->fieldtypeCache[$typeId] = $fieldTypes; return $this->fieldtypeCache[$typeId]; } @@ -1068,8 +1055,7 @@ private function getListValues($fieldId) if (isset($this->listValues[$fieldId])) { return $this->listValues[$fieldId]; } - $query = "SELECT v.value_name, v.value_value - FROM cb_list_values v, cb_list l + $query = "SELECT v.value_name, v.value_value FROM cb_list_values v, cb_list l WHERE l.cb_list_id = v.cb_list_id AND l.cb_field_id = %d"; try { $res = $this->db->query(sprintf($query, $fieldId)); @@ -1095,8 +1081,7 @@ public function getDefaults($fieldId) if (isset($this->defaults[$fieldId])) { return $this->defaults[$fieldId]; } - $query = "SELECT cbl.default_value, cblv.value_value " - . "FROM cb_list_values cblv " + $query = "SELECT cbl.default_value, cblv.value_value FROM cb_list_values cblv " . "LEFT JOIN cb_list cbl ON cblv.cb_list_id = cbl.cb_list_id " . "INNER JOIN cb_field cbf ON cbf.cb_field_id = cbl.cb_field_id " . "WHERE cbl.cb_field_id = %d " @@ -1106,7 +1091,7 @@ public function getDefaults($fieldId) } catch (\PDOException $e) { return null; } - $row = $res->fetchRow(); + $row = $res->fetch(); $this->defaults[$fieldId] = null; if (!is_null($row)) { @@ -1133,14 +1118,14 @@ public function getDefaults($fieldId) private function getExternalDefaultValue($fieldId) { $externalValue = null; - $query = "SELECT external FROM cb_field WHERE cb_field_id = $fieldId"; + $query = 'SELECT `external` FROM cb_field WHERE cb_field_id = ' . $fieldId; $res = $this->db->query($query); if (!$res) { $externalValue = null; } - $row = $res->fetchRow(); + $row = $res->fetch(); if (!is_null($row)) { $finalInfo = $this->getInfoDb($row['external']); if (!is_array($finalInfo)) { @@ -1155,7 +1140,8 @@ private function getExternalDefaultValue($fieldId) * Get static information from database * * @param string $string The string for get information - * @return mixed Information + * @return array|bool|mixed|string + * @throws Exception */ public function getInfoDb($string) { @@ -1167,14 +1153,10 @@ public function getInfoDb($string) $monitoringDb = new \CentreonDB('centstorage'); } - /* - * Default values - */ + // Default values $s_db = "centreon"; $s_rpn = null; - /* - * Parse string - */ + // Parse string $configs = explode(':', $string); foreach ($configs as $config) { if (strpos($config, '=') == false) { @@ -1205,9 +1187,7 @@ public function getInfoDb($string) break; } } - /* - * Construct query - */ + // Construct query if (!isset($s_table) || !isset($s_column)) { return false; } @@ -1216,9 +1196,7 @@ public function getInfoDb($string) $query .= " WHERE `" . $s_column_key . "` = '" . $s_key . "'"; } - /* - * Execute the query - */ + // Execute the query try { switch ($s_db) { case 'centreon': @@ -1423,8 +1401,8 @@ private function getConfigFieldName($configId, $configGroup, $info) } /** - * - * @return array + * @param $sName + * @return int */ public function isExist($sName) { @@ -1436,11 +1414,10 @@ public function isExist($sName) $query = "SELECT COUNT(config_id) as nb FROm cfg_centreonbroker WHERE config_name = '" . $this->db->escape($sName) . "'"; $res = $this->db->query($query); - $row = $res->fetchRow(); + $row = $res->fetch(); if ($row['nb'] > 0) { $bExist = 1; } - return $bExist; } } diff --git a/www/class/config-generate/broker.class.php b/www/class/config-generate/broker.class.php index 5b12ac8a56d..624561447e0 100644 --- a/www/class/config-generate/broker.class.php +++ b/www/class/config-generate/broker.class.php @@ -89,9 +89,9 @@ private function getExternalValues() global $pearDB; if (!is_null($this->cacheExternalValue)) { - return ; + return; } - + $this->cacheExternalValue = array(); $stmt = $this->backend_instance->db->prepare("SELECT CONCAT(cf.fieldname, '_', cttr.cb_tag_id, '_', ctfr.cb_type_id) as name, external FROM cb_field cf, cb_type_field_relation ctfr, cb_tag_type_relation cttr @@ -108,7 +108,7 @@ private function getExternalValues() private function generate($poller_id, $localhost) { $this->getExternalValues(); - + if (is_null($this->stmt_broker)) { $this->stmt_broker = $this->backend_instance->db->prepare("SELECT $this->attributes_select @@ -144,7 +144,7 @@ private function generate($poller_id, $localhost) $stats_activate = $row['stats_activate']; $correlation_activate = $row['correlation_activate']; - # Base parameters + // Base parameters $object['broker_id'] = $row['config_id']; $object['broker_name'] = $row['config_name']; $object['poller_id'] = $this->engine['id']; @@ -171,7 +171,7 @@ private function generate($poller_id, $localhost) $this->stmt_broker_parameters->execute(); $resultParameters = $this->stmt_broker_parameters->fetchAll(PDO::FETCH_GROUP | PDO::FETCH_ASSOC); - # Flow parameters + // Flow parameters foreach ($resultParameters as $key => $value) { // We search the BlockId $blockId = 0; @@ -184,6 +184,7 @@ private function generate($poller_id, $localhost) } } + $rrdCacheOption = 'disable'; foreach ($value as $subvalue) { if (!isset($subvalue['fieldIndex']) || $subvalue['fieldIndex'] == "" || @@ -202,9 +203,22 @@ private function generate($poller_id, $localhost) $object[$subvalue['config_group_id']][$key]['filters'][][$subvalue['config_key']] = $subvalue['config_value']; } else { + if ($subvalue['config_key'] === 'rrd_cached_option') { + $rrdCacheOption = $subvalue['config_value']; + continue; + } + + if ($subvalue['config_key'] === 'rrd_cached') { + if ($rrdCacheOption === 'tcp') { + $object[$subvalue['config_group_id']][$key]['port'] = $subvalue['config_value']; + } elseif ($rrdCacheOption === 'unix') { + $object[$subvalue['config_group_id']][$key]['path'] = $subvalue['config_value']; + } + continue; + } + $object[$subvalue['config_group_id']][$key][$subvalue['config_key']] = $subvalue['config_value']; - // We override with external values if (isset($this->cacheExternalValue[$subvalue['config_key'] . '_' . $blockId])) { $object[$subvalue['config_group_id']][$key][$subvalue['config_key']] = @@ -223,7 +237,7 @@ private function generate($poller_id, $localhost) } $flow_count++; } - + // Check if we need to add values from external foreach ($this->cacheExternalValue as $key2 => $value2) { if (preg_match('/^(.+)_' . $blockId . '$/', $key2, $matches)) { @@ -235,7 +249,7 @@ private function generate($poller_id, $localhost) } } - # Stats parameters + // Stats parameters if ($stats_activate == '1') { $object[$flow_count]['stats'] = array( 'type' => 'stats', @@ -244,7 +258,7 @@ private function generate($poller_id, $localhost) ); } - # Generate file + // Generate file $this->generateFile($object, true, 'centreonBroker'); $this->writeFile($this->backend_instance->getPath()); } @@ -289,7 +303,7 @@ public function generateFromPoller($poller) { $this->generate($poller['id'], $poller['localhost']); } - + private function getInfoDb($string) { /* @@ -352,10 +366,10 @@ private function getInfoDb($string) $db = $this->backend_instance->db_cs; break; } - + $stmt = $db->prepare($query); $stmt->execute(); - + $infos = array(); while (($row = $stmt->fetch(PDO::FETCH_ASSOC))) { $val = $row[$s_column]; @@ -371,7 +385,7 @@ private function getInfoDb($string) } return $infos; } - + private function rpnCalc($rpn, $val) { if (!is_numeric($val)) { @@ -387,7 +401,7 @@ private function rpnCalc($rpn, $val) return $val; } } - + private function rpnOperation($result, $item) { if (in_array($item, array('+', '-', '*', '/'))) { diff --git a/www/include/Administration/parameters/rrdtool/form.ihtml b/www/include/Administration/parameters/rrdtool/form.ihtml index 2265336a9dd..76c0807c700 100644 --- a/www/include/Administration/parameters/rrdtool/form.ihtml +++ b/www/include/Administration/parameters/rrdtool/form.ihtml @@ -22,27 +22,6 @@ {$form.rrdtool_version.html} - - - -

{$form.header.rrdcached_title}

- - - - {$form.rrdcached_enable.label} - - {$form.rrdcached_enable.html} - - - {$form.rrdcached_port.label} - - {$form.rrdcached_port.html} - - - {$form.rrdcached_unix_path.label} - - {$form.rrdcached_unix_path.html} - {if !$valid}
diff --git a/www/include/Administration/parameters/rrdtool/form.php b/www/include/Administration/parameters/rrdtool/form.php index f8b7b952874..d620347647c 100644 --- a/www/include/Administration/parameters/rrdtool/form.php +++ b/www/include/Administration/parameters/rrdtool/form.php @@ -65,17 +65,6 @@ $form->addElement('text', 'rrdtool_path_bin', _("Directory + RRDTOOL Binary"), $attrsText); $form->addElement('text', 'rrdtool_version', _("RRDTool Version"), $attrsText2); -/* - * Rrdcached - */ -$attrEnable = array('onclick' => 'toggleRrdcached(this)'); -$form->addElement('header', 'rrdcached_title', _("Rrdcached configuration : work only with Centreon Broker")); -$rrdcachedEnable[] = $form->createElement('radio', 'rrdcached_enable', null, _("Yes"), '1', $attrEnable); -$rrdcachedEnable[] = $form->createElement('radio', 'rrdcached_enable', null, _("No"), '0', $attrEnable); -$form->addGroup($rrdcachedEnable, 'rrdcached_enable', _("Enable RRDCached"), ' '); -$form->addElement('text', 'rrdcached_port', _('TCP Port'), $attrsText2); -$form->addElement('text', 'rrdcached_unix_path', _('UNIX Socket path'), $attrsText); - $form->addElement('hidden', 'gopt_id'); $redirect = $form->addElement('hidden', 'o'); $redirect->setValue($o); diff --git a/www/include/common/javascript/centreon/brokerConfig.js b/www/include/common/javascript/centreon/brokerConfig.js index 21c14461ede..b0cc4c77a3e 100644 --- a/www/include/common/javascript/centreon/brokerConfig.js +++ b/www/include/common/javascript/centreon/brokerConfig.js @@ -62,7 +62,6 @@ function clonifyTableFields(attributeName,displayName){ //table1.prepend(control); firstPosition.after(newdiv); } - } // Finaly, we make each group of fields clonable (if not alreadyProcessed) @@ -141,9 +140,41 @@ jQuery(function () { }); }); -/* Hooks for some fields */ +// Hooks for some fields +var rrdArguments = { + // Hook on load tab + onLoad: function (element, argument) { + argument = window.JSON.parse(argument); + return function () { + var entry = element.name.match('(input|output)(\\[\\d\\])\\[(\\w*)\\]'); + var option = entry.input; + var target = entry[1] + entry[2] + '[' + argument.target + ']'; + + if (document.querySelector('input[name="' + option + '"]:checked').value === 'disable') { + document.getElementsByName(target)[1].disabled = true; + } + } + }, + // Hook on change the target + onChange: function (argument) { + return function (self) { + var entry = self.name.match('(input|output)(\\[\\d\\])\\[(\\w*)\\]'); + var option = entry.input; + var target = entry[1] + entry[2] + '[' + argument.target + ']'; + + if (document.querySelector('input[name="' + option + '"]:checked').value === 'disable') { + document.getElementsByName(target)[1].value = ''; + document.getElementsByName(target)[1].disabled = true; + } else { + document.getElementsByName(target)[1].disabled = false; + } + } + } +} + +// Hooks for some fields var luaArguments = { - /* Hook on load tab */ + // Hook on load tab onLoad: function (element, argument) { argument = window.JSON.parse(argument); return function () { @@ -155,7 +186,7 @@ var luaArguments = { luaArguments.changeInput(type, target) } }, - /* Hook on change the target */ + // Hook on change the target onChange: function (argument) { return function (self) { var entry = self.name.match('(input|output)(\\[\\d\\])\\[(\\w*)\\]'); @@ -166,9 +197,9 @@ var luaArguments = { luaArguments.changeInput(type,target) } }, - /* Internal function for apply the input change */ + // Internal function for apply the input change changeInput: function (type, name) { - /* Get all attributes */ + // Get all attributes var attrs = {}; name = '[name="' + name + '"]:input'; jQuery.each(jQuery(name)[0].attributes, function (idx, attr) { @@ -180,7 +211,7 @@ var luaArguments = { var $elParent = jQuery(name).parent(); var value = jQuery(name).val(); jQuery(name).remove(); - /* Find the good input for the type by default text => string */ + // Find the good input for the type by default text => string if (type === 'number') { var newEl = jQuery('') .attr(attrs) diff --git a/www/install/insertBaseConf.sql b/www/install/insertBaseConf.sql index faa82abcf90..5407e277c69 100644 --- a/www/install/insertBaseConf.sql +++ b/www/install/insertBaseConf.sql @@ -544,8 +544,8 @@ INSERT INTO `cb_field` (`cb_field_id`, `fieldname`, `displayname`, `description` (33, 'fifo', 'File for Centreon Broker statistics', 'File where Centreon Broker statistics will be stored', 'text', NULL), (34, 'queries_per_transaction', 'Maximum queries per transaction', 'The maximum queries per transaction before commit.', 'int', NULL), (35, 'read_timeout', 'Transaction commit timeout', 'The transaction timeout before running commit.', 'int', NULL), -(36, 'path', 'Unix socket', 'The Unix socket used to communicate with rrdcached. This is a global option, go to Administration > Options > RRDTool to modify it.', 'text', 'T=options:C=value:CK=key:K=rrdcached_unix_path'), -(37, 'port', 'TCP port', 'The TCP port used to communicate with rrdcached. This is a global option, go to Administration > Options > RRDTool to modify it.', 'int', 'T=options:C=value:CK=key:K=rrdcached_port'), +(36, 'rrd_cached_option', 'Enable RRDCached', 'Enable rrdcached option for Centreon, please see Centreon documentation to configure it.', 'radio', NULL), +(37, 'rrd_cached', 'RRDCacheD listening socket/port', 'The absolute path to unix socket or TCP port for communicating with rrdcached daemon.', 'text', NULL), (38, 'max_size', 'Max file size in bytes', 'The maximum size of log file.', 'int', NULL), (39, 'check_replication', 'Replication enabled', 'When enabled, the broker engine will check whether or not the replication is up to date before attempting to update data.', 'radio', NULL), (40, 'rebuild_check_interval', 'Rebuild check interval in seconds', 'The interval between check if some metrics must be rebuild. The default value is 300s', 'int', NULL), @@ -620,7 +620,8 @@ INSERT INTO `cb_list` (`cb_list_id`, `cb_field_id`, `default_value`) VALUES (10, 62, 'false'), (1, 63, 'yes'), (1, 70, 'no'), -(11, 73, 'string'); +(11, 73, 'string'), +(12, 36, 'disable'); -- -- Contenu de la table `cb_list_values` @@ -658,7 +659,10 @@ INSERT INTO `cb_list_values` (`cb_list_id`, `value_name`, `value_value`) VALUES (10, 'False', 'false'), (11, 'String', 'string'), (11, 'Number', 'number'), -(11, 'Password', 'password'); +(11, 'Password', 'password'), +(12, 'Disable', 'disable'), +(12, 'TCP Port', 'tcp'), +(12, 'UNIX Socket', 'unix'); -- -- Contenu de la table `cb_module_relation` @@ -726,8 +730,7 @@ INSERT INTO `cb_type_field_relation` (`cb_type_id`, `cb_field_id`, `is_required` (11, 11, 1, 1), (11, 12, 1, 2), (11, 41, 0, 3), -(13, 36, 0, 4), -(13, 37, 0, 3), +(13, 37, 0, 4), (13, 13, 1, 1), (13, 14, 1, 2), (14, 7, 1, 4), @@ -843,7 +846,8 @@ INSERT INTO `cb_type_field_relation` (`cb_type_id`, `cb_field_id`, `is_required` -- Contenu de la table `cb_type_field_relation` -- INSERT INTO `cb_type_field_relation` (`cb_type_id`, `cb_field_id`, `is_required`, `order_display`, `jshook_name`, `jshook_arguments`) VALUES -(33, 73, 0, 5, 'luaArguments', '{"target": "lua_parameter__value_%d"}'); +(33, 73, 0, 5, 'luaArguments', '{"target": "lua_parameter__value_%d"}'), +(13, 36, 0, 3, 'rrdArguments', '{"target": "rrd_cached"}'); -- -- Contenu de la table `widget_parameters_field_type` diff --git a/www/install/php/Update-19.10.0-beta.3.php b/www/install/php/Update-19.10.0-beta.3.php index fa33010e4e3..71c718f2d4e 100644 --- a/www/install/php/Update-19.10.0-beta.3.php +++ b/www/install/php/Update-19.10.0-beta.3.php @@ -190,3 +190,60 @@ $statement->bindValue(':user_id', $row['user_id'], \PDO::PARAM_INT); $statement->execute(); } + +$result = $pearDB->query("SELECT `value` FROM options WHERE `key` = 'rrdcached_enable' "); +$cache = $result->fetch(); + +if ($cache['value']) { + + try { + $pearDB->beginTransaction(); + + $res = $pearDB->query( + "SELECT * FROM cfg_centreonbroker_info WHERE `config_key` = 'type' AND `config_value` = 'rrd'" + ); + $result = $pearDB->query("SELECT `value` FROM options WHERE `key` = 'rrdcached_port' "); + $port = $result->fetch(); + + while ($row = $res->fetch()) { + if ($port['value']) { + $query = 'INSERT INTO cfg_centreonbroker_info (config_id, config_key, config_value, ' + . 'config_group, config_group_id ) VALUES ' + . '( ' . $row['config_id'] . ',"rrd_cached_option","tcp", "' + . $row['config_group'] . '",' . $row['config_group_id'] . ' ),' + . '( ' . $row['config_id'] . ',"rrd_cached","' . $port['value'] . '","' + . $row['config_group'] . '",' . $row['config_group_id'] . ' )'; + $pearDB->query($query); + } else { + $result = $pearDB->query("SELECT `value` FROM options WHERE `key` = 'rrdcached_unix_path' "); + $path = $result->fetch(); + + $query = 'INSERT INTO cfg_centreonbroker_info (config_id, config_key, config_value, ' + . 'config_group, config_group_id ) VALUES ' + . '( ' . $row['config_id'] . ',"rrd_cached_option","unix","' + . $row['config_group'] . '",' . $row['config_group_id'] . ' ),' + . '( ' . $row['config_id'] . ',"rrd_cached","' . $path['value'] . '","' + . $row['config_group'] . '",' . $row['config_group_id'] . ' )'; + $pearDB->query($query); + } + + $pearDB->query( + "DELETE FROM cfg_centreonbroker_info WHERE `config_id` = " . $row['config_id'] + . " AND config_group_id = " . $row['config_group_id'] + . " AND config_group = 'output' AND ( config_key = 'port' OR config_key = 'path') " + ); + } + $pearDB->query( + "DELETE FROM options WHERE `key` = 'rrdcached_enable' + OR `key` = 'rrdcached_port' OR `key` = 'rrdcached_unix_path'" + ); + $pearDB->commit(); + } catch (\PDOException $e) { + + $centreonLog->insertLog( + 2, // sql-error.log + "UPGRADE : Unable to move rrd global cache option on broker form" + ); + $pearDB->rollBack(); + } +} diff --git a/www/install/sql/centreon/Update-DB-19.10.0-beta.3.sql b/www/install/sql/centreon/Update-DB-19.10.0-beta.3.sql index e15e11ed335..2ad17807f65 100644 --- a/www/install/sql/centreon/Update-DB-19.10.0-beta.3.sql +++ b/www/install/sql/centreon/Update-DB-19.10.0-beta.3.sql @@ -6,3 +6,32 @@ ALTER TABLE nagios_server ADD COLUMN `remote_server_centcore_ssh_proxy` enum('0' -- Add severity preference on host-monitoring widget INSERT INTO `widget_parameters_field_type` (`ft_typename`, `is_connector`) VALUES ('hostSeverityMulti', 1); + +-- Update broker form +UPDATE `cb_field` SET `fieldname` = 'rrd_cached_option', `displayname` = 'Enable RRDCached', `description` = 'Enable rrdcached option for Centreon, please see Centreon documentation to configure it.', `fieldtype` = 'radio', `external` = NULL +WHERE `fieldname` = 'path' AND `displayname` = 'Unix socket'; + +UPDATE `cb_field` SET `fieldname` = 'rrd_cached', `displayname` = 'RRDCacheD listening socket/port', `description` = 'The absolute path to unix socket or TCP port for communicating with rrdcached daemon.', `fieldtype` = 'text', `external` = NULL +WHERE `fieldname` = 'port' AND `displayname` = 'TCP port'; + +INSERT INTO `cb_list` (`cb_list_id`, `cb_field_id`, `default_value`) +VALUES((SELECT coalesce(MAX(l.cb_list_id),0)+1 from cb_list l), (SELECT `cb_field_id` FROM `cb_field` WHERE `displayname` = 'Enable RRDCached'), 'disable'); + +INSERT INTO `cb_list_values` (`cb_list_id`, `value_name`, `value_value`) +VALUES +((SELECT `cb_list_id` FROM `cb_list` WHERE `cb_field_id` = + (SELECT `cb_field_id` FROM `cb_field` WHERE `displayname` = 'Enable RRDCached')), 'Disable', 'disable' +), +((SELECT `cb_list_id` FROM `cb_list` WHERE `cb_field_id` = + (SELECT `cb_field_id` FROM `cb_field` WHERE `displayname` = 'Enable RRDCached')), 'UNIX Socket', 'unix' +), +((SELECT `cb_list_id` FROM `cb_list` WHERE `cb_field_id` = + (SELECT `cb_field_id` FROM `cb_field` WHERE `displayname` = 'Enable RRDCached')), 'TCP Port ', 'tcp' +); + +UPDATE `cb_type_field_relation` SET `jshook_name` = 'rrdArguments', `jshook_arguments` = '{"target": "rrd_cached"}', `order_display` = 3 +WHERE `cb_type_id` = (SELECT `cb_type_id` FROM `cb_type` WHERE `type_shortname` = 'rrd') AND `cb_field_id` = (SELECT `cb_field_id` FROM `cb_field` WHERE `displayname` = 'Enable RRDCached'); + +UPDATE `cb_type_field_relation` SET `order_display` = 4 +WHERE `cb_type_id` = (SELECT `cb_type_id` FROM `cb_type` WHERE `type_shortname` = 'rrd') AND `cb_field_id` = (SELECT `cb_field_id` FROM `cb_field` WHERE `displayname` = 'RRDCacheD listening socket/port'); +