Page 1 of 1
XI does not interpret incoming 0 as 'OK'
Posted: Mon Feb 10, 2020 12:23 pm
by dlukinski
Hello XI support
We have an NRPE check, receiving statuses from the remote script.
Status comes is as "0", but XI still interprets one as critical - see the attached screenshot.
Is there away to fix this?
Re: XI does not interpret incoming 0 as 'OK'
Posted: Mon Feb 10, 2020 1:31 pm
by scottwilkerson
It evaluates the exit code, not the first char of the output
If you run the plugin from the command like like so, what do you get
Code: Select all
su nagios
/path/to/plugin.sh
echo $?
the
echo $? will give you the exit code
Re: XI does not interpret incoming 0 as 'OK'
Posted: Wed Feb 12, 2020 2:04 pm
by dlukinski
scottwilkerson wrote:It evaluates the exit code, not the first char of the output
If you run the plugin from the command like like so, what do you get
Code: Select all
su nagios
/path/to/plugin.sh
echo $?
the
echo $? will give you the exit code
NRPE runs this PS script
Code: Select all
Set-Variable -Name 'path' -Value 'C:\Apps\SLIM_loginTest\AuthTest.exe'
if ([System.IO.File]::Exists($path)){
& $path
if ($LASTEXITCODE = '0'){
echo '0 - SLIM login is working'
}
elseif ($LASTEXITCODE = '2')
{
echo '2 - SLIM login is not working'
}
else
{
echo 'Something went wrong'
}
}
else
{
$LASTEXITCODE = 2;
echo "File not found: $path"
}
With this result:
Code: Select all
PS C:\Program Files\NSClient++\scripts\powershell> ./authTest.ps1
0 - SLIM login is working
Re: XI does not interpret incoming 0 as 'OK'
Posted: Wed Feb 12, 2020 2:08 pm
by scottwilkerson
The powershell script isn't exiting with exit codes
Try this
Code: Select all
Set-Variable -Name 'path' -Value 'C:\Apps\SLIM_loginTest\AuthTest.exe'
if ([System.IO.File]::Exists($path)){
& $path
if ($LASTEXITCODE = '0'){
echo '0 - SLIM login is working'
exit 0
}
elseif ($LASTEXITCODE = '2')
{
echo '2 - SLIM login is not working'
exit 2
}
else
{
echo 'Something went wrong'
exit 3
}
}
else
{
$LASTEXITCODE = 2;
echo "File not found: $path"
}
Re: XI does not interpret incoming 0 as 'OK'
Posted: Wed Feb 12, 2020 4:41 pm
by dlukinski
scottwilkerson wrote:The powershell script isn't exiting with exit codes
Try this
Code: Select all
Set-Variable -Name 'path' -Value 'C:\Apps\SLIM_loginTest\AuthTest.exe'
if ([System.IO.File]::Exists($path)){
& $path
if ($LASTEXITCODE = '0'){
echo '0 - SLIM login is working'
exit 0
}
elseif ($LASTEXITCODE = '2')
{
echo '2 - SLIM login is not working'
exit 2
}
else
{
echo 'Something went wrong'
exit 3
}
}
else
{
$LASTEXITCODE = 2;
echo "File not found: $path"
}
I worked, Thank you (!)
- totally puzzled how it was working before (we know it did and stopped appr. 1 month ago)
Re: XI does not interpret incoming 0 as 'OK'
Posted: Wed Feb 12, 2020 4:53 pm
by scottwilkerson
dlukinski wrote:scottwilkerson wrote:The powershell script isn't exiting with exit codes
Try this
Code: Select all
Set-Variable -Name 'path' -Value 'C:\Apps\SLIM_loginTest\AuthTest.exe'
if ([System.IO.File]::Exists($path)){
& $path
if ($LASTEXITCODE = '0'){
echo '0 - SLIM login is working'
exit 0
}
elseif ($LASTEXITCODE = '2')
{
echo '2 - SLIM login is not working'
exit 2
}
else
{
echo 'Something went wrong'
exit 3
}
}
else
{
$LASTEXITCODE = 2;
echo "File not found: $path"
}
I worked, Thank you (!)
- totally puzzled how it was working before (we know it did and stopped appr. 1 month ago)
glad to hear it's working!
Locking thread