icinga2 icon indicating copy to clipboard operation
icinga2 copied to clipboard

Don't write icinga2.debug file

Open julianbrost opened this issue 3 years ago • 2 comments

At the moment, Icinga 2 writes the /var/cache/icinga2/icinga2.debug file every time it loads a config (that is, config validation and daemon startup including reload). Analyzing icinga2 daemon -C using a profiler shows that a solid 17% of the total time is spent in icinga::ConfigCompilerContext::WriteObject(), i.e. duming the object to the icinga2.debug file. Most of the time in there is spent in icinga::JsonEncode(). So not writing this file each time show great potential to speed up reload times.

The main purpose of this file is to be the data source for the icinga2 object list command, which you typically only need when debugging issues, in all other cases, writing this file is a waste of time.

Two options for improving this:

  • Adding an extra flag to only generate the file if needed, so to use icinga2 object list, you'd have to run something like icinga2 daemon -C --dump-objects first.
  • Rework icinga2 object list so that it does not read the icinga2.debug file but rather talks to the running daemon to get that information. For this, a new local socket would be needed, but looks like Windows still is an open question (looks like support for AF_UNIX was added around 2018, but that's probably not yet available in all relevant server versions). This option has the additional advantage that icinga2 object list would always output up-to-date information just as it's used by the daemon, whereas now, it could show newer (config modified, icinga2 daemon -C but no reload) or older (API-modified object, no daemon reload or config validation since then) information than used by the daemon.

julianbrost avatar Apr 29 '22 10:04 julianbrost

My first thought was that #7349 could serve as a basis for this feature, but that seems to add the socket to the umbrella process, so that's not really what we'd need here.

julianbrost avatar Apr 29 '22 11:04 julianbrost

This is what's currently written to icinga2.debug: https://github.com/Icinga/icinga2/blob/a51c004f548265941d089cc2034688a4e91d9701/lib/config/configitem.cpp#L288-L300

Everything except debug_hints, everything is already available at runtime. debug_hints is what is responsible for these lines in icinga2 object list:

    % = modified in '/etc/icinga2/zones.d/master/notifications.conf', lines 10:2-10:24

julianbrost avatar Apr 29 '22 13:04 julianbrost