centreon
centreon copied to clipboard
fix(ui/timeline): remove INITIAL STATE logs
Description
Removes the INITIAL STATE logs, generated by Engine each time it restarts, from the Timeline tab.
Without the fix, events will be shown eventhough there is no status change (Engine restarted twice at 11:47 and 11:49 AM) :
This is the behaviour of the Event Logs page :
What's odd is the "AND l.output NOT LIKE 'INITIAL % STATE:%" statement : there is no such strings in INITIAL STATE logs so Engine may have change its behaviour. Also, the msg_type 8 and 9 must be better explained by the Collect dev team (cc @bouda1).
Type of change
- [x] Patch fixing an issue (non-breaking change)
Target serie
- [ ] 22.04.x
- [x] 22.10.x
- [x] 23.04.x
- [x] 23.10.x
- [x] 24.04.x (master)
How this pull request can be tested ?
- Restart an Engine,
- No new event should be listed in the Timeline tab of any resource.
Checklist
Community contributors & Centreon team
- [x] I have followed the coding style guidelines provided by Centreon
- [x] I have commented my code, especially new classes, functions or any legacy code modified. (docblock)
- [x] I have commented my code, especially hard-to-understand areas of the PR.
- [x] I have rebased my development branch on the base branch (master, maintenance).
Hi @cgagnaire
I don't understand your last remark concerning the SQL query and "AND l.output NOT LIKE 'INITIAL % STATE:%" .
I have a Centreon 23.04 here, and here is the result I get:
MariaDB [centreon_storage]> select output from logs limit 10;
+---------------------------------------------------------------------------+
| output |
+---------------------------------------------------------------------------+
| Event broker module '/usr/lib64/nagios/cbmod.so' initialized successfully |
| INITIAL HOST STATE: Centreon-central;UP;HARD;1; |
| INITIAL SERVICE STATE: Centreon-central;proc-sshd;OK;HARD;1; |
| INITIAL SERVICE STATE: Centreon-central;proc-httpd;OK;HARD;1; |
| INITIAL SERVICE STATE: Centreon-central;proc-crond;OK;HARD;1; |
| INITIAL SERVICE STATE: Centreon-central;proc-centengine;OK;HARD;1; |
| INITIAL SERVICE STATE: Centreon-central;proc-gorgone;OK;HARD;1; |
| INITIAL SERVICE STATE: Centreon-central;proc-broker-sql;OK;HARD;1; |
| INITIAL SERVICE STATE: Centreon-central;proc-broker-rrd;OK;HARD;1; |
| INITIAL SERVICE STATE: Centreon-central;Ping;OK;HARD;1; |
+---------------------------------------------------------------------------+
10 rows in set (0,002 sec)
MariaDB [centreon_storage]>
As you can see we have such lines.
About msg_types 8 and 9, here are the different possible values defined in the broker/neb/log_entry.hh file:
service_alert = 0,
host_alert = 1,
service_notification = 2,
host_notification = 3,
warning = 4,
other = 5,
service_initial_state = 8,
host_initial_state = 9,
service_acknowledge_problem = 10,
host_acknowledge_problem = 11,
service_event_handler = 12,
host_event_handler = 13,
global_service_event_handler = 14,
global_host_event_handler = 15,
} log_msg_type;
So 8 is service_initial_state
and 9 is host_initial_state
.
So, maybe I understand better now :smile:
If you remove 8 and 9 as msg_type, we can also remove the piece of code "AND l.output NOT LIKE 'INITIAL % STATE:%" because they mean the same "thing".
And thank you @cgagnaire for this fix!! :wink:
Hi @bouda1, How are the legs?
I do have the INITIAL..STATE in the log attached to centengine process:
[2024-01-25T15:57:56.698+01:00] [process] [info] [1041258] Centreon Engine 23.04.7 starting ... (PID=1041258)
[2024-01-25T15:57:56.698+01:00] [process] [info] [1041258] Local time is Thu Jan 25 15:57:56 2024
[2024-01-25T15:57:56.698+01:00] [process] [info] [1041258] LOG VERSION: 2.0
[2024-01-25T15:57:56.698+01:00] [notifications] [info] [1041258] Calculating next valid notification time...
[2024-01-25T15:57:56.698+01:00] [notifications] [info] [1041258] Default interval: 0
[2024-01-25T15:57:56.698+01:00] [notifications] [info] [1041258] Interval used for calculating next valid notification time: 0
[2024-01-25T15:57:56.698+01:00] [notifications] [info] [1041258] Calculating next valid notification time...
[2024-01-25T15:57:56.698+01:00] [notifications] [info] [1041258] Default interval: 0
[2024-01-25T15:57:56.698+01:00] [notifications] [info] [1041258] Interval used for calculating next valid notification time: 0
[2024-01-25T15:57:56.698+01:00] [notifications] [info] [1041258] Calculating next valid notification time...
[2024-01-25T15:57:56.698+01:00] [notifications] [info] [1041258] Default interval: 0
[2024-01-25T15:57:56.698+01:00] [notifications] [info] [1041258] Interval used for calculating next valid notification time: 0
[2024-01-25T15:57:56.698+01:00] [notifications] [info] [1041258] Calculating next valid notification time...
[2024-01-25T15:57:56.698+01:00] [notifications] [info] [1041258] Default interval: 0
[2024-01-25T15:57:56.698+01:00] [notifications] [info] [1041258] Interval used for calculating next valid notification time: 0
[2024-01-25T15:57:56.699+01:00] [events] [info] [1041258] Event broker module '/usr/lib64/centreon-engine/externalcmd.so' initialized successfully
[2024-01-25T15:57:56.699+01:00] [external_command] [info] [1041258] start command_file_worker_thread
[2024-01-25T15:57:56.711+01:00] [events] [info] [1041258] Event broker module '/usr/lib64/nagios/cbmod.so' initialized successfully
[2024-01-25T15:57:56.711+01:00] [events] [info] [1041258] INITIAL HOST STATE: Host-Prod;UP;HARD;1;OK - localhost rta 0.029ms lost 0%
[2024-01-25T15:57:56.711+01:00] [events] [info] [1041258] INITIAL HOST STATE: Host-Qual;UP;HARD;1;OK - localhost rta 0.024ms lost 0%
[2024-01-25T15:57:56.711+01:00] [events] [info] [1041258] INITIAL HOST STATE: Host-Dev;UP;HARD;1;OK - localhost rta 0.034ms lost 0%
[2024-01-25T15:57:56.711+01:00] [events] [info] [1041258] INITIAL HOST STATE: Host-NoEnv;UP;HARD;1;OK - localhost rta 0.018ms lost 0%
[2024-01-25T15:57:56.711+01:00] [events] [info] [1041258] INITIAL SERVICE STATE: Host-Prod;Swap;UNKNOWN;HARD;3;UNKNOWN: SNMP Table Request: Timeout
[2024-01-25T15:57:56.711+01:00] [events] [info] [1041258] INITIAL SERVICE STATE: Host-Prod;Memory;UNKNOWN;HARD;3;UNKNOWN: SNMP Table Request: Timeout
[2024-01-25T15:57:56.711+01:00] [events] [info] [1041258] INITIAL SERVICE STATE: Host-Prod;Cpu;UNKNOWN;HARD;3;UNKNOWN: SNMP Table Request: Timeout
[2024-01-25T15:57:56.711+01:00] [events] [info] [1041258] INITIAL SERVICE STATE: Host-Prod;Ping;OK;HARD;1;OK - localhost rta 0.011ms lost 0%
[2024-01-25T15:57:56.711+01:00] [events] [info] [1041258] INITIAL SERVICE STATE: Host-Qual;Swap;UNKNOWN;HARD;3;UNKNOWN: SNMP Table Request: Timeout
[2024-01-25T15:57:56.711+01:00] [events] [info] [1041258] INITIAL SERVICE STATE: Host-Qual;Memory;UNKNOWN;HARD;3;UNKNOWN: SNMP Table Request: Timeout
[2024-01-25T15:57:56.711+01:00] [events] [info] [1041258] INITIAL SERVICE STATE: Host-Qual;Cpu;UNKNOWN;HARD;3;UNKNOWN: SNMP Table Request: Timeout
[2024-01-25T15:57:56.711+01:00] [events] [info] [1041258] INITIAL SERVICE STATE: Host-Qual;Ping;OK;HARD;1;OK - localhost rta 0.009ms lost 0%
[2024-01-25T15:57:56.711+01:00] [events] [info] [1041258] INITIAL SERVICE STATE: Host-Dev;Swap;UNKNOWN;HARD;3;UNKNOWN: Cannot find virtual memory informations.
[2024-01-25T15:57:56.711+01:00] [events] [info] [1041258] INITIAL SERVICE STATE: Host-Dev;Memory;UNKNOWN;HARD;3;UNKNOWN: Cannot find physical memory informations.
[2024-01-25T15:57:56.711+01:00] [events] [info] [1041258] INITIAL SERVICE STATE: Host-Dev;Cpu;UNKNOWN;HARD;3;UNKNOWN: SNMP Table Request: Cant get a single value.
[2024-01-25T15:57:56.711+01:00] [events] [info] [1041258] INITIAL SERVICE STATE: Host-Dev;Ping;OK;HARD;1;OK - localhost rta 0.011ms lost 0%
[2024-01-25T15:57:56.711+01:00] [events] [info] [1041258] INITIAL SERVICE STATE: Host-NoEnv;Swap;UNKNOWN;HARD;3;UNKNOWN: SNMP Table Request: Timeout
[2024-01-25T15:57:56.711+01:00] [events] [info] [1041258] INITIAL SERVICE STATE: Host-NoEnv;Memory;UNKNOWN;HARD;3;UNKNOWN: SNMP Table Request: Timeout
[2024-01-25T15:57:56.711+01:00] [events] [info] [1041258] INITIAL SERVICE STATE: Host-NoEnv;Cpu;UNKNOWN;HARD;3;UNKNOWN: SNMP Table Request: Timeout
[2024-01-25T15:57:56.711+01:00] [events] [info] [1041258] INITIAL SERVICE STATE: Host-NoEnv;Ping;OK;HARD;1;OK - localhost rta 0.009ms lost 0%
[2024-01-25T15:57:56.714+01:00] [configuration] [info] [1041258] Event loop start at Thu Jan 25 15:57:56 2024
[2024-01-25T15:57:56.714+01:00] [process] [info] [1041258] Configuration loaded, main loop starting.
But not in the database:
MariaDB [centreon_storage]> select from_unixtime(ctime), output from logs order by log_id desc limit 30;
+----------------------+---------------------------------------------------------------------------+
| from_unixtime(ctime) | output |
+----------------------+---------------------------------------------------------------------------+
| 2024-01-25 15:57:56 | Configuration loaded, main loop starting. |
| 2024-01-25 15:57:56 | Event loop start at Thu Jan 25 15:57:56 2024 |
| 2024-01-25 15:57:56 | OK - localhost rta 0.009ms lost 0% |
| 2024-01-25 15:57:56 | UNKNOWN: SNMP Table Request: Timeout |
| 2024-01-25 15:57:56 | UNKNOWN: SNMP Table Request: Timeout |
| 2024-01-25 15:57:56 | UNKNOWN: SNMP Table Request: Timeout |
| 2024-01-25 15:57:56 | OK - localhost rta 0.011ms lost 0% |
| 2024-01-25 15:57:56 | UNKNOWN: SNMP Table Request: Cant get a single value. |
| 2024-01-25 15:57:56 | UNKNOWN: Cannot find physical memory informations. |
| 2024-01-25 15:57:56 | UNKNOWN: Cannot find virtual memory informations. |
| 2024-01-25 15:57:56 | OK - localhost rta 0.009ms lost 0% |
| 2024-01-25 15:57:56 | UNKNOWN: SNMP Table Request: Timeout |
| 2024-01-25 15:57:56 | UNKNOWN: SNMP Table Request: Timeout |
| 2024-01-25 15:57:56 | UNKNOWN: SNMP Table Request: Timeout |
| 2024-01-25 15:57:56 | OK - localhost rta 0.011ms lost 0% |
| 2024-01-25 15:57:56 | UNKNOWN: SNMP Table Request: Timeout |
| 2024-01-25 15:57:56 | UNKNOWN: SNMP Table Request: Timeout |
| 2024-01-25 15:57:56 | UNKNOWN: SNMP Table Request: Timeout |
| 2024-01-25 15:57:56 | OK - localhost rta 0.018ms lost 0% |
| 2024-01-25 15:57:56 | OK - localhost rta 0.034ms lost 0% |
| 2024-01-25 15:57:56 | OK - localhost rta 0.024ms lost 0% |
| 2024-01-25 15:57:56 | OK - localhost rta 0.029ms lost 0% |
| 2024-01-25 15:57:56 | Event broker module '/usr/lib64/nagios/cbmod.so' initialized successfully |
| 2024-01-25 15:57:56 | Successfully shutdown ... (PID=1041224) |
| 2024-01-25 15:57:56 | Caught SIG TERM, shutting down ... |
| 2024-01-25 15:57:15 | Configuration loaded, main loop starting. |
| 2024-01-25 15:57:15 | Event loop start at Thu Jan 25 15:57:15 2024 |
| 2024-01-25 15:57:15 | OK - localhost rta 0.009ms lost 0% |
| 2024-01-25 15:57:15 | UNKNOWN: SNMP Table Request: Timeout |
| 2024-01-25 15:57:15 | UNKNOWN: SNMP Table Request: Timeout |
+----------------------+---------------------------------------------------------------------------+
30 rows in set (0.002 sec)
Is there an engine option that changes that behaviour ?
Thanks for the explanation for msg_type 8 and 9, and well yes I don't understand what we were trying to achieve with both conditions nullifying themselves. That's why I asked !
The legs feel pretty good :wink:
About INITIAL STATES logs, do you use legacy or log_v2 logs? I don't understand why you don't have them in the database. With log_v2, the broker sink is added to all the loggers. For INITIAL STATES, the concerned logger is named "events" and the log level is info. And the broker sink level is always info. So if you set events log level to info, you should see the INITIAL STATES on both sides.
I'm using v2 and info for events.