-----------------------------------------------------------
This is an automatically generated e-mail. To reply, visit:
https://reviews.apache.org/r/57281/#review167857
-----------------------------------------------------------


Ship it!




Ship It!

- Alejandro Fernandez


On March 3, 2017, 11:56 a.m., yao lei wrote:
> 
> -----------------------------------------------------------
> This is an automatically generated e-mail. To reply, visit:
> https://reviews.apache.org/r/57281/
> -----------------------------------------------------------
> 
> (Updated March 3, 2017, 11:56 a.m.)
> 
> 
> Review request for Ambari and Jonathan Hurley.
> 
> 
> Bugs: AMBARI-20291
>     https://issues.apache.org/jira/browse/AMBARI-20291
> 
> 
> Repository: ambari
> 
> 
> Description
> -------
> 
> Script-Based Alert Dispatcher now pass five parameters to script,including 
> alert definition name, definition label,service name, alert state, and alert 
> text.
> But if script can receive other two parameters from dispather,it will be 
> better.
> 1.hostname.
> Because hostname the alert for is not always included in alert text,although 
> it may be null like aggregate alerts.
> With it we can more quick to find the related host that occured alert.
> 2.alert timestamp.
> We may need to know the alert occurrence time ( state change time) more 
> exactly. After the alert happened,it will spend some time to schedule the 
> script to run.
> Without it,we can only regard the script start time as the alert occurrence 
> time.
> 
> We now use this feature to send alert information to mobile phone and suggest 
> also passing hostname and alert timestamp.
> 
> 
> Diffs
> -----
> 
>   
> ambari-server/src/main/java/org/apache/ambari/server/notifications/dispatchers/AlertScriptDispatcher.java
>  907588d 
>   
> ambari-server/src/main/java/org/apache/ambari/server/state/services/AlertNoticeDispatchService.java
>  174f31f 
>   
> ambari-server/src/test/java/org/apache/ambari/server/notifications/dispatchers/AlertScriptDispatcherTest.java
>  9e0e406 
> 
> 
> Diff: https://reviews.apache.org/r/57281/diff/1/
> 
> 
> Testing
> -------
> 
> 1.cd ambari-server
>    mvn test
> 
> 2.write a python script to receive parameters from dispatcher
> 
> <code>
> #!/usr/bin/python
> import sys
> import logging
> 
> def main():
>     definitionName = sys.argv[1]
>     definitionLabel = sys.argv[2]
>     serviceName = sys.argv[3]
>     alertState = sys.argv[4]
>     alertText = sys.argv[5]
>     alertTimestamp = sys.argv[6]
>     hostname = sys.argv[7] if len(sys.argv)-1 == 7 else None
> 
>     logFile='/var/log/ambari-server/log_py.log'
> 
>     logging.basicConfig(filename = logFile, level = logging.DEBUG)
>     logging.debug('received ' + str(len(sys.argv)-1) + ' parameters')
>     for i in range(1, len(sys.argv)):
>         logging.debug('parameter ' +str(i) + ':' +str(sys.argv[i]))
> 
> if __name__ == '__main__':
>    main()
> </code>
> 
> Stop and start any service like HDFS , we can see the expected result in 
> /var/log/ambari-server/log_py.log,
> 
> 3.write a shell script to  receive parameters from dispatcher
> 
> <code>
> #!/bin/bash
> logFile=/var/log/ambari-server/log_sh.log
> definitionName=$1
> definitionLabel=$2
> serviceName=$3
> alertState=$4 
> alertText=$5
> alertTimestamp=$6
> hostname=$7
> 
> echo received $# parameters:  $definitionName, $definitionLabel, 
> $serviceName, $alertState ,$alertText ,$alertTimestamp, $hostname  >> $logFile
> </code>
> 
> Stop and start any service like HDFS , we can see the expected result in 
> /var/ambari-server/log_sh.log, we can see the expected result.
> 
> 
> Thanks,
> 
> yao lei
> 
>

Reply via email to