Windows Agent: Enable debug log

Hi guys,

the last time our server admins installed on our windows server Icinga as agent with automatic deployment tools and the old PowerShell module. The last time there are more and more requirement for new checks. So I test diffrent checks like the new PowerShell Framework/Plugins where I often need the debug log on Windows.

Here is described how to enable the debug log under Windows: Troubleshooting - Icinga 2

C:\Program Files\ICINGA2\sbin> .\icinga2.exe feature enable debuglog

That means it’s the same way as we know from our Linux setups. But we saw that this isn’t working in our setups. No log file is created. So we tried to open a new shell and write a log file during debuging with the call. By the way also the main log is not written.

C:\Program Files\ICINGA2\sbin>icinga2.exe daemon --log-level debug >[path]\debug.log

for the debugging session. This is working but not everything is written in the file. e.g. how icinga calls check plugins incl. parameter.

By chance a colleague of mine discovered the following entries in icinga2.conf, which are sadly not in the documention for windows setups:

/* Define our block required to enable or disable Icinga 2 debug log

  • Enable or disable it by using the PowerShell Module with
  • argument -IcingaEnableDebugLog or by switching
  • PowerShellIcinga2EnableDebug to true or false manually.
  • true: Debug log is active
  • false: Debug log is deactivated
  • IMPORTANT: “;” after true or false has to remain to allow the
  •        PowerShell Module to switch this feature on or off.
    

*/
const PowerShellIcinga2EnableDebug = false;
const PowerShellIcinga2EnableLog = false;

if (PowerShellIcinga2EnableDebug) {
object FileLogger “debug-file” {
severity = “debug”
path = LocalStateDir + “/log/icinga2/debug.log”
}
}

With setting the following constants to true

const PowerShellIcinga2EnableDebug = false;
const PowerShellIcinga2EnableLog = false;

and restart the Icinga service - et voilĂ  - the log files are created and Icinga writes long entries!

So the conclussion is you don’t need to enable the feature mainlog and debuglog under Windows. You need only the set this constantes to true. That’s all. I don’t know if it’s a bug, a feature or something else …

I hope this help some people, who maybe have the same problem like us. As I wrote, sadly that this is not documented. :frowning:

Edit:
A reason could be, using the old powershell module https://github.com/Icinga/icinga2-powershell-module, because the icinga2.conf is created by the installation routine!

2 Likes

It’s coming from icinga2-powershell-modul, details can be found here.

Thanks for the link. I read your discussion with Michael.
My thought was to write this down here for other people, who are struggling into this or similar problem.

BTW: I did some additional tests and would like to summarize the result here for the others:

  • I cleaned the icinga2.conf from the extra lines from the old PowerShell-Module showed above -> doesn’t work also
  • After I saw that the module doesn’t write following line into icinga2.conf:
    include "features-enabled/*.conf"
    That means that no enabled feature will work because of missing configuration! So after including this line again, every feature like mainlog, debuglog etc. will work like expected.
  • That means also without this line every feature has to be configured in icinga2.conf if it should work correctly.

So I hope this information help people who installed the agent on their Windows Servers with the old module in the past. We forgot for example that the module configures the agent not in the way like described in the docs. After some time this is confusing.

We have to change our installation routine to the new framework for future server installation. But that’s still on our to-do.

1 Like