9 |
|
|
10 |
|
import java.util.*; |
11 |
|
import java.io.*; |
12 |
+ |
import java.text.*; |
13 |
|
|
14 |
|
/** |
15 |
|
* This alerter delivers alerts using e-mail. |
56 |
|
if(((alert.getLevel() == 0) && (alert.getLastLevel() >= level)) || (alert.getLevel() >= level)) { |
57 |
|
String alertType = Alert.alertLevels[alert.getLevel()]; |
58 |
|
String thresholdType = Alert.thresholdLevels[alert.getThreshold()]; |
59 |
+ |
String timeFirstSince = DateUtils.formatTime(System.currentTimeMillis() - alert.getInitialAlertTime(), "%DAYS% days, %HOURS% hours, %MINS% mins, and %SECS% secs"); |
60 |
+ |
String timeFirstOccured = DateFormat.getDateTimeInstance(DateFormat.SHORT, DateFormat.SHORT, Locale.UK).format(new Date(alert.getInitialAlertTime())); |
61 |
+ |
|
62 |
|
// sort out the subject |
63 |
|
String subject; |
64 |
|
try { |
74 |
|
subject = StringUtils.replaceText(subject, "%thresholdValue%", alert.getThresholdValue()); |
75 |
|
subject = StringUtils.replaceText(subject, "%attributeName%", alert.getAttributeName()); |
76 |
|
subject = StringUtils.replaceText(subject, "%timeTillNextAlert%", getTimeString(Long.parseLong(alert.getTimeTillNextAlert()))); |
77 |
+ |
subject = StringUtils.replaceText(subject, "%timeSinceFirstAlert%", timeFirstSince); |
78 |
+ |
subject = StringUtils.replaceText(subject, "%timeOfFirstAlert%", timeFirstOccured); |
79 |
|
|
80 |
|
// sort out the message body |
81 |
|
String message; |
92 |
|
message = StringUtils.replaceText(message, "%thresholdValue%", alert.getThresholdValue()); |
93 |
|
message = StringUtils.replaceText(message, "%attributeName%", alert.getAttributeName()); |
94 |
|
message = StringUtils.replaceText(message, "%timeTillNextAlert%", getTimeString(Long.parseLong(alert.getTimeTillNextAlert()))); |
95 |
+ |
message = StringUtils.replaceText(message, "%timeSinceFirstAlert%", timeFirstSince); |
96 |
+ |
message = StringUtils.replaceText(message, "%timeOfFirstAlert%", timeFirstOccured); |
97 |
|
|
98 |
|
try { |
99 |
|
// create SMTP message |