Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

5.8.3 #14

Open
wants to merge 4 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
26 changes: 23 additions & 3 deletions dist/bootstrap/src/main/resources/conf/server-log4j.xml
Original file line number Diff line number Diff line change
Expand Up @@ -232,14 +232,34 @@
</logger>

<!--
To debug alert and escalation events change the following from INFO to DEBUG.
For debugging specific action you can change debug level to the following:
CounterExecutionStrategy, SingleAlertExecutionStrategy, AlertManagerImpl as described below
To debug Alert mechanism change the following classes from INFO to DEBUG.
-->

<!-- Alert events (including Alert Manager) -->
<logger name="org.hyperic.hq.events">
<level value="INFO"/>
</logger>

<!-- Alert events queue (including Queue Manager): enqueue and dequeue -->
<logger name="org.hyperic.hq.zevents">
<level value="INFO" />
</logger>

<!-- Alert actions -->
<logger name="org.hyperic.hq.bizapp.server.action">
<level value="INFO" />
</logger>

<!-- Email notifications -->
<logger name="org.hyperic.hq.bizapp.server.session.EmailManagerImpl">
<level value="INFO" />
</logger>

<!-- Escalation -->
<logger name="org.hyperic.hq.escalation.server.session">
<level value="INFO" />
</logger>

<!--
To debug Measurement subsystem change the value from INFO to DEBUG.
For example: availability average calculation
Expand Down
1 change: 1 addition & 0 deletions dist/installer/src/main/resources/data/hq-server.conf
Original file line number Diff line number Diff line change
Expand Up @@ -106,6 +106,7 @@ accept.unverified.certificates=${accept.unverified.certificates}
# server, in which case localhost or 127.0.0.1 can be used here.
server.mail.host=${server.mail.host}


################################################################################
# Database (JDBC) Settings
################################################################################
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -158,4 +158,8 @@ public class HQConstants {
public static final String TOPN_DEFAULT_INTERVAL = "TOPN_DEFAULT_INTERVAL";
public static final String TOPN_NUMBER_OF_PROCESSES = "TOPN_NUMBER_OF_PROCESSES";

// Email: An SMTP protocol Properties
public static final String MAIL_SMTP_CONNECTIONTIMEOUT = "mail.smtp.connectiontimeout";
public static final String MAIL_SMTP_TIMEOUT = "mail.smtp.connectiontimeout";
public static final String MAIL_SMTP_HOST = "mail.smtp.host";
}
2 changes: 2 additions & 0 deletions hq-installer/src/test/resources/auth-tls-mail-config.xml
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,8 @@
<property name="mail.smtp.socketFactory.port" value="465" />
<property name="mail.smtp.socketFactory.fallback" value="false" />
<property name="mail.smtp.socketFactory.class" value="javax.net.ssl.SSLSocketFactory" />
<property name="mail.smtp.connectiontimeout" value="20000" />
<property name="mail.smtp.timeout" value="20000" />

</configuration>
</attribute>
Expand Down
6 changes: 6 additions & 0 deletions hq-installer/src/test/resources/default-mail-config.xml
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,12 @@
<!-- Change to the SMTP gateway server -->
<property name="mail.smtp.host" value="@@@server.mail.host@@@"/>

<!-- Change to the SMTP connection timeout -->
<property name="mail.smtp.connectiontimeout" value="20000"/>

<!-- Change to the SMTP read timeout -->
<property name="mail.smtp.timeout" value="20000"/>

<!-- Enable debugging output from the javamail classes -->
<property name="mail.debug" value="false"/>
</configuration>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand All @@ -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
Expand All @@ -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) {
Expand Down Expand Up @@ -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.");
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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;
}

Expand All @@ -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);
Expand All @@ -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);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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 + "]";
}
}
2 changes: 2 additions & 0 deletions hq-server/src/main/resources/META-INF/spring/mail-context.xml
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,8 @@
<prop key="mail.smtp.socketFactory.fallback">${mail.smtp.socketFactory.fallback}</prop>
<prop key="mail.smtp.starttls.enable">${mail.smtp.starttls.enable}</prop>
<prop key="mail.smtp.socketFactory.port">${mail.smtp.socketFactory.port}</prop>
<prop key="mail.smtp.connectiontimeout">${mail.smtp.connectiontimeout}</prop>
<prop key="mail.smtp.timeout">${mail.smtp.timeout}</prop>
</props>
</constructor-arg>
<constructor-arg ref="passwordAuthenticator" />
Expand Down
5 changes: 5 additions & 0 deletions hq-server/src/main/resources/mail-config.properties
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand All @@ -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