Host Check Plugin - Exit Codes?

Hi,

I’m kindof stuck with a host check plugin (not service!).
I’ve written a python script which calls the system ping command. In the end it prints out a text and gives an exit code.

But Icinga seems to interprete those exit codes very odd.
And I don’t know what to do to make it work. I’m not able to make it critical/down…

Examples I tried/checked:

Plugin-Output: [OK] - PING - Packet loss = 0%, RTA = 11.95 ms
Exit-Code: 0
Icinga-Interpretation: Up

Plugin-Output: [CRITICAL] - PING - Packet loss = 100%, RTA = 0
Exit-Code: 1
Icinga-Interpretation: Up

Plugin-Output: [CRITICAL] - PING - Packet loss = 100%, RTA = 0
Exit-Code: 2
Icinga-Interpretation: Unreachable

Plugin-Output: [CRITICAL] - PING - Packet loss = 100%, RTA = 0
Exit-Code: 3
Icinga-Interpretation: Unreachable

Plugin-Output: [CRITICAL] - PING - Packet loss = 100%, RTA = 0
Exit-Code: 4
Icinga-Interpretation: Unreachable

So does someone know how to do this right?

At first I had a look at the monitoring-plugins documentation but was surprised that it seems to lack details on host plugins.
The documentation of Icinga 1 still has the information :-).

Plugin Return Code Service State Host State
0 OK UP
1 WARNING UP or DOWN/UNREACHABLE*
2 CRITICAL DOWN/UNREACHABLE
3 UNKNOWN DOWN/UNREACHABLE
1 Like

Hi Wolfgang,

Thank you for your reply. It’s definetly helpful. At least in general :slight_smile:
But as you can see in my examples above. Icinga always decides to show UNREACHABLE instead of DOWN. So as Exit-Code 2 & 3 can be both (DOWN/UNREACHABLE), how can I force Icinga to show DOWN?

I think I found the solution. On my Testenvironment many devices are down. So are the parents of the host in my examples. And because the parent is down, Icinga decides to show unreachable instead of down.

So this information together with @Wolfgang table of exit codes makes finally sense.