mirror of
https://github.com/gnustep/libs-ec.git
synced 2025-02-19 01:51:03 +00:00
Improve subjects for alarms/clears
git-svn-id: svn+ssh://svn.gna.org/svn/gnustep/libs/ec/trunk@36486 72102866-910b-0410-8b05-ffd578937521
This commit is contained in:
parent
ec7e2cf336
commit
69c31c4924
3 changed files with 30 additions and 19 deletions
|
@ -29,22 +29,32 @@
|
||||||
Rewrite = "{Original}\n\nAlarm outstanding for {Hours} hours.";
|
Rewrite = "{Original}\n\nAlarm outstanding for {Hours} hours.";
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
SeverityText = "..*"; /* Any alert with an alarm severity */
|
SeverityText = "..*";
|
||||||
DurationBelow = "60"; /* Alarm outstanding for under an hour */
|
DurationBelow = "60"; /* Alarm outstanding for under an hour */
|
||||||
Rewrite = "{Original}\n\nAlarm outstanding for {Minutes} minutes.";
|
Rewrite = "{Original}\n\nAlarm outstanding for {Minutes} minutes.";
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
SeverityText = "..*";
|
||||||
|
Subject = "Alarm {Identifier}";
|
||||||
|
Email = (
|
||||||
|
"myaccount@localhost.localdomain"
|
||||||
|
);
|
||||||
|
Stop = YES; /* Don't go on to any general alerts */
|
||||||
|
},
|
||||||
|
|
||||||
{
|
{
|
||||||
SeverityCode = "5"; /* Any alert for a cleared alarm */
|
SeverityCode = "5"; /* Any alert for a cleared alarm */
|
||||||
DurationAbove = "59"; /* Alarm outstanding for an hour or more */
|
DurationAbove = "59"; /* Alarm outstanding for an hour or more */
|
||||||
Rewrite = "{Original}\n\nCleared after {Hours} hours.";
|
Rewrite = "{Original}\n\nCleared after {Hours} hours.";
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
SeverityCode = "5"; /* Any alert for a cleared alarm */
|
SeverityCode = "5";
|
||||||
DurationBelow = "60"; /* Alarm outstanding for under an hour */
|
DurationBelow = "60"; /* Alarm outstanding for under an hour */
|
||||||
Rewrite = "{Original}\n\nCleared after {Minutes} minutes.";
|
Rewrite = "{Original}\n\nCleared after {Minutes} minutes.";
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
SeverityText = "..*"; /* Any alert with an alarm severity */
|
SeverityText = "5";
|
||||||
|
Subject = "Clear {Identifier}";
|
||||||
Email = (
|
Email = (
|
||||||
"myaccount@localhost.localdomain"
|
"myaccount@localhost.localdomain"
|
||||||
);
|
);
|
||||||
|
|
10
EcAlerter.h
10
EcAlerter.h
|
@ -200,10 +200,12 @@
|
||||||
* </p>
|
* </p>
|
||||||
* <p>The <em>Email</em> array lists email addresses to which email alerts are
|
* <p>The <em>Email</em> array lists email addresses to which email alerts are
|
||||||
* to be sent.<br />
|
* to be sent.<br />
|
||||||
* An optional 'Subject' field may be present in the rule ... this is used
|
* An optional <em>Subject</em> field may be present in the rule ...
|
||||||
* to specify that the is to be tagged with the given subject line. This
|
* this is used to specify that the is to be tagged with the given
|
||||||
* <em>defeats</em> batching of messages in that only messages with the
|
* subject line. This <em>defeats</em> batching of messages in that
|
||||||
* same subject may be batched in the same email.
|
* only messages with the same subject may be batched in the same email.<br />
|
||||||
|
* NB. The value of the <em>Subject</em> field is used as a template
|
||||||
|
* in the same way as the <em>Replacement</em> fields.
|
||||||
* </p>
|
* </p>
|
||||||
*
|
*
|
||||||
* <p>Configuration of the alerter is done by the 'Alerter' key in the user
|
* <p>Configuration of the alerter is done by the 'Alerter' key in the user
|
||||||
|
|
23
EcAlerter.m
23
EcAlerter.m
|
@ -98,11 +98,11 @@
|
||||||
@end
|
@end
|
||||||
|
|
||||||
static NSMutableString *
|
static NSMutableString *
|
||||||
replaceFields(NSDictionary *fields)
|
replaceFields(NSDictionary *fields, NSString *template)
|
||||||
{
|
{
|
||||||
NSMutableString *m;
|
NSMutableString *m;
|
||||||
|
|
||||||
m = [[[fields objectForKey: @"Replacement"] mutableCopy] autorelease];
|
m = [[template mutableCopy] autorelease];
|
||||||
if (nil != m)
|
if (nil != m)
|
||||||
{
|
{
|
||||||
NSEnumerator *e;
|
NSEnumerator *e;
|
||||||
|
@ -541,8 +541,7 @@ replaceFields(NSDictionary *fields)
|
||||||
s = [d objectForKey: @"Rewrite"];
|
s = [d objectForKey: @"Rewrite"];
|
||||||
if (nil != s)
|
if (nil != s)
|
||||||
{
|
{
|
||||||
[m setObject: s forKey: @"Replacement"];
|
s = replaceFields(m, s);
|
||||||
s = replaceFields(m);
|
|
||||||
[m setObject: s forKey: @"Message"];
|
[m setObject: s forKey: @"Message"];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -816,7 +815,7 @@ replaceFields(NSDictionary *fields)
|
||||||
/*
|
/*
|
||||||
* Perform {field-name} substitutions ...
|
* Perform {field-name} substitutions ...
|
||||||
*/
|
*/
|
||||||
s = replaceFields(m);
|
s = replaceFields(m, [m objectForKey: @"Replacement"]);
|
||||||
while ((d = [e nextObject]) != nil)
|
while ((d = [e nextObject]) != nil)
|
||||||
{
|
{
|
||||||
[[EcProc cmdLogFile: d] printf: @"%@\n", s];
|
[[EcProc cmdLogFile: d] printf: @"%@\n", s];
|
||||||
|
@ -838,6 +837,11 @@ replaceFields(NSDictionary *fields)
|
||||||
NSString *text;
|
NSString *text;
|
||||||
NSString *subject;
|
NSString *subject;
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Perform {field-name} substitutions ...
|
||||||
|
*/
|
||||||
|
text = replaceFields(m, [m objectForKey: @"Replacement"]);
|
||||||
|
|
||||||
subject = [m objectForKey: @"Subject"];
|
subject = [m objectForKey: @"Subject"];
|
||||||
if (nil == subject)
|
if (nil == subject)
|
||||||
{
|
{
|
||||||
|
@ -859,15 +863,10 @@ replaceFields(NSDictionary *fields)
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
AUTORELEASE(RETAIN(subject));
|
subject = replaceFields(m, subject);
|
||||||
[m removeObjectForKey: @"Subject"];
|
[m removeObjectForKey: @"Subject"];
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
|
||||||
* Perform {field-name} substitutions ...
|
|
||||||
*/
|
|
||||||
text = replaceFields(m);
|
|
||||||
|
|
||||||
/* If we need to send immediately, don't buffer the message.
|
/* If we need to send immediately, don't buffer the message.
|
||||||
*/
|
*/
|
||||||
if (nil != identifier)
|
if (nil != identifier)
|
||||||
|
@ -996,7 +995,7 @@ replaceFields(NSDictionary *fields)
|
||||||
*/
|
*/
|
||||||
t = RETAIN([m objectForKey: @"Timestamp"]);
|
t = RETAIN([m objectForKey: @"Timestamp"]);
|
||||||
[m removeObjectForKey: @"Timestamp"];
|
[m removeObjectForKey: @"Timestamp"];
|
||||||
s = replaceFields(m);
|
s = replaceFields(m, [m objectForKey: @"Replacement"]);
|
||||||
if (t != nil)
|
if (t != nil)
|
||||||
{
|
{
|
||||||
[m setObject: t forKey: @"Timestamp"];
|
[m setObject: t forKey: @"Timestamp"];
|
||||||
|
|
Loading…
Reference in a new issue