Defining a new checkcommand - parameters are not being initialized?

This forum was archived to /woltlab and is now in read-only mode.
  • Hello everyone,

    today I encountered a little problem concerning the definition of a new checkcommand.

    The plugin I wanted to use is a vbs. The plugin is being used on a Windows-Host.

    So I tested the VBS itself in the CMD and everything was fine, the plugin did what I was looking for.

    I then proceeded with writing the checkcommand for the plugin which looks something like this:

    (skip_key was used because the script doesn't have any letters in front of the parameters.)

    Then I got on with the according service:

    1. object Service "checkdir_C_Temp" {
    2.   import "generic-service"
    3.   check_command = "filesystemcheck"
    4.   vars.dirsize_dir = "C:\\temp"
    5.   vars.dirsize_crit = "6500"
    6.   vars.dirsize_warn = "6000"
    7.   command_endpoint = "myServer"
    8.   host_name = "myServer"
    9. }

    Ok, so far so good.

    First things first, the mere execution of the plugin is working fine. It delivers a result, the problem is, the result is always "UNKNOWN" which appears when the plugin doesn't have all the parameters specified when executed.

    It seems like the parameters are being skipped and the service doesn't hand them over to the command.

    Is there anything I might have missed?

    thanks in advance.

  • Code
    1. "//NoLogo" = {
    2. required = true
    3. order = 0
    4. }

    This snippet will be silently ignored, it is missing the "value" item. You probably want to use "value" and "skip_key" here.

  • Good Morning,

    thanks for the answers.

    Concerning the weird looking parameter definition, this actually works.

    Still, I changed it accordingly to the way you have mentioned to cut out all possible reasons for my problem, unfortunately it didn't change anything.

    This is how it looks now:

    Just to get a little bit more into detail:

    My script checks the size of a directory/folder, in order to do that it needs 3 parameters:

    1. The folder to check

    2. the warn-threshold

    3. the critical-threshold

    If one of those 3 is missing the script will return "UNKNOWN"

    The script:

    The other to specified parameters are modifiers for the cscript.exe that actually have nothing to do with the vbs itself:

    1. //Nologo changes the output of the script so it only show whats necessary.

    2. Is the path to the actual scriptfile, self explaining.

    So it seems like the modifiers are used correctly because the script is succesfully executed and has "nologo".

    My Problem is now that I dont have the slightest idea why it doesn't use the other 3 parameters and I am not even sure if it does even use one or two of them.

    But what I found out is that it can't use all 3 parameters, because I included the output of the input array of the script and it returns an outofbounds-error, so I am positive that icinga is obviously not passing over the three parameters.

    The easiest way out would probably be to find a plugin that does what I want that is an .exe file.

  • little addition:

    when I hardcode the values in the checkcommand it works just fine, so problems seem to exist between the service/serviceparams and the checkcommand.

  • I think your assumption may be right.

    To exactly know what icinga is executing, i remind you on my post #2:

    icinga2 feature enable debuglog

    type C:\ProgramData\icinga2\var\log\icinga2\debug.log | find "Running command"

    icinga2 feature disable debuglog

    That will show you exaclty what icinga2 is calling.

    At my machine, that gives:

    1. [2017-01-18 08:34:55 Mitteleuropõische Zeit] notice/Process: Running command 'C:\Windows\System32\cscript.exe //NoLogo "C:\Program Files\ICINGA2\/sbin\check_folder_size.vbs" C:\temp 6000 6500': PID 4952
    2. [2017-01-18 08:34:55 Mitteleuropõische Zeit] notice/Process: PID 4952 ('C:\Windows\System32\cscript.exe //NoLogo "C:\Program Files\ICINGA2\/sbin\check_folder_size.vbs" C:\temp 6000 6500') terminated with exit code 0

    Which looks as expected for me - so icinga2 *is* sending all parameters *and* the script returns success.

    The post was edited 2 times, last by sru ().

  • So this is how the debug.log looks, parameters are missing as guessed:

    1. [2017-01-18 09:30:30 +0100] notice/Process: Running command 'C:\Windows\System32\cscript.exe //NoLogo "C:\Program Files\ICINGA2\/sbin\check_folder_size.vbs"': PID 3932

    So I knew where to look and I have found the problem and it was of course a pretty obvious one.

    The checkcommand on the Icinga-master was different then the one found on the windows host... thats it.

    Works now.

    Thank you for your help.

    Have a nice day.