centreon/centreon-broker

Stream connector generates host data twice

UrBnW opened this issue ยท 13 comments

UrBnW commented

Hi,

Here's a very simple Stream connector test script :

function init(conf)
    broker_log:set_parameters(3, "/var/log/centreon-broker/test.log")
end

function write(d)
  broker_log:info(3, broker.json_encode(d))
  return true
end

function filter(category, element)
  if category == 1 and element == 14 then
    return true
  end
  return false
end

Configured like this, at broker or module level :

config

Unfortunately, every data line is duplicated (present twice in logfile) !
No issue however with services (element == 24).

I tested 19.10.x and 20.10.x, both trigger this issue.

Any reason why ?

Thank you very much ๐Ÿ‘

Hi @cpbn,

Thanks for the feedback ๐Ÿ’ฏ

We are going to investigate this as soon as possible.

Maybe @bouda1 can give you a first answer to your running issue

Regards,

The only thing I can tell for now is that it is very strange and I don't think this is due to the streamconnector.

Maybe you changed its name and you reloaded engine. So the streamconnector could be registered two times with different names.

Could you stop engine, broker and then start broker and engine.

The only problem I think about is a change on engine side suffisantly big enough with just a reload instead of a restart.

Tell me and, maybe you could also send the broker configuration.

Thanks.

UrBnW commented

Maybe you changed its name and you reloaded engine. So the streamconnector could be registered two times with different names.

I already tried, but tried again to be sure, unfortunately it does help.
In addition, my workaround, and the fact that there is no issue with services (element == 24), tend to confirm this is not a dual-registration issue.

Could you stop engine, broker and then start broker and engine.

Does not help either.

Tell me and, maybe you could also send the broker configuration.

I use the default configuration, + a Stream connector config.
Below is central-broker.xml.

Thank you !

<?xml version="1.0" encoding="UTF-8"?>
<centreonBroker>
 <broker_id><![CDATA[1]]></broker_id>
 <broker_name><![CDATA[central-broker-master]]></broker_name>
 <poller_id><![CDATA[1]]></poller_id>
 <poller_name><![CDATA[Central]]></poller_name>
 <module_directory><![CDATA[/usr/share/centreon/lib/centreon-broker]]></module_directory>
 <log_timestamp><![CDATA[1]]></log_timestamp>
 <log_thread_id><![CDATA[0]]></log_thread_id>
 <event_queue_max_size><![CDATA[100000]]></event_queue_max_size>
 <command_file><![CDATA[/var/lib/centreon-broker/command.sock]]></command_file>
 <cache_directory><![CDATA[/var/lib/centreon-broker]]></cache_directory>
 <input>
  <name><![CDATA[central-broker-master-input]]></name>
  <port><![CDATA[5669]]></port>
  <buffering_timeout><![CDATA[0]]></buffering_timeout>
  <retry_interval><![CDATA[60]]></retry_interval>
  <protocol><![CDATA[bbdo]]></protocol>
  <tls><![CDATA[auto]]></tls>
  <negotiation><![CDATA[yes]]></negotiation>
  <one_peer_retention_mode><![CDATA[no]]></one_peer_retention_mode>
  <compression><![CDATA[auto]]></compression>
  <type><![CDATA[ipv4]]></type>
 </input>
 <logger>
  <name><![CDATA[/var/log/centreon-broker/central-broker-master.log]]></name>
  <config><![CDATA[yes]]></config>
  <debug><![CDATA[no]]></debug>
  <error><![CDATA[yes]]></error>
  <info><![CDATA[no]]></info>
  <level><![CDATA[low]]></level>
  <type><![CDATA[file]]></type>
 </logger>
 <output>
  <name><![CDATA[central-broker-master-sql]]></name>
  <db_type><![CDATA[mysql]]></db_type>
  <db_host><![CDATA[localhost]]></db_host>
  <buffering_timeout><![CDATA[0]]></buffering_timeout>
  <retry_interval><![CDATA[60]]></retry_interval>
  <db_port><![CDATA[3306]]></db_port>
  <db_user><![CDATA[centreon]]></db_user>
  <db_password><![CDATA[mynicepassword]]></db_password>
  <db_name><![CDATA[centreon_storage]]></db_name>
  <check_replication><![CDATA[no]]></check_replication>
  <type><![CDATA[sql]]></type>
 </output>
 <output>
  <name><![CDATA[centreon-broker-master-rrd]]></name>
  <port><![CDATA[5670]]></port>
  <buffering_timeout><![CDATA[0]]></buffering_timeout>
  <retry_interval><![CDATA[60]]></retry_interval>
  <host><![CDATA[localhost]]></host>
  <protocol><![CDATA[bbdo]]></protocol>
  <tls><![CDATA[no]]></tls>
  <negotiation><![CDATA[yes]]></negotiation>
  <one_peer_retention_mode><![CDATA[no]]></one_peer_retention_mode>
  <compression><![CDATA[no]]></compression>
  <type><![CDATA[ipv4]]></type>
 </output>
 <output>
  <name><![CDATA[central-broker-master-perfdata]]></name>
  <interval><![CDATA[10]]></interval>
  <length><![CDATA[31536000]]></length>
  <buffering_timeout><![CDATA[0]]></buffering_timeout>
  <retry_interval><![CDATA[60]]></retry_interval>
  <db_type><![CDATA[mysql]]></db_type>
  <db_host><![CDATA[localhost]]></db_host>
  <db_port><![CDATA[3306]]></db_port>
  <db_user><![CDATA[centreon]]></db_user>
  <db_password><![CDATA[mynicepassword]]></db_password>
  <db_name><![CDATA[centreon_storage]]></db_name>
  <check_replication><![CDATA[no]]></check_replication>
  <store_in_data_bin><![CDATA[yes]]></store_in_data_bin>
  <insert_in_index_data><![CDATA[1]]></insert_in_index_data>
  <type><![CDATA[storage]]></type>
 </output>
 <output>
  <name><![CDATA[host-latency]]></name>
  <path><![CDATA[/usr/lib/centreon/plugins/host-latency.lua]]></path>
  <filters>
   <category><![CDATA[neb]]></category>
  </filters>
  <type><![CDATA[lua]]></type>
  <lua_parameter>
   <type><![CDATA[string]]></type>
   <name><![CDATA[]]></name>
   <value><![CDATA[]]></value>
  </lua_parameter>
 </output>
 <stats>
  <type><![CDATA[stats]]></type>
  <name><![CDATA[central-broker-master-stats]]></name>
  <json_fifo><![CDATA[/var/lib/centreon-broker/central-broker-master-stats.json]]></json_fifo>
 </stats>
</centreonBroker>
UrBnW commented

Exact same behavior using the InfluxDB Stream connector script.
Host data (category == 1 and element == 14) is generated twice.

OK, initially, I did not exactly understand your problem.

In fact, you just say that host events are sent two times to the streamconnector. But can you confirm it is not the case for almost all others events ?

If it is the case, you must know that broker works with caches. When it is restarted or engine is restarted, events in cache are replayed, and it is possible to have events played two times because they come from various sources.

UrBnW commented

Yes, for services (category == 1 and element == 24), data is sent only one time to the streamconnector, as expected :)

I have completed my previous comment.

UrBnW commented

It's not a cache issue, the events after the broker restart (even longer enough after the restart) still come twice.

I made a mistake, this event is not a host event but a host status event. The only thing I can say now is that if you see it two times, it is because the connector receives it two times. The stream connector has a passive behaviour. I will take a look at the possible reasons, no idea for now.

UrBnW commented

Thank you @bouda1.
What's "nice" here is that it's easy to reproduce :)

UrBnW commented

I was curious and just gave an additional test, the issue is reproductible wherever the Stream Connector is configured from :

  • broker output ;
  • module (cbmod / engine) output.

Both configurations lead to host data generated twice.

This issue is a centreon-engine issue and not centreon-broker.
It is due to multiple reasons, but the one you see usually is that engine sends host and service status twice when they are actively checked. The fix should be release in centreon-engine 20.10.4 and 20.04.10.

UrBnW commented

I was not able to reproduce with 21.04.4 (engine 21.04.3, broker 21.04.2).
Thank you ๐Ÿ‘