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?
XI does not interpret incoming 0 as 'OK'
XI does not interpret incoming 0 as 'OK'
You do not have the required permissions to view the files attached to this post.
-
scottwilkerson
- DevOps Engineer
- Posts: 19396
- Joined: Tue Nov 15, 2011 3:11 pm
- Location: Nagios Enterprises
- Contact:
Re: XI does not interpret incoming 0 as 'OK'
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
the echo $? will give you the exit code
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 $?Re: XI does not interpret incoming 0 as 'OK'
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 getthe echo $? will give you the exit codeCode: Select all
su nagios /path/to/plugin.sh echo $?
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"
}
Code: Select all
PS C:\Program Files\NSClient++\scripts\powershell> ./authTest.ps1
0 - SLIM login is working
-
scottwilkerson
- DevOps Engineer
- Posts: 19396
- Joined: Tue Nov 15, 2011 3:11 pm
- Location: Nagios Enterprises
- Contact:
Re: XI does not interpret incoming 0 as 'OK'
The powershell script isn't exiting with exit codes
Try this
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'
scottwilkerson wrote:The powershell script isn't exiting with exit codes
Try thisCode: 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)
-
scottwilkerson
- DevOps Engineer
- Posts: 19396
- Joined: Tue Nov 15, 2011 3:11 pm
- Location: Nagios Enterprises
- Contact:
Re: XI does not interpret incoming 0 as 'OK'
glad to hear it's working!dlukinski wrote:scottwilkerson wrote:The powershell script isn't exiting with exit codes
Try thisCode: 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)
Locking thread