Skip to content
This repository has been archived by the owner on Dec 13, 2022. It is now read-only.

Saving a engine configuration changes the value of "Broker Module Options" involuntary to 0 #8196

Closed
2 of 4 tasks
rmorandell-pgum opened this issue Dec 16, 2019 · 5 comments
Closed
2 of 4 tasks

Comments

@rmorandell-pgum
Copy link

BUG REPORT INFORMATION

Versions

centreon-engine-18.10.0-4.el7.centos.x86_64
centreon-web-18.10.9-4.el7.centos.noarch
centreon-widget-grid-map-18.10.0-6.el7.centos.noarch
centreon-open-tickets-18.10.0-5.el7.centos.noarch
centreon-plugin-Hardware-Printers-Generic-Snmp-20191016-111959.el7.centos.noarch
centreon-plugin-Applications-Monitoring-Centreon-Poller-20191016-111959.el7.centos.noarch
centreon-plugin-Applications-Monitoring-Centreon-Database-20191016-111959.el7.centos.noarch
centreon-broker-influxdb-18.10.2-1.el7.centos.x86_64
centreon-release-18.10-2.el7.centos.noarch
centreon-18.10.9-4.el7.centos.noarch
centreon-widget-live-top10-memory-usage-18.10.0-6.el7.centos.noarch
centreon-widget-servicegroup-monitoring-18.10.0-6.el7.centos.noarch
centreon-fingerprint-18.10.0-1.el7.centos.x86_64
centreon-plugin-Hardware-Ups-Standard-Rfc1628-Snmp-20191016-111959.el7.centos.noarch
centreon-broker-18.10.2-1.el7.centos.x86_64
centreon-engine-daemon-18.10.0-4.el7.centos.x86_64
centreon-trap-18.10.9-4.el7.centos.noarch
centreon-database-18.10.9-4.el7.centos.noarch
centreon-connector-ssh-18.10.0-2.el7.centos.x86_64
centreon-license-manager-common-18.10.2-1.el7.centos.noarch
centreon-license-manager-18.10.2-1.el7.centos.noarch
centreon-widget-hostgroup-monitoring-18.10.0-6.el7.centos.noarch
centreon-widget-tactical-overview-18.10.0-6.el7.centos.noarch
centreon-open-tickets-module-18.10.0-5.el7.centos.noarch
centreon-widget-service-monitoring-18.10.4-1.el7.centos.noarch
centreon-broker-storage-18.10.2-1.el7.centos.x86_64
centreon-broker-cbd-18.10.2-1.el7.centos.x86_64
centreon-plugin-Virtualization-VMWare-daemon-3.0.3-20190704131142.el7.centos.noarch
centreon-clib-18.10.0-2.el7.centos.x86_64
centreon-plugin-Operatingsystems-Windows-Snmp-20191016-111959.el7.centos.noarch
centreon-plugin-Applications-Protocol-Http-20191016-111959.el7.centos.noarch
centreon-perl-libs-18.10.9-4.el7.centos.noarch
centreon-engine-extcommands-18.10.0-4.el7.centos.x86_64
centreon-base-config-centreon-engine-18.10.9-4.el7.centos.noarch
centreon-connector-perl-18.10.0-2.el7.centos.x86_64
centreon-awie-18.10.0-3.el7.centos.noarch
centreon-widget-live-top10-cpu-usage-18.10.0-6.el7.centos.noarch
centreon-widget-host-monitoring-18.10.1-1.el7.centos.noarch
centreon-open-tickets-widget-18.10.0-5.el7.centos.noarch
centreon-plugins-base-1.18-2.el7.centos.noarch
centreon-pp-manager-18.10.5-1.el7.centos.noarch
centreon-broker-core-18.10.2-1.el7.centos.x86_64
centreon-broker-cbmod-18.10.2-1.el7.centos.x86_64
centreon-plugin-Network-Cisco-Standard-Snmp-20191016-111959.el7.centos.noarch
centreon-plugin-Applications-Protocol-Dns-20191016-111959.el7.centos.noarch
centreon-plugin-Applications-Monitoring-Centreon-Central-20191016-111959.el7.centos.noarch
centreon-plugin-Applications-Databases-Mysql-20191016-111959.el7.centos.noarch
centreon-common-18.10.9-4.el7.centos.noarch
ivertix-centreon-web-18.10.9-0.x86_64
centreon-connector-18.10.0-2.el7.centos.x86_64
centreon-widget-httploader-18.10.0-6.el7.centos.noarch
centreon-auto-discovery-server-18.10.7-1.el7.centos.x86_64
centreon-plugin-Applications-Monitoring-Centreon-Map4-Jmx-20191016-111959.el7.centos.noarch
centreon-plugin-Applications-Protocol-Ftp-20191016-111959.el7.centos.noarch
centreon-widget-engine-status-18.10.1-1.el7.centos.noarch
centreon-poller-centreon-engine-18.10.9-4.el7.centos.noarch
centreon-widget-graph-monitoring-18.10.0-6.el7.centos.noarch
centreon-plugin-Operatingsystems-Linux-Snmp-20191016-111959.el7.centos.noarch
centreon-plugin-Applications-Protocol-Ldap-20191016-111959.el7.centos.noarch
centreon-widget-global-health-18.10.1-1.el7.centos.noarch
centreon-broker-graphite-18.10.2-1.el7.centos.x86_64

Operating System

CentOS7

Browser used

  • Google Chrome
  • Firefox
  • Internet Explorer IE11
  • Safari

Additional environment details (AWS):

Description

Changing some values in "Configuration>Pollers>Engine configuration" resets the value for "Broker Module Options" under Data to "0".

Steps to Reproduce

Please describe precisely the steps to reproduce the encountered issue.

  1. I logged in Centreon
  2. Menu "Configuration>Pollers>Engine configuration"
  3. Set some value to trigger a save
  4. Reopen the changed Engine Configuration
  5. Move to tab "Data"
  6. Check the value of Broker Module Options

Describe the received result

The value changes to 0 and a warning appears.

image

Reseting to -1 and save ha no effect.

Workaround: set the value on DB directly

Could be correlated with issue https://github.com/centreon/centreon/issues/7942 ?

@lpinsivy
Copy link
Contributor

Hi @rmorandell-pgum when you save the form do you have error in /var/opt/rh/rh-php71/log/php-fpm/centreon-error.log or /var/log/centreon/sql-error.log files?

Regards,

@rmorandell-pgum
Copy link
Author

Hi @lpinsivy,

thanks for the answer. The sql-error.log is clear.

In centreon-error.logi can see this error:

[20-Dec-2019 11:03:06 Europe/Rome] PHP Warning: Invalid argument supplied for foreach() in /usr/share/centreon/www/include/configuration/configNagios/DB-Func.php on line 239
[20-Dec-2019 11:03:06 Europe/Rome] PHP Warning: array_map(): Argument #2 should be an array in /usr/share/centreon/www/include/configuration/configNagios/DB-Func.php on line 2160
[20-Dec-2019 11:03:06 Europe/Rome] PHP Warning: join(): Invalid arguments passed in /usr/share/centreon/www/include/configuration/configNagios/DB-Func.php on line 2160

@lpinsivy
Copy link
Contributor

Hi @rmorandell-pgum I made a mistake when I cherry-pick the PR #7591 on 18.10.x branch.

Can you apply this patch and indicate me if everything is ok before to patch the 18.10.x branch.

diff --git a/www/include/configuration/configNagios/DB-Func.php b/www/include/configuration/configNagios/DB-Func.php
index 66fb2c50ac..49e7f69ea2 100644
--- a/www/include/configuration/configNagios/DB-Func.php
+++ b/www/include/configuration/configNagios/DB-Func.php
@@ -219,34 +219,6 @@ function insertNagiosInDB()
     return ($nagios_id);
 }
 
-/**
- * Calculate the sum of bitwise for a POST QuickForm array
- *
- * The array format
- *
- * array[key] => enable
- *  Key int the bit
- *  Enable 0|1 if the bit is activate
- *
- * if found the bit -1 (all) or 0 (none) activate return the value
- *
- * @param array $list The POST QuickForm table
- * @return int The bitwise
- */
-function calculateBitwise($list)
-{
-    $bitwise = 0;
-    foreach ($list as $bit => $value) {
-        if ($value == 1) {
-            if ($bit === -1 || $bit === 0) {
-                return $bit;
-            }
-            $bitwise += $bit;
-        }
-    }
-    return $bitwise;
-}
-
 function insertNagios($ret = array(), $brokerTab = array())
 {
     global $form, $pearDB, $centreon;
@@ -1092,9 +1064,8 @@ function insertNagios($ret = array(), $brokerTab = array())
         $rq .= "'0',";
     }
 
-    // Calculate the sum of bitwise
-    if (isset($ret['event_broker_options']) && $ret['event_broker_options'] != null) {
-        $rq .= "'" . calculateBitwise($ret["event_broker_options"]) . "', ";
+    if (isset($ret["event_broker_options"]) && $ret["event_broker_options"] != null) {
+        $rq .= "'" . htmlentities($ret["event_broker_options"], ENT_QUOTES, "UTF-8") . "', ";
     } else {
         $rq .= "'-1', ";
     }
@@ -2038,9 +2009,8 @@ function updateNagios($nagios_id = null)
         $rq .= "nagios_comment = NULL, ";
     }
 
-    /* Calculate the sum of bitwise */
     if (isset($ret["event_broker_options"]) && $ret["event_broker_options"] != null) {
-        $rq .= "event_broker_options = '" . calculateBitwise($ret['event_broker_options']) . "', ";
+        $rq .= "event_broker_options = '" . htmlentities($ret["event_broker_options"], ENT_QUOTES, "UTF-8") . "',  ";
     } else {
         $rq .= "event_broker_options = '-1', ";
     }

Regards,

@rmorandell-pgum
Copy link
Author

The fix is working and the centreon-error.log is clear

Thanks

Regards

@lpinsivy
Copy link
Contributor

I made a PR and this one will be included soon in the product.

Regards,

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

3 participants