SNMP v2/v3 how to use return values?

Hi All,

First of all, total noob alert! I’ve been reading through the documentation but can’t get it clear in my head, so my apologies if this is a totally dumb question.

I’m currently using SNMPv2 and SNMPv3 to check network interfaces of multiple switches, which return either a 1 or 2 based on if they are UP (1) or DOWN (2).

However, for both a 1 and 2 return it states, ‘SNMP OK - 1 or 2’ How can I change this so that the actual Icinga2 host service changes to CRITICAL once a 2 is returned on that check?

All this was configured via the web GUI / director.

Thank you in advance, and once again sorry if this is a stupid questions.

Hi,

there is no such feature in icinga2 as far as I know.
However, it is fairly easy to write your own python script that does what you are talking about. I wrote my own check that works somewhat similar to this:

  1. Call the normal check
  2. Import the output into a variable
  3. Use if/else to check your variable and write your desired output into another variable .

Icinga2 reads the exit() in python to determine the state of the check and whatever you print() is used as output.

This video helped me alot: