ambari-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From d...@apache.org
Subject ambari git commit: AMBARI-15111 Alerts: email notification should also contain server info (dsen)
Date Fri, 19 Feb 2016 15:45:46 GMT
Repository: ambari
Updated Branches:
  refs/heads/trunk 739ed206e -> a0c4dcc5d


AMBARI-15111 Alerts: email notification should also contain server info (dsen)


Project: http://git-wip-us.apache.org/repos/asf/ambari/repo
Commit: http://git-wip-us.apache.org/repos/asf/ambari/commit/a0c4dcc5
Tree: http://git-wip-us.apache.org/repos/asf/ambari/tree/a0c4dcc5
Diff: http://git-wip-us.apache.org/repos/asf/ambari/diff/a0c4dcc5

Branch: refs/heads/trunk
Commit: a0c4dcc5db21903391e6bd5e819fefb921f4e3ca
Parents: 739ed20
Author: Dmytro Sen <dsen@apache.org>
Authored: Fri Feb 19 16:18:03 2016 +0200
Committer: Dmytro Sen <dsen@apache.org>
Committed: Fri Feb 19 16:18:03 2016 +0200

----------------------------------------------------------------------
 .../server/configuration/Configuration.java     | 12 ++++++++++++
 .../services/AlertNoticeDispatchService.java    | 17 +++++++++++++----
 .../src/main/resources/alert-templates.xml      | 20 +++++++++++++++++++-
 3 files changed, 44 insertions(+), 5 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/ambari/blob/a0c4dcc5/ambari-server/src/main/java/org/apache/ambari/server/configuration/Configuration.java
----------------------------------------------------------------------
diff --git a/ambari-server/src/main/java/org/apache/ambari/server/configuration/Configuration.java
b/ambari-server/src/main/java/org/apache/ambari/server/configuration/Configuration.java
index cfc2f51..aec83a7 100644
--- a/ambari-server/src/main/java/org/apache/ambari/server/configuration/Configuration.java
+++ b/ambari-server/src/main/java/org/apache/ambari/server/configuration/Configuration.java
@@ -278,6 +278,9 @@ public class Configuration {
   public static final String TEMPORARY_KEYSTORE_ACTIVELY_PURGE = "security.temporary.keystore.actibely.purge";
   public static final boolean TEMPORARY_KEYSTORE_ACTIVELY_PURGE_DEFAULT = true;
 
+  // Alerts notifications properties
+  public static final String AMBARI_DISPLAY_URL = "ambari.display.url";
+
   /**
    * Key for repo validation suffixes.
    */
@@ -2481,6 +2484,15 @@ public class Configuration {
   }
 
   /**
+   * Get the ambari display URL
+   * @return
+   */
+  public String getAmbariDisplayUrl() {
+    return properties.getProperty(AMBARI_DISPLAY_URL, null);
+  }
+
+
+  /**
    * @return number of retry attempts for api and blueprint operations
    */
   public int getOperationsRetryAttempts() {

http://git-wip-us.apache.org/repos/asf/ambari/blob/a0c4dcc5/ambari-server/src/main/java/org/apache/ambari/server/state/services/AlertNoticeDispatchService.java
----------------------------------------------------------------------
diff --git a/ambari-server/src/main/java/org/apache/ambari/server/state/services/AlertNoticeDispatchService.java
b/ambari-server/src/main/java/org/apache/ambari/server/state/services/AlertNoticeDispatchService.java
index a27bc1d..0b84568 100644
--- a/ambari-server/src/main/java/org/apache/ambari/server/state/services/AlertNoticeDispatchService.java
+++ b/ambari-server/src/main/java/org/apache/ambari/server/state/services/AlertNoticeDispatchService.java
@@ -451,7 +451,7 @@ public class AlertNoticeDispatchService extends AbstractScheduledService
{
     String targetType = target.getNotificationType();
 
     // build the velocity objects for template rendering
-    AmbariInfo ambari = new AmbariInfo(m_metaInfo.get());
+    AmbariInfo ambari = new AmbariInfo(m_metaInfo.get(), m_configuration);
     AlertSummaryInfo summary = new AlertSummaryInfo(histories);
     DispatchInfo dispatch = new DispatchInfo(target);
 
@@ -516,7 +516,7 @@ public class AlertNoticeDispatchService extends AbstractScheduledService
{
     String targetType = target.getNotificationType();
 
     // build the velocity objects for template rendering
-    AmbariInfo ambari = new AmbariInfo(m_metaInfo.get());
+    AmbariInfo ambari = new AmbariInfo(m_metaInfo.get(), m_configuration);
     AlertInfo alert = new AlertInfo(history);
     DispatchInfo dispatch = new DispatchInfo(target);
 
@@ -558,6 +558,10 @@ public class AlertNoticeDispatchService extends AbstractScheduledService
{
         bodyWriter.write(alert.getAlertName());
         bodyWriter.write(" ");
         bodyWriter.write(alert.getAlertText());
+        if (alert.hasHostName()) {
+          bodyWriter.write(" ");
+          bodyWriter.append(alert.getHostName());
+        }
         bodyWriter.write("\n");
       }
     }
@@ -1042,7 +1046,8 @@ public class AlertNoticeDispatchService extends AbstractScheduledService
{
      *
      * @param metaInfo
      */
-    protected AmbariInfo(AmbariMetaInfo metaInfo) {
+    protected AmbariInfo(AmbariMetaInfo metaInfo, Configuration m_configuration) {
+      m_url = m_configuration.getAmbariDisplayUrl();
       m_version = metaInfo.getServerVersion();
     }
 
@@ -1053,6 +1058,10 @@ public class AlertNoticeDispatchService extends AbstractScheduledService
{
       return m_hostName;
     }
 
+    public boolean hasUrl() {
+      return m_url != null;
+    }
+
     /**
      * @return the url
      */
@@ -1193,4 +1202,4 @@ public class AlertNoticeDispatchService extends AbstractScheduledService
{
       return m_body;
     }
   }
-}
\ No newline at end of file
+}

http://git-wip-us.apache.org/repos/asf/ambari/blob/a0c4dcc5/ambari-server/src/main/resources/alert-templates.xml
----------------------------------------------------------------------
diff --git a/ambari-server/src/main/resources/alert-templates.xml b/ambari-server/src/main/resources/alert-templates.xml
index d7fe320..2e8fc71 100644
--- a/ambari-server/src/main/resources/alert-templates.xml
+++ b/ambari-server/src/main/resources/alert-templates.xml
@@ -158,6 +158,20 @@
                   <div class="label-small">
                     $alert.getAlertText()
                   </div>
+                  <div class="label-small">
+                    Cluster: $alert.getAlertDefinition().getCluster().getClusterName()
+                  </div>
+                  #if( $alert.getHostName() )
+                    #if( $ambari.hasUrl() )
+                      <div class="label-small">
+                      Host: <a href=$ambari.getUrl()/#/main/hosts/$alert.getHostName()/summary>$ambari.getUrl()/#/main/hosts/$alert.getHostName()/summary</a>
+                      </div>
+                    #else
+                      <div class="label-small">
+                        Host: $alert.getHostName()
+                      </div>
+                    #end
+                  #end
                 </td>
               </tr>
             #end
@@ -170,6 +184,10 @@
     This notification was sent to $dispatch.getTargetName()
     <br/>
     Apache Ambari $ambari.getServerVersion()
+    #if( $ambari.hasUrl() )
+    <br/>
+    Ambari Server link: <a href=$ambari.getUrl()>$ambari.getUrl()</a>
+    #end
   </div>
 </html>
       ]]>
@@ -193,4 +211,4 @@
 $alert.getAlertText()]]>
     </body>
   </alert-template>  
-</alert-templates>
\ No newline at end of file
+</alert-templates>


Mime
View raw message