No, it cannot. The script-approach for SNMP in Ambari 2.2 is meant as a way of 
providing your own custom behavior on top of Ambari. The core logic of Ambari 
only passes the fields that you see here. (alert state, name, service, etc).

You need to edit the script to provide your own host. I've seen people actually 
put several hosts in this script since they want to push to multiple SNMP 
managers for the same notification.

Something else to mention; the web client in Ambari 2.2 didn't support edittng 
script dispatchers. You shouldn't try to edit it from the web client as it 
could change the type.

On Jun 6, 2017, at 2:09 AM, Satyanarayana Jampa 
<sja...@innominds.com<mailto:sja...@innominds.com>> wrote:

Hi,
                I am using Ambari 2.2 and I would like to enable the SNMP 
alerts.
                For  enabling the alerts I followed the below link:
                                
https://community.hortonworks.com/articles/74370/snmp-alert.html
                The “snmp_mib_script.sh” has snmptrap command, which take 
localhost as the “HOST” parameter as below:
Can this “Host” parameter be taken from the Ambari “Edit Notification” screen, 
just like the alert state, alertname etc?


HOST=localhost
COMMUNITY=public

STATE=0
if [ $4 == "OK" ]; then
  STATE=0
elif [ $4 == "UNKNOWN" ]; then
  STATE=1
elif [ $4 == "WARNING" ]; then
  STATE=2
elif [ $4 == "CRITICAL" ]; then
  STATE=3
fi

/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"

Thanks,
Satya.

Reply via email to