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.
We are using this in our environment. It works fine. If we would like to get the host name in the alert next what should we add to the snmptrap command ? You have the alerthost in this sample command
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"
Like this what will be the command for snmp_mib_script.sh - to include the alertHost ?
/usr/bin/snmptrap -v 2c -c $COMMUNITY $HOST '' APACHE-AMBARI-MIB::apacheAmbariAlert alertDefinitionName s "$1" alertName s "$2" alertText s "$5" alertState i $STATE alertService s "$3"