I am trying to define an external script which would take optional arguments in NSClient++ 0.4.1 on Windows. Following the
nsclient-full.ini example code I have defined
mycheck=cmd /C echo C:\mydir\myscript.ps1 %ARGS% | powershell.exe -command -
which simply yields the string
%ARGS% passed as the only argument to myscript.ps1, no matter what I specify in my call through NRPE (using Nagios'
check_nrpe if that matters). I then tried to rewrite the definition to
mycheck=cmd /C echo C:\mydir\myscript.ps1 $ARG1$ $ARG2$ | powershell.exe -command -
(myscript.ps1 would take up to two arguments), which does help a bit. At least, if two arguments are provided, I can fetch them via the
args array. The trouble starts when the call has less than two arguments - in this case the literal strings
$ARG1$ are passed through as arguments. Handling this case in the code of myscript.ps1 makes the whole argument processing routine ugly at best.
Is there a sane way of defining optional parameters to an external script which would not pass NSClient's variable names if no parameter has been specified?