SNMP Alert
Reference:
a) Github
b) AMBARI-13205
1) Install SNMP on a sandbox or test environment
yum install net-snmp net-snmp-utils net-snmp-libs –y
2) Modify the script /etc/snmp/snmptrapd.conf to include "disableAuthorization yes"
# Example configuration file for snmptrapd
#
# No traps are handled by default, you must edit this file!
#
# authCommunity log,execute,net public
# traphandle SNMPv2-MIB::coldStart /usr/bin/bin/my_great_script cold
disableAuthorization yes
3) Copy APACHE-AMBARI-MIB.txt file from the above github or jira reference
a) cp APACHE-AMBARI-MIB.txt /usr/share/snmp/mibs
b) chmod 777 /usr/share/snmp/mibs/APACHE-AMBARI-MIB.txt
4) Copy snmp_mib_script.sh script from the above github or jira reference and set appropriate permission to execute the script
cp snmp_mib_script.sh /tmp/snmp_mib_script.sh
5) Run the below command
nohup snmptrapd -m ALL -A -n -Lf /tmp/traps.log &
6) Invoke a test trap to ensure that the snmptrapd is logging appropriately to '/tmp/traps.log'
snmptrap -v 2c -c public localhost '' APACHE-AMBARI-MIB::apacheAmbariAlert alertDefinitionName s "definitionName" alertDefinitionHash s "definitionHash" alertName s "name" alertText s "text" alertState i 0 alertHost s "host" alertService s "service" alertComponent s "component"
7) Check and see the alert in the trap file '/tmp/traps.log'
😎 Kill the snmptrapd process(step 5) and set up the alert notification on Ambari UI
9) Below is the notification I setup on Ambari


10) Run the below command & invoke a test trap again
nohup snmptrapd -m ALL -A -n -Lf /tmp/traps.log &
snmptrap -v 2c -c public localhost '' APACHE-AMBARI-MIB::apacheAmbariAlert alertDefinitionName s "definitionName" alertDefinitionHash s "definitionHash" alertName s "name" alertText s "text" alertState i 0 alertHost s "host" alertService s "service" alertComponent s "component"
11) Test the alert by manually stopping a component, in this example yarn node manager and ambari-agent was stopped which showed up on both /var/log/ambari-server/ambari-alerts.log and also in /tmp/traps.log file. I have attached the screenshot of the snmp alert on the left side and ambari alert on the right side of the screen shot. Please note sometimes the alert might take a while to show up.

Hope this helps!
Thanks

