57 |
|
} catch(IOException e) { |
58 |
|
_logger.write(toString(), Logger.ERROR, "Error starting IRCBot: "+e); |
59 |
|
} |
60 |
+ |
|
61 |
+ |
_logger.write(toString(), Logger.SYSINIT, "IRC Alerter started"); |
62 |
|
} |
63 |
|
|
64 |
|
//---PUBLIC METHODS--- |
66 |
|
public void sendAlert(Alert alert) { |
67 |
|
// only send if it's equal (or above) our level |
68 |
|
if(alert.getLevel() >= _level) { |
69 |
+ |
String alertType = Alert.alerts[alert.getLevel()]+"["+String.valueOf(alert.getLevel())+"]"; |
70 |
|
// sort out the message |
71 |
|
String message = _message; |
72 |
< |
message = StringUtils.replaceText(message, "%level%", String.valueOf(alert.getLevel())); |
73 |
< |
message = StringUtils.replaceText(message, "%message%", alert.getMessage()); |
72 |
> |
message = StringUtils.replaceText(message, "%level%", alertType); |
73 |
> |
message = StringUtils.replaceText(message, "%source%", alert.getSource()); |
74 |
> |
message = StringUtils.replaceText(message, "%value%", alert.getValue()); |
75 |
> |
message = StringUtils.replaceText(message, "%thresholdValue%", alert.getThresholdValue()); |
76 |
> |
message = StringUtils.replaceText(message, "%attributeName%", alert.getAttributeName()); |
77 |
|
|
78 |
|
// send the message |
79 |
+ |
_logger.write(toString(), Logger.DEBUG, "Sending IRC Alert at level"+String.valueOf(alert.getLevel())); |
80 |
|
_ircbot.sendMsg(message); |
81 |
|
} |
82 |
|
} |
229 |
|
* @throws IOException if the disconnection fails |
230 |
|
*/ |
231 |
|
public void disconnect() throws IOException { |
232 |
< |
// send proper QUIET |
232 |
> |
// send proper QUIT |
233 |
|
_socketOut.println("QUIT : iscreamBot component shutting down..."); |
234 |
|
// close the socket |
235 |
|
_socketOut.close(); |