XI does not interpret incoming 0 as 'OK'

This support forum board is for support questions relating to Nagios XI, our flagship commercial network monitoring solution.
Locked
dlukinski
Posts: 1130
Joined: Tue Oct 06, 2015 9:42 am

XI does not interpret incoming 0 as 'OK'

Post 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?
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'

Post 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
Former Nagios employee
Creator:
Human Design Website
Get Your Human Design Chart
dlukinski
Posts: 1130
Joined: Tue Oct 06, 2015 9:42 am

Re: XI does not interpret incoming 0 as 'OK'

Post 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
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'

Post 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"
}
Former Nagios employee
Creator:
Human Design Website
Get Your Human Design Chart
dlukinski
Posts: 1130
Joined: Tue Oct 06, 2015 9:42 am

Re: XI does not interpret incoming 0 as 'OK'

Post 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)
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'

Post 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
Former Nagios employee
Creator:
Human Design Website
Get Your Human Design Chart
Locked