icinga2 icon indicating copy to clipboard operation
icinga2 copied to clipboard

Logger: don't render log messages which will be disposed anyway

Open Al2Klimov opened this issue 3 years ago • 2 comments

by caching the total minimum log severity of all loggers in a "global variable" and whether a message's severity is large enough for any of the loggers in a per-message no-op flag.

closes #9504

Al2Klimov avatar Sep 08 '22 10:09 Al2Klimov

Is-it-harmless test

Involves three loggers w/ different levels.

➜  icinga2 git:(master) ✗ prefix/sbin/icinga2 daemon -x warning
[2022-09-08 12:01:23 +0200] warning/PluginCheckTask: Check command for object 'alexandersmbp2.int.netways.de!swap' (PID: 96123, arguments: '/Users/aklimov/NET/WS/icinga2/prefix/usr/lib/nagios/plugins/check_swap' '-c' '25%' '-w' '50%') terminated with exit code 128, output: execvpe(/Users/aklimov/NET/WS/icinga2/prefix/usr/lib/nagios/plugins/check_swap) failed: No such file or directory
^C
➜  icinga2 git:(master) ✗ tail prefix/var/log/icinga2/icinga2.log
[2022-09-08 12:00:42 +0200] information/FileLogger: 'main-log' started.
[2022-09-08 12:00:42 +0200] information/NotificationComponent: 'notification' started.
[2022-09-08 12:00:42 +0200] information/CheckerComponent: 'checker' started.
[2022-09-08 12:00:42 +0200] information/ConfigItem: Activated all objects.
[2022-09-08 12:01:23 +0200] warning/PluginCheckTask: Check command for object 'alexandersmbp2.int.netways.de!swap' (PID: 96123, arguments: '/Users/aklimov/NET/WS/icinga2/prefix/usr/lib/nagios/plugins/check_swap' '-c' '25%' '-w' '50%') terminated with exit code 128, output: execvpe(/Users/aklimov/NET/WS/icinga2/prefix/usr/lib/nagios/plugins/check_swap) failed: No such file or directory
[2022-09-08 12:01:26 +0200] information/Application: Received request to shut down.
[2022-09-08 12:01:27 +0200] information/Application: Shutting down...
[2022-09-08 12:01:27 +0200] information/CheckerComponent: 'checker' stopped.
[2022-09-08 12:01:27 +0200] information/NotificationComponent: 'notification' stopped.
➜  icinga2 git:(master) ✗ tail prefix/var/log/icinga2/debug.log
[2022-09-08 12:01:27 +0200] debug/ConfigObject: Deactivate() called for config object 'alexandersmbp2.int.netways.de!http' with type 'Service'.
[2022-09-08 12:01:27 +0200] debug/ConfigObject: Deactivate() called for config object 'alexandersmbp2.int.netways.de!icinga' with type 'Service'.
[2022-09-08 12:01:27 +0200] debug/ConfigObject: Deactivate() called for config object 'disk' with type 'ServiceGroup'.
[2022-09-08 12:01:27 +0200] debug/ConfigObject: Deactivate() called for config object 'ping' with type 'ServiceGroup'.
[2022-09-08 12:01:27 +0200] debug/ConfigObject: Deactivate() called for config object 'http' with type 'ServiceGroup'.
[2022-09-08 12:01:27 +0200] debug/ConfigObject: Deactivate() called for config object '9to5' with type 'TimePeriod'.
[2022-09-08 12:01:27 +0200] debug/ConfigObject: Deactivate() called for config object '24x7' with type 'TimePeriod'.
[2022-09-08 12:01:27 +0200] debug/ConfigObject: Deactivate() called for config object 'never' with type 'TimePeriod'.
[2022-09-08 12:01:27 +0200] debug/ConfigObject: Deactivate() called for config object 'app' with type 'IcingaApplication'.
[2022-09-08 12:01:27 +0200] debug/ConfigObject: Deactivate() called for config object 'debug-file' with type 'FileLogger'.
➜  icinga2 git:(master) ✗

Each gets its level \o/

Al2Klimov avatar Sep 08 '22 10:09 Al2Klimov

TODO

  • #9523

TODO @Al2Klimov

  • [x] rebase

Al2Klimov avatar Sep 09 '22 12:09 Al2Klimov