Return-Path: X-Original-To: archive-asf-public-internal@cust-asf2.ponee.io Delivered-To: archive-asf-public-internal@cust-asf2.ponee.io Received: from cust-asf.ponee.io (cust-asf.ponee.io [163.172.22.183]) by cust-asf2.ponee.io (Postfix) with ESMTP id 8F371200BD5 for ; Thu, 24 Nov 2016 05:36:33 +0100 (CET) Received: by cust-asf.ponee.io (Postfix) id 8DC04160B0A; Thu, 24 Nov 2016 04:36:33 +0000 (UTC) Delivered-To: archive-asf-public@cust-asf.ponee.io Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by cust-asf.ponee.io (Postfix) with SMTP id B1E3C160AFD for ; Thu, 24 Nov 2016 05:36:32 +0100 (CET) Received: (qmail 67210 invoked by uid 500); 24 Nov 2016 04:36:31 -0000 Mailing-List: contact commits-help@eagle.incubator.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: dev@eagle.incubator.apache.org Delivered-To: mailing list commits@eagle.incubator.apache.org Received: (qmail 67201 invoked by uid 99); 24 Nov 2016 04:36:31 -0000 Received: from pnap-us-west-generic-nat.apache.org (HELO spamd1-us-west.apache.org) (209.188.14.142) by apache.org (qpsmtpd/0.29) with ESMTP; Thu, 24 Nov 2016 04:36:31 +0000 Received: from localhost (localhost [127.0.0.1]) by spamd1-us-west.apache.org (ASF Mail Server at spamd1-us-west.apache.org) with ESMTP id 5C382CF1D4 for ; Thu, 24 Nov 2016 04:36:31 +0000 (UTC) X-Virus-Scanned: Debian amavisd-new at spamd1-us-west.apache.org X-Spam-Flag: NO X-Spam-Score: -4.719 X-Spam-Level: X-Spam-Status: No, score=-4.719 tagged_above=-999 required=6.31 tests=[KAM_ASCII_DIVIDERS=0.8, KAM_LAZY_DOMAIN_SECURITY=1, KAM_MXURI=1.5, RCVD_IN_DNSWL_HI=-5, RCVD_IN_MSPIKE_H3=-0.01, RCVD_IN_MSPIKE_WL=-0.01, RP_MATCHES_RCVD=-2.999] autolearn=disabled Received: from mx1-lw-us.apache.org ([10.40.0.8]) by localhost (spamd1-us-west.apache.org [10.40.0.7]) (amavisd-new, port 10024) with ESMTP id geCwp_jo9fh0 for ; Thu, 24 Nov 2016 04:36:29 +0000 (UTC) Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by mx1-lw-us.apache.org (ASF Mail Server at mx1-lw-us.apache.org) with SMTP id A44D25F58E for ; Thu, 24 Nov 2016 04:36:28 +0000 (UTC) Received: (qmail 64832 invoked by uid 99); 24 Nov 2016 04:35:12 -0000 Received: from git1-us-west.apache.org (HELO git1-us-west.apache.org) (140.211.11.23) by apache.org (qpsmtpd/0.29) with ESMTP; Thu, 24 Nov 2016 04:35:12 +0000 Received: by git1-us-west.apache.org (ASF Mail Server at git1-us-west.apache.org, from userid 33) id A7AAFDFCC6; Thu, 24 Nov 2016 04:35:12 +0000 (UTC) Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit From: jinhuwu@apache.org To: commits@eagle.incubator.apache.org Message-Id: X-Mailer: ASF-Git Admin Mailer Subject: incubator-eagle git commit: [MINOR] optimize health check: add some information Date: Thu, 24 Nov 2016 04:35:12 +0000 (UTC) archived-at: Thu, 24 Nov 2016 04:36:33 -0000 Repository: incubator-eagle Updated Branches: refs/heads/master adeaa0f9e -> 3becca689 [MINOR] optimize health check: add some information Author: wujinhu Closes #679 from wujinhu/healthFix. Project: http://git-wip-us.apache.org/repos/asf/incubator-eagle/repo Commit: http://git-wip-us.apache.org/repos/asf/incubator-eagle/commit/3becca68 Tree: http://git-wip-us.apache.org/repos/asf/incubator-eagle/tree/3becca68 Diff: http://git-wip-us.apache.org/repos/asf/incubator-eagle/diff/3becca68 Branch: refs/heads/master Commit: 3becca68929cd005416605da0b9be4cbdb0c0cba Parents: adeaa0f Author: wujinhu Authored: Thu Nov 24 12:35:05 2016 +0800 Committer: wujinhu Committed: Thu Nov 24 12:35:05 2016 +0800 ---------------------------------------------------------------------- .../ApplicationHealthCheckEmailPublisher.java | 29 ++++++++++++++++++-- .../impl/ApplicationHealthCheckServiceImpl.java | 4 +-- .../src/main/resources/application.conf | 1 - 3 files changed, 29 insertions(+), 5 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/incubator-eagle/blob/3becca68/eagle-core/eagle-app/eagle-app-base/src/main/java/org/apache/eagle/app/service/impl/ApplicationHealthCheckEmailPublisher.java ---------------------------------------------------------------------- diff --git a/eagle-core/eagle-app/eagle-app-base/src/main/java/org/apache/eagle/app/service/impl/ApplicationHealthCheckEmailPublisher.java b/eagle-core/eagle-app/eagle-app-base/src/main/java/org/apache/eagle/app/service/impl/ApplicationHealthCheckEmailPublisher.java index c7d7e0f..8374b38 100644 --- a/eagle-core/eagle-app/eagle-app-base/src/main/java/org/apache/eagle/app/service/impl/ApplicationHealthCheckEmailPublisher.java +++ b/eagle-core/eagle-app/eagle-app-base/src/main/java/org/apache/eagle/app/service/impl/ApplicationHealthCheckEmailPublisher.java @@ -26,6 +26,7 @@ import org.apache.velocity.VelocityContext; import org.slf4j.Logger; import org.slf4j.LoggerFactory; +import java.net.InetAddress; import java.util.HashMap; import java.util.Map; import java.util.Properties; @@ -72,8 +73,15 @@ public class ApplicationHealthCheckEmailPublisher implements ApplicationHealthCh final VelocityContext context = new VelocityContext(); Map appMsgs = new HashMap<>(); + int unhealthyCount = 0; + int healthyCount = 0; for (String appId : results.keySet()) { appMsgs.put(appId, results.get(appId).getMessage()); + if (!results.get(appId).isHealthy()) { + unhealthyCount++; + } else { + healthyCount++; + } } Map unHealthyContext = new HashMap<>(); unHealthyContext.put("appMsgs", appMsgs); @@ -81,11 +89,28 @@ public class ApplicationHealthCheckEmailPublisher implements ApplicationHealthCh unHealthyContext.put("healthCheckUrl", "http://" + config.getString(SERVICE_HOST) + ":" + HEALTH_CHECK_PORT + "/healthcheck"); context.put(UNHEALTHY_CONTEXT, unHealthyContext); + String subject = ""; + if (healthyCount > 0) { + subject += healthyCount + " healthy app(s)"; + } + if (unhealthyCount > 0) { + if (!subject.isEmpty()) { + subject += ", "; + } + subject += unhealthyCount + " unhealthy app(s)"; + } + subject = config.getString(CONF_MAIL_SUBJECT) + ": " + subject; EagleMailClient client = new EagleMailClient(properties); - success = client.send(config.getString(CONF_MAIL_SENDER), + String hostname = InetAddress.getLocalHost().getHostName(); + if (!hostname.endsWith(".com")) { + //avoid invalid host exception + hostname += ".com"; + } + success = client.send( + System.getProperty("user.name") + "@" + hostname, recipients, config.hasPath(CONF_MAIL_CC) ? config.getString(CONF_MAIL_CC) : null, - config.getString(CONF_MAIL_SUBJECT), + subject, config.getString(CONF_MAIL_TEMPLATE), context, null); http://git-wip-us.apache.org/repos/asf/incubator-eagle/blob/3becca68/eagle-core/eagle-app/eagle-app-base/src/main/java/org/apache/eagle/app/service/impl/ApplicationHealthCheckServiceImpl.java ---------------------------------------------------------------------- diff --git a/eagle-core/eagle-app/eagle-app-base/src/main/java/org/apache/eagle/app/service/impl/ApplicationHealthCheckServiceImpl.java b/eagle-core/eagle-app/eagle-app-base/src/main/java/org/apache/eagle/app/service/impl/ApplicationHealthCheckServiceImpl.java index b292fa1..fb2a1b4 100644 --- a/eagle-core/eagle-app/eagle-app-base/src/main/java/org/apache/eagle/app/service/impl/ApplicationHealthCheckServiceImpl.java +++ b/eagle-core/eagle-app/eagle-app-base/src/main/java/org/apache/eagle/app/service/impl/ApplicationHealthCheckServiceImpl.java @@ -152,11 +152,11 @@ public class ApplicationHealthCheckServiceImpl extends ApplicationHealthCheckSer int dailySendHour = config.getInt(HEALTH_CHECK_DAILY_SEND_HOUR_PATH); GregorianCalendar cal = new GregorianCalendar(timeZone); - if (cal.get(Calendar.HOUR_OF_DAY) % dailySendHour == 0 && !hasSendDaily) { + if (cal.get(Calendar.HOUR_OF_DAY) == dailySendHour && !hasSendDaily) { isDaily = true; } - if (cal.get(Calendar.HOUR_OF_DAY) % dailySendHour != 0) { + if (cal.get(Calendar.HOUR_OF_DAY) != dailySendHour) { hasSendDaily = false; } Map copyAppHealthChecks = new HashMap<>(); http://git-wip-us.apache.org/repos/asf/incubator-eagle/blob/3becca68/eagle-server/src/main/resources/application.conf ---------------------------------------------------------------------- diff --git a/eagle-server/src/main/resources/application.conf b/eagle-server/src/main/resources/application.conf index da0c7c9..91757d7 100644 --- a/eagle-server/src/main/resources/application.conf +++ b/eagle-server/src/main/resources/application.conf @@ -105,7 +105,6 @@ application { mail.smtp.host = "mail.host.com" mail.smtp.port = 25 mail.smtp.recipients = "someone@email.com" - mail.smtp.sender = "someone@email.com" mail.smtp.subject = "Eagle Application Health Check" mail.smtp.template = "HealthCheckTemplate.vm" }