check_nrpe put $ at end of check string
Posted: Wed Feb 12, 2014 11:44 am
Hi to all!
i've a problem with my powershell nagios script, mounted on a MS Windows Server 2008 64bit, with a NRPE_NT daemon.
I've declared the command like this:
I've set ExecutionPolicy as unrestricted
I've restart NRPE_NT Services and declared command on console, like this:
Now, why if i run it locally, it works good:
But if i run it by check_nrpe i receive this output:
'-' was specified with the -Command parameter: no other arguments to -Command are permitted.
In Debug mode, on NRPE.log i can see this:
Why in this way, check_nrpe add a dollar character ($) at end string, derailing the entire control ?
This is the powershell script:
Thanks in advance
i've a problem with my powershell nagios script, mounted on a MS Windows Server 2008 64bit, with a NRPE_NT daemon.
I've declared the command like this:
Code: Select all
command[check_files]=cmd /c echo C:\nrpe\libexec\check_file.ps1 $ARG1$; exit($lastexitcode) | powershell.exe -command - I've restart NRPE_NT Services and declared command on console, like this:
Code: Select all
$USER1$/check_nrpe -H $HOSTADDRESS$ -t 60 -c check_files -a $ARG1$Code: Select all
C:\>cmd /c echo C:\nrpe\libexec\_file.ps1 C:\nrpe; exit($lastexitcode)| powershell.exe -command -
[b]No file/s present with this string[/b]'-' was specified with the -Command parameter: no other arguments to -Command are permitted.
In Debug mode, on NRPE.log i can see this:
Code: Select all
Running command: cmd /c echo C:\nrpe\libexec\check_file.ps1 C:\nrpe; exit($lastexitcode) | powershell.exe -command - [b]$[/b]
Command completed with return code 0This is the powershell script:
Code: Select all
#Nagios Status
$returnStateOK = 0
$returnStateWarning = 1
$returnStateCritical = 2
$returnStateUnknown = 3
if ($args.count -lt 1) {
echo "Miss Argument"
exit $returnStateUnknown
}
elseif ($args.count -eq 1) {
$test = Test-Path $args
if ($test -eq "True") {
$result = ls $args -Filter *.err|Measure-Object -Line | select -expand lines
if ($result -ne 0) {
echo "$result file/s presents with *.err ext"
exit $returnStateCritical
}
else {
echo "No file/s present with this string"
exit $returnStateOK
}
}
else {
echo "Path not found"
exit $returnStateUnknown
}
}
else {
echo "Write only 1 argument"
exit $returnStateUnknown
}