add support for alarm component matching

This commit is contained in:
Richard Frith-Macdonald 2020-07-16 14:15:36 +01:00
parent 518f015c35
commit 92212e13e8
2 changed files with 17 additions and 0 deletions

View file

@ -74,6 +74,12 @@
* will match raising, clearing, and also (if ReminderInterval is set)
* reminders about the alarm.
* </desc>
* <term>Component</term>
* <desc>For [EcAlarm] messages, this may be used to match messages by
* the alarm component. Specifying an empty value matches only alarms
* with an empty component part.
* If this is not specified, alarms with any component may match.
* </desc>
* <term>DurationAbove</term>
* <desc>For [EcAlarm] messages, this may be used to match any message
* whose duration in minutes is greater than the supplied integer value.

View file

@ -116,6 +116,7 @@
NSString *serverName;
NSString *severityText;
NSString *text;
NSString *component;
NSDate *timestamp;
NSString *type;
int duration;
@ -148,6 +149,7 @@
RELEASE(severityText);
RELEASE(text);
RELEASE(timestamp);
RELEASE(component);
RELEASE(type);
[super dealloc];
}
@ -833,6 +835,13 @@ replaceFields(NSDictionary *fields, NSString *template)
/* The next set are matches only for alarms.
*/
if (nil != (s = [d objectForKey: @"Component"]))
{
if (NO == [s isEqual: event->component])
{
continue;
}
}
if (nil != (s = [d objectForKey: @"ReminderInterval"]))
{
if (isReminder)
@ -1276,6 +1285,7 @@ replaceFields(NSDictionary *fields, NSString *template)
event->isAlarm = NO;
event->isClear = NO;
event->reminder = -1;
event->component = nil;
if (nil != identifier)
{
event->type = @"Alert";
@ -1292,6 +1302,7 @@ replaceFields(NSDictionary *fields, NSString *template)
[EcAlarm stringFromSeverity: event->severity]);
event->isAlarm = YES;
event->reminder = reminder;
ASSIGN(event->component, [alarm moComponent]);
if ([@"Clear" isEqual: [alarm extra]])
{
event->isClear = YES;