Sending snmp traps from icinga2 to opmanager

Hi, im using a basic setup of icinga2 with icingaweb2. Using config files for hosts, and running ssh-checks from the icinga2 server using a ssh key (monitoring servers running rhel and solaris). i have users and notifications set up to mail us if we get critical alerts.
We also use opmanager for our batch ops team, for alerting support teams (on call etc). I would like to know if its possible to get icinga2 to send a trap (snmp) when an alert occurs to opmanager. And if so, how do i set this up ? Thanks…

Hi,

you can write your own notification scripts. This one is doing what you want. Icinga itself installs only a bash script to send E-Mail. Instead or in Addition you write your own notification tool for using snmp. e.g. with using net-snmp.

1 Like

Hi,

it’s correct. You have to write the notification scripts by yourself. As you have to do it anyway I would recommend to check if you can also use the opmanager REST API for example.

This is probably less hassle than having a script handling all the OIDs or maybe even parsing complex MIB files and the API has additional benefits like authentication and encryption if you want.

Thanks, im not using director or graphite as i found them too difficult to set up with using docker. I’m the only member of the team that has any knowledge on the icinga config we have as i set it up from scratch (probably badly). However I have a config that i can manage, and it works fine and emails when alerts occur (using ssh checks and nagios plugins). I have notifications set up ok for email, any idea what a notification script might look like for sending alerts to opmanager ? appreciate the input.

Hi,

I would start simple and construct a command line with the snmptrap command, as described here.

snmptrap -v <snmp_version> -c <community> <destination_host> <uptime> <OID_or_MIB> <object> <value_type> <value>

snmptrap -v 2c -c public localhost '' 1.3.6.1.4.1.8072.2.3.0.1 1.3.6.1.4.1.8072.2.3.2.1 i 123456

Once you’ve got that working, put it into a script with parameters and decide which inputs it needs to send a good trap, e.g. with passing in the host and service name as environment variables.

object NotificationCommand "snmptrap-sender" {
  //...

  command = [ ConfigDir + "/scripts/snmptrap-sender" ]

  env = {
    HOSTNAME = "$host.name$"
    SERVICENAME = "$service.name$"
  }
}

vim /etc/icinga2/scripts/snmp-trapsender

#!/bin/bash
LOG=/tmp/icinga-trapsender-`date +%s`.log

echo "Host: $HOSTNAME" >> $LOG
echo "Service: $SERVICENAME >> $LOG

# construct an snmptrap line here

One possible idea would be to provide the OID via host custom variable, and pass that one via environment variables to the script. Once everything is working, disable the LOG above.

Cheers,
Michael

Thank you, i will look at trying to set this up after xmas. i have a omprobe server i need to send the traps to. would this be the $HOST (destination_host) ?

Have abandoned. Gone opmanager route… thanks.