mirror of
https://github.com/gnustep/libs-ec.git
synced 2025-02-22 11:21:28 +00:00
Improve clearing alarms from Console
This commit is contained in:
parent
1a29e09cb8
commit
8abf307699
4 changed files with 114 additions and 12 deletions
11
ChangeLog
11
ChangeLog
|
@ -1,3 +1,14 @@
|
||||||
|
2021-12-10 Richard Frith-Macdonald <rfm@gnu.org>
|
||||||
|
|
||||||
|
* EcProcess.h:
|
||||||
|
* EcCommand.m:
|
||||||
|
* EcControl.m:
|
||||||
|
New -clear: method in Command server to clear an alarm in one of its
|
||||||
|
clients. Changed the Control server so that the 'suppress' command
|
||||||
|
clears an alarm locally (suppressing its effects by leaving it
|
||||||
|
raised in the originating client), while the 'clear' command clears
|
||||||
|
the alarm in the originating client.
|
||||||
|
|
||||||
2021-09-13 Richard Frith-Macdonald <rfm@gnu.org>
|
2021-09-13 Richard Frith-Macdonald <rfm@gnu.org>
|
||||||
|
|
||||||
* EcCommand.m:
|
* EcCommand.m:
|
||||||
|
|
14
EcCommand.m
14
EcCommand.m
|
@ -564,6 +564,7 @@ desiredName(Desired state)
|
||||||
procName: (NSString*)name
|
procName: (NSString*)name
|
||||||
addText: (NSString*)additional;
|
addText: (NSString*)additional;
|
||||||
- (void) auditState: (LaunchInfo*)l reason: (NSString*)additional;
|
- (void) auditState: (LaunchInfo*)l reason: (NSString*)additional;
|
||||||
|
- (void) clear: (EcAlarm*)alarm;
|
||||||
- (void) clearAll: (NSString*)name
|
- (void) clearAll: (NSString*)name
|
||||||
addText: (NSString*)additional;
|
addText: (NSString*)additional;
|
||||||
- (void) clearCode: (AlarmCode)ac
|
- (void) clearCode: (AlarmCode)ac
|
||||||
|
@ -3220,6 +3221,19 @@ valgrindLog(NSString *name)
|
||||||
[self update];
|
[self update];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
- (void) clear: (EcAlarm*)alarm
|
||||||
|
{
|
||||||
|
EcClientI *c;
|
||||||
|
|
||||||
|
NSAssert(EcAlarmSeverityCleared == [alarm perceivedSeverity],
|
||||||
|
NSInvalidArgumentException);
|
||||||
|
|
||||||
|
/* Clear the alarm in the named client (if found).
|
||||||
|
*/
|
||||||
|
c = [self findIn: clients byName: [alarm moInstancedProcess]];
|
||||||
|
[[[c obj] ecAlarmDestination] alarm: alarm];
|
||||||
|
}
|
||||||
|
|
||||||
/* Clears all alarms we have raised (or an earlier instance might have raised
|
/* Clears all alarms we have raised (or an earlier instance might have raised
|
||||||
* and failed to clear due to a crash).
|
* and failed to clear due to a crash).
|
||||||
*/
|
*/
|
||||||
|
|
96
EcControl.m
96
EcControl.m
|
@ -885,7 +885,7 @@ static NSString* cmdWord(NSArray* a, unsigned int pos)
|
||||||
{
|
{
|
||||||
m = [NSString stringWithFormat: @"\n%@\n\n", [self ecArchive: nil]];
|
m = [NSString stringWithFormat: @"\n%@\n\n", [self ecArchive: nil]];
|
||||||
}
|
}
|
||||||
else if (comp(wd, @"clear") >= 0 || comp(wd, @"suppress") >= 0)
|
else if (comp(wd, @"clear") >= 0)
|
||||||
{
|
{
|
||||||
NSArray *a = [sink alarms];
|
NSArray *a = [sink alarms];
|
||||||
unsigned index = 1;
|
unsigned index = 1;
|
||||||
|
@ -897,9 +897,6 @@ static NSString* cmdWord(NSArray* a, unsigned int pos)
|
||||||
int n = [wd intValue];
|
int n = [wd intValue];
|
||||||
int i = [a count];
|
int i = [a count];
|
||||||
|
|
||||||
if (n <= 0)
|
|
||||||
{
|
|
||||||
}
|
|
||||||
while (i-- > 0)
|
while (i-- > 0)
|
||||||
{
|
{
|
||||||
alarm = [a objectAtIndex: i];
|
alarm = [a objectAtIndex: i];
|
||||||
|
@ -916,10 +913,31 @@ static NSString* cmdWord(NSArray* a, unsigned int pos)
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
NSArray *hosts = [[commands copy] autorelease];
|
||||||
|
NSUInteger i;
|
||||||
|
|
||||||
m = [NSString stringWithFormat:
|
m = [NSString stringWithFormat:
|
||||||
@"%@Suppressing %@\n", m, alarm];
|
@"%@Clearing %@\n", m, alarm];
|
||||||
alarm = [alarm clear];
|
alarm = [alarm clear];
|
||||||
[self alarm: alarm];
|
|
||||||
|
|
||||||
|
for (i = 0; i < [hosts count]; i++)
|
||||||
|
{
|
||||||
|
CommandInfo *c = [hosts objectAtIndex: i];
|
||||||
|
|
||||||
|
if ([commands indexOfObjectIdenticalTo: c] != NSNotFound)
|
||||||
|
{
|
||||||
|
NS_DURING
|
||||||
|
{
|
||||||
|
[[c obj] clear: alarm];
|
||||||
|
}
|
||||||
|
NS_HANDLER
|
||||||
|
{
|
||||||
|
NSLog(@"Caught: %@", localException);
|
||||||
|
}
|
||||||
|
NS_ENDHANDLER
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (0 == [m length])
|
if (0 == [m length])
|
||||||
|
@ -989,7 +1007,7 @@ static NSString* cmdWord(NSArray* a, unsigned int pos)
|
||||||
if ([wd length] == 0)
|
if ([wd length] == 0)
|
||||||
{
|
{
|
||||||
m = @"Commands are -\n"
|
m = @"Commands are -\n"
|
||||||
@"Help\tAlarms\tArchive\tConfig\tConnect\t"
|
@"Help\tAlarms\tArchive\tClear\tConfig\tConnect\t"
|
||||||
@"Flush\tHost\tList\tMemory\tOn\t"
|
@"Flush\tHost\tList\tMemory\tOn\t"
|
||||||
@"Password\tRepeat\tRestart\tQuit\tSet\tStatus\t"
|
@"Password\tRepeat\tRestart\tQuit\tSet\tStatus\t"
|
||||||
@"Suppress\tTell\tUnset\n\n"
|
@"Suppress\tTell\tUnset\n\n"
|
||||||
|
@ -1034,6 +1052,20 @@ static NSString* cmdWord(NSArray* a, unsigned int pos)
|
||||||
@"the form YYYY-MM-DD being the date at "
|
@"the form YYYY-MM-DD being the date at "
|
||||||
@"which the archive was created.\n";
|
@"which the archive was created.\n";
|
||||||
}
|
}
|
||||||
|
else if (comp(wd, @"Clear") >= 0)
|
||||||
|
{
|
||||||
|
m = @"Clear\n\n"
|
||||||
|
@"Instructs the Control server to clear "
|
||||||
|
@"one or more alarms (identified by numeric\n"
|
||||||
|
@"notificationIDs).\n\n"
|
||||||
|
@"NB. This command clears the alarm(s) in the "
|
||||||
|
@"central records of the Control server,\n"
|
||||||
|
@"and also in the originating process.\n"
|
||||||
|
@"You cannot clear an alarm centrally once "
|
||||||
|
@"it has been suppressed; in that case you\n"
|
||||||
|
@"must issue a 'clear'command directly to "
|
||||||
|
@"the originating process itsself.\n";
|
||||||
|
}
|
||||||
else if (comp(wd, @"Config") >= 0)
|
else if (comp(wd, @"Config") >= 0)
|
||||||
{
|
{
|
||||||
m = @"Config\nInstructs the Control server to re-load "
|
m = @"Config\nInstructs the Control server to re-load "
|
||||||
|
@ -1139,13 +1171,13 @@ static NSString* cmdWord(NSArray* a, unsigned int pos)
|
||||||
else if (comp(wd, @"Suppress") >= 0)
|
else if (comp(wd, @"Suppress") >= 0)
|
||||||
{
|
{
|
||||||
m = @"Suppress\n\n"
|
m = @"Suppress\n\n"
|
||||||
@"Instructs the Control server to clear "
|
@"Instructs the Control server to suppress "
|
||||||
@"one or more alarms (identified by numeric\n"
|
@"one or more alarms (identified by numeric\n"
|
||||||
@"notificationIDs).\n\n"
|
@"notificationIDs).\n\n"
|
||||||
@"NB. This command clears the alarm(s) in the "
|
@"NB. This command clears the alarm(s) in the "
|
||||||
@"central records of the Control server,\n"
|
@"central records of the Control server,\n"
|
||||||
@"NOT in the originating process.\n"
|
@"but NOT in the originating process.\n"
|
||||||
@"This feature means that you can clear "
|
@"This feature means that you can suppress "
|
||||||
@"an alarm centrally while the underlying\n"
|
@"an alarm centrally while the underlying\n"
|
||||||
@"problem has not been corrected and, "
|
@"problem has not been corrected and, "
|
||||||
@"because the originating process has\n"
|
@"because the originating process has\n"
|
||||||
|
@ -1274,8 +1306,7 @@ static NSString* cmdWord(NSArray* a, unsigned int pos)
|
||||||
for (j = 0; j < [svrs count]; j++)
|
for (j = 0; j < [svrs count]; j++)
|
||||||
{
|
{
|
||||||
m = [m stringByAppendingFormat:
|
m = [m stringByAppendingFormat:
|
||||||
@" %2d. %@\n", j,
|
@" %2d. %@\n", j, [svrs objectAtIndex: j]];
|
||||||
[svrs objectAtIndex: j]];
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1424,6 +1455,47 @@ static NSString* cmdWord(NSArray* a, unsigned int pos)
|
||||||
{
|
{
|
||||||
m = [self description];
|
m = [self description];
|
||||||
}
|
}
|
||||||
|
else if (comp(wd, @"suppress") >= 0)
|
||||||
|
{
|
||||||
|
NSArray *a = [sink alarms];
|
||||||
|
unsigned index = 1;
|
||||||
|
|
||||||
|
m = @"";
|
||||||
|
while ([(wd = cmdWord(cmd, index++)) length] > 0)
|
||||||
|
{
|
||||||
|
EcAlarm *alarm = nil;
|
||||||
|
int n = [wd intValue];
|
||||||
|
int i = [a count];
|
||||||
|
|
||||||
|
while (i-- > 0)
|
||||||
|
{
|
||||||
|
alarm = [a objectAtIndex: i];
|
||||||
|
if ([alarm notificationID] == n)
|
||||||
|
{
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
alarm = nil;
|
||||||
|
}
|
||||||
|
if (nil == alarm)
|
||||||
|
{
|
||||||
|
m = [NSString stringWithFormat:
|
||||||
|
@"%@No alarm found with ID %@\n", m, wd];
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
m = [NSString stringWithFormat:
|
||||||
|
@"%@Suppressing %@\n", m, alarm];
|
||||||
|
alarm = [alarm clear];
|
||||||
|
[self alarm: alarm];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (0 == [m length])
|
||||||
|
{
|
||||||
|
m = @"The 'suppress' command requires one or more IDs\n"
|
||||||
|
@"These are the unique identifiers used for working with\n"
|
||||||
|
@"external SNMP monitoring systems.\n";
|
||||||
|
}
|
||||||
|
}
|
||||||
else if (comp(wd, @"tell") >= 0)
|
else if (comp(wd, @"tell") >= 0)
|
||||||
{
|
{
|
||||||
wd = cmdWord(cmd, 1);
|
wd = cmdWord(cmd, 1);
|
||||||
|
|
|
@ -232,6 +232,11 @@ typedef enum {
|
||||||
*/
|
*/
|
||||||
- (oneway void) alarm: (in bycopy EcAlarm*)alarm;
|
- (oneway void) alarm: (in bycopy EcAlarm*)alarm;
|
||||||
|
|
||||||
|
/** Pass an alarm clear to the Command server for forwarding to its
|
||||||
|
* clients for clearing.
|
||||||
|
*/
|
||||||
|
- (oneway void) clear: (in bycopy EcAlarm*)alarm;
|
||||||
|
|
||||||
/** Send a text command to a process owned by the Command server.
|
/** Send a text command to a process owned by the Command server.
|
||||||
*/
|
*/
|
||||||
- (oneway void) command: (in bycopy NSData*)dat
|
- (oneway void) command: (in bycopy NSData*)dat
|
||||||
|
|
Loading…
Reference in a new issue