Send SNMP trap on failover

Configuring synchronization, sensors, and optimizations
User avatar
CRM User
Posts: 124
Joined: Sun Nov 27, 2016 3:41 pm

Send SNMP trap on failover

Postby CRM User » Tue Mar 06, 2018 6:03 pm

For system monitoring I'd like to see a SNMP trap once there has been a switchover of the HAAst peers. Perhaps one trap for demotion of the active peer, and a second trap for promotion of the standby peer. How could I do this?
Account for questions transferred from CRM system
User avatar
Telium Support
Posts: 162
Joined: Sun Nov 27, 2016 3:27 pm

Re: Send SNMP trap on failover

Postby Telium Support » Tue Mar 06, 2018 6:07 pm

You can have HAAst issue SNMP traps using HAAst's built-in event handler system. The event handlers are simply executable files (binary / BASH / etc) or symlinks placed in the directory:

The event handlers are named to reflect when they are triggered. The files you most likely want to create are:
  • asterisk.start.pre
The event handler (files) are launched automatically by HAAst - there is nothing you need to do to execute them. For example, the "asterisk.start.pre" is launched by HAAst before Asterisk is started upon node promotion. If you wanted the event handler to run immediately after Asterisk is started, create a file called "".

In your case create these two files with 550 permissions in the above folder. The content of the file would be similar to:

Code: Select all

# Issue SNMP v3 trap
snmptrap -v <snmp_version> -e <engine_id> -u <security_username> -a <authentication_protocal> -A <authentication_protocal_pass_phrase> -x <privacy_protocol> -X <privacy_protocol_pass_phrase> <destination_host> <uptime> <OID_or_MIB> <object> <value_type> <value>
logger "SNMP trap issued for demotion of local peer"

There are also numerous environment variables set by HAAst before executing the event handlers; so if you want information related to the peer/failover/etc you can use these environment variables in your BASH script. (See the installation guide for more information on the environment variables, or use the set command in an event handler to redirect all environment variables to a temporary file for further examination).

The snmptrap commands may require a change to system configuration files, but that would be specific to your setup. If you have configured other traps then this is likely already done.

Please note that use of SNMP is an advanced topic, and its configuration requires advanced Linux admin skills.