I'm trying to extend my check_ms_win_tasks.ps1 script. At this point, I'm passing three parameters and they are all mandatory. As I do not want them to be mandatory, as it can happen there are no excluding folder or task patterns, I removed the [Parameter(Mandatory=$true)] form the parameters.
Now normally I should be able to call the script like this in Powershell: .\check_ms_win_tasks.ps1 -computername "localhost" -ExclFolders "Microsoft" -ExclTasks "Google", which gives the expected result.
But when I try this from cli, I get:
Code: Select all
/usr/local/nagios/libexec/check_nrpe -H servername -p 5666 -t 60 -c check_ms_win_tasks -a '-Computername "localhost"' '-ExclFolders Microsoft,OG_WZD,EHRM,F5,Backup_Maintenance' '-ExclTasks "Jeff","Copy Fimacs"'
/usr/local/nagios/libexec/check_nrpe: invalid option -- 'E'
/usr/local/nagios/libexec/check_nrpe: invalid option -- 'x'
/usr/local/nagios/libexec/check_nrpe: invalid option -- 'E'
/usr/local/nagios/libexec/check_nrpe: invalid option -- 'x'
NRPE Plugin for Nagios
Copyright (c) 1999-2008 Ethan Galstad ([email protected])
Version: 2.12
Last Modified: 03-10-2008
License: GPL v2 with exemptions (-l for more info)
SSL/TLS Available: Anonymous DH Mode, OpenSSL 0.9.6 or higher required
Usage: check_nrpe -H <host> [-n] [-u] [-p <port>] [-t <timeout>] [-c <command>] [-a <arglist...>]
Options:
-n = Do no use SSL
-u = Make socket timeouts return an UNKNOWN state instead of CRITICAL
<host> = The address of the host running the NRPE daemon
[port] = The port on which the daemon is running (default=5666)
[timeout] = Number of seconds before connection times out (default=10)
[command] = The name of the command that the remote daemon should run
[arglist] = Optional arguments that should be passed to the command. Multiple
arguments should be separated by a space. If provided, this must be
the last option supplied on the command line
The command made in nsclient.ini looks like this:
Code: Select all
check_ms_win_tasks=cmd /c echo scripts\check_ms_win_tasks.ps1 $ARG1$ $ARG2$ $ARG3$; exit $LastExitCode | powershell.exe -command -The Nagios command look like this now:
Code: Select all
$USER1$/check_nrpe -H $HOSTADDRESS$ -p 5666 -t 60 -c check_ms_win_tasks -a $ARG1$ $ARG2$ $ARG3$Any advice on this?
Willem