diff --git a/dist/bootstrap/src/main/resources/conf/server-log4j.xml b/dist/bootstrap/src/main/resources/conf/server-log4j.xml
index 09a8ade944..72a8890bbc 100644
--- a/dist/bootstrap/src/main/resources/conf/server-log4j.xml
+++ b/dist/bootstrap/src/main/resources/conf/server-log4j.xml
@@ -232,14 +232,34 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/hq-server/src/main/java/org/hyperic/hq/bizapp/server/session/EmailManagerImpl.java b/hq-server/src/main/java/org/hyperic/hq/bizapp/server/session/EmailManagerImpl.java
index da5ad3e774..5371ebbaff 100644
--- a/hq-server/src/main/java/org/hyperic/hq/bizapp/server/session/EmailManagerImpl.java
+++ b/hq-server/src/main/java/org/hyperic/hq/bizapp/server/session/EmailManagerImpl.java
@@ -80,12 +80,16 @@ public class EmailManagerImpl implements EmailManager {
private Session mailSession;
private ConcurrentStatsCollector concurrentStatsCollector;
+ private int mailSmtpConnectiontimeout;
+ private int mailSmtpTimeout;
+ private String mailSmtpHost;
+
final Log log = LogFactory.getLog(EmailManagerImpl.class);
public static final String JOB_GROUP = "EmailFilterGroup";
private static final IntHashMap _alertBuffer = new IntHashMap();
public static final Object SCHEDULER_LOCK = new Object();
-
+
@Autowired
public EmailManagerImpl(JavaMailSender mailSender, ServerConfigManager serverConfigManager,
PlatformManager platformManager, ResourceManager resourceManager,
@@ -96,6 +100,10 @@ public EmailManagerImpl(JavaMailSender mailSender, ServerConfigManager serverCon
this.platformManager = platformManager;
this.resourceManager = resourceManager;
this.concurrentStatsCollector = concurrentStatsCollector;
+
+ mailSmtpConnectiontimeout = Integer.parseInt(mailSession.getProperties().getProperty(HQConstants.MAIL_SMTP_CONNECTIONTIMEOUT));
+ mailSmtpTimeout = Integer.parseInt(mailSession.getProperties().getProperty(HQConstants.MAIL_SMTP_TIMEOUT));
+ mailSmtpHost = mailSession.getProperties().getProperty(HQConstants.MAIL_SMTP_HOST);
}
@PostConstruct
@@ -106,6 +114,7 @@ public void initStats() {
public void sendEmail(EmailRecipient[] addresses, String subject, String[] body, String[] htmlBody, Integer priority) {
MimeMessage mimeMessage = mailSender.createMimeMessage();
final StopWatch watch = new StopWatch();
+
try {
InternetAddress from = getFromAddress();
if (from == null) {
@@ -156,12 +165,19 @@ public void sendEmail(EmailRecipient[] addresses, String subject, String[] body,
mailSender.send(mimeMessage);
}
} catch (MessagingException e) {
- log.error("Error sending email: [" + subject + "]\nmailServer = [" + mailSession.getProperties() + "]", e);
+ log.error("MessagingException in sending email: [" + subject + "]\nmailServer = [" + mailSession.getProperties() + "]", e);
} catch (MailException me) {
- log.error("Error sending email: [" + subject + "]\nmailServer = [" + mailSession.getProperties() + "]", me);
+ log.error("MailException in sending email: [" + subject + "]\nmailServer = [" + mailSession.getProperties() + "]", me);
+ } catch (Exception ex) {
+ log.error("Error in sending email: [" + subject + "]\nmailServer = [" + mailSession.getProperties() + "]", ex);
} finally {
- if (watch.getElapsed() >= MeasurementConstants.MINUTE) {
- log.warn("sending email using mailServer=" + mailSession.getProperties() +
+ if (log.isDebugEnabled()){
+ log.debug("Sending email using mailServer=" + mailSession.getProperties() +
+ " took " + watch.getElapsed() + " ms.");
+ }
+ if (watch.getElapsed() >= mailSmtpConnectiontimeout
+ || (watch.getElapsed() >= mailSmtpTimeout)) {
+ log.warn("Sending email using mailServer=" + mailSmtpHost +
" took " + watch.getElapsed() + " ms. Please check with your mail administrator.");
}
}
diff --git a/hq-server/src/main/java/org/hyperic/hq/escalation/server/session/EscalationRuntimeImpl.java b/hq-server/src/main/java/org/hyperic/hq/escalation/server/session/EscalationRuntimeImpl.java
index 89b2555c9f..6c57eb0b9a 100644
--- a/hq-server/src/main/java/org/hyperic/hq/escalation/server/session/EscalationRuntimeImpl.java
+++ b/hq-server/src/main/java/org/hyperic/hq/escalation/server/session/EscalationRuntimeImpl.java
@@ -49,6 +49,7 @@
import org.hyperic.hq.authz.server.session.AuthzSubject;
import org.hyperic.hq.authz.server.session.Resource;
import org.hyperic.hq.authz.shared.AuthzSubjectManager;
+import org.hyperic.hq.events.ActionExecuteException;
import org.hyperic.hq.events.ActionExecutionInfo;
import org.hyperic.hq.events.AlertDefinitionInterface;
import org.hyperic.hq.events.AlertInterface;
@@ -604,8 +605,9 @@ public void executeState(Integer stateId) {
// HQ-1348: End escalation if alert is already fixed
if (esc.getAlertInfo().isFixed()) {
+ if (debug)
+ log.debug("alert cannot be escalated, since it is already fixed.");
endEscalation(escalationState);
-
return;
}
@@ -618,7 +620,7 @@ public void executeState(Integer stateId) {
if (debug) {
log.debug("Moving onto next state of escalation, but waiting for "
- + escalationAction.getWaitTime() + " ms");
+ + nextTime + " ms");
}
escalationState.setNextAction(actionIdx + 1);
@@ -635,7 +637,6 @@ public void executeState(Integer stateId) {
ActionExecutionInfo execInfo = new ActionExecutionInfo(esc
.getShortReason(), esc.getLongReason(), esc.getAuxLogs());
String detail = action.executeAction(esc.getAlertInfo(), execInfo);
-
type.changeAlertState(esc, overlord,
EscalationStateChange.ESCALATED);
type.logActionDetails(esc, action, detail, null);
diff --git a/hq-server/src/main/java/org/hyperic/hq/events/server/session/AlertDefinition.java b/hq-server/src/main/java/org/hyperic/hq/events/server/session/AlertDefinition.java
index a644e909b0..640fee7a02 100644
--- a/hq-server/src/main/java/org/hyperic/hq/events/server/session/AlertDefinition.java
+++ b/hq-server/src/main/java/org/hyperic/hq/events/server/session/AlertDefinition.java
@@ -618,7 +618,15 @@ public boolean performsEscalations() {
return true;
}
+ @Override
public String toString() {
- return "alertDef [" + this.getName() + "]";
+ return "AlertDefinition [_name=" + _name + ", _ctime=" + _ctime + ", _mtime=" + _mtime + ", _parent=" + _parent
+ + ", _children=" + _children + ", _description=" + _description + ", _priority=" + _priority
+ + ", _active=" + _active + ", _enabled=" + _enabled + ", _frequencyType=" + _frequencyType
+ + ", _count=" + _count + ", _range=" + _range + ", _willRecover=" + _willRecover + ", _notifyFiltered="
+ + _notifyFiltered + ", _controlFiltered=" + _controlFiltered + ", _deleted=" + _deleted
+ + ", _conditions=" + _conditions + ", _triggers=" + _triggers + ", _actions=" + _actions
+ + ", _escalation=" + _escalation + ", _resource=" + _resource + ", _state=" + _state + ", _value="
+ + _value + "]";
}
}
diff --git a/hq-server/src/main/resources/META-INF/spring/mail-context.xml b/hq-server/src/main/resources/META-INF/spring/mail-context.xml
index f0e7b26724..3a499d3436 100644
--- a/hq-server/src/main/resources/META-INF/spring/mail-context.xml
+++ b/hq-server/src/main/resources/META-INF/spring/mail-context.xml
@@ -54,6 +54,8 @@
${mail.smtp.socketFactory.fallback}
${mail.smtp.starttls.enable}
${mail.smtp.socketFactory.port}
+ ${mail.smtp.connectiontimeout}
+ ${mail.smtp.timeout}
diff --git a/hq-server/src/main/resources/mail-config.properties b/hq-server/src/main/resources/mail-config.properties
index e59d5c0341..8c3fd76181 100644
--- a/hq-server/src/main/resources/mail-config.properties
+++ b/hq-server/src/main/resources/mail-config.properties
@@ -32,6 +32,7 @@ mail.password=mypassword
#maps to mail.smtp.host, but kept existing prop name from hq-server.conf for upgrade
server.mail.host=localhost
+#maps to SMTP connection and read timeout, but kept existing prop name from hq-server.conf for upgrade
# Change to SMTP port
mail.smtp.port=25
@@ -41,4 +42,8 @@ mail.smtp.socketFactory.class=javax.net.SocketFactory
mail.smtp.socketFactory.fallback=false
mail.smtp.socketFactory.port=25
mail.smtp.starttls.enable=false
+# Connection timeout
+mail.smtp.connectiontimeout=20000
+# Read timeout
+mail.smtp.timeout=20000
mail.debug=false