mirror of
https://github.com/gnustep/libs-ec.git
synced 2025-02-14 15:41:00 +00:00
add audit alarms and improve message text
This commit is contained in:
parent
3c80be4ecc
commit
394368873e
4 changed files with 75 additions and 22 deletions
13
EcAlarm.h
13
EcAlarm.h
|
@ -351,6 +351,7 @@ EcMakeManagedObject(NSString *host, NSString *process, NSString *component);
|
|||
void *_extra;
|
||||
BOOL _frozen;
|
||||
uint8_t _delay;
|
||||
BOOL _audit;
|
||||
}
|
||||
|
||||
/** Creates and returns an autoreleased instance by calling the
|
||||
|
@ -403,6 +404,11 @@ EcMakeManagedObject(NSString *host, NSString *process, NSString *component);
|
|||
*/
|
||||
- (NSString*) additionalText;
|
||||
|
||||
/** Returns YES if this alarm is flagged as an audit object: a clear which
|
||||
* should be recorded/monitored even without a matching raise of the alarm.
|
||||
*/
|
||||
- (BOOL) audit;
|
||||
|
||||
/** Compares the other object with the receiver for sorting/ordering.<br />
|
||||
* If both objects have a notificationID set then the result of the
|
||||
* numeric comparison of those IDs is used.<br />
|
||||
|
@ -465,7 +471,7 @@ EcMakeManagedObject(NSString *host, NSString *process, NSString *component);
|
|||
|
||||
/** Freeze the state of the receiver;
|
||||
* no more calls to setters are permitted.<br />
|
||||
* Then a frozen alarm is copied, the new copy is <em>not</em> frozen.
|
||||
* When a frozen alarm is copied, the new copy is <em>not</em> frozen.
|
||||
*/
|
||||
- (void) freeze;
|
||||
|
||||
|
@ -558,6 +564,11 @@ EcMakeManagedObject(NSString *host, NSString *process, NSString *component);
|
|||
*/
|
||||
- (EcAlarmProbableCause) probableCause;
|
||||
|
||||
/** Specified if this alarm is to be flagged as an audit object: a clear which
|
||||
* should be recorded/monitored even without a matching raise of the alarm.
|
||||
*/
|
||||
- (void) setAudit: (BOOL)flag;
|
||||
|
||||
/** Sets the number of seconds for which this alarm should be delayed in the
|
||||
* queue to allow coalescing with other matching alarms. This defaults to
|
||||
* zero so that there is no special delay in processing beyond that imposed
|
||||
|
|
42
EcAlarm.m
42
EcAlarm.m
|
@ -113,7 +113,7 @@ EcMakeManagedObject(NSString *host, NSString *process, NSString *component)
|
|||
{
|
||||
if (self == [EcAlarm class])
|
||||
{
|
||||
[self setVersion: 2];
|
||||
[self setVersion: 3];
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -387,6 +387,11 @@ EcMakeManagedObject(NSString *host, NSString *process, NSString *component)
|
|||
return _additionalText;
|
||||
}
|
||||
|
||||
- (BOOL) audit
|
||||
{
|
||||
return _audit;
|
||||
}
|
||||
|
||||
- (Class) classForCoder
|
||||
{
|
||||
return [EcAlarm class];
|
||||
|
@ -549,7 +554,7 @@ EcMakeManagedObject(NSString *host, NSString *process, NSString *component)
|
|||
|
||||
- (void) encodeWithCoder: (NSCoder*)aCoder
|
||||
{
|
||||
[aCoder encodeValuesOfObjCTypes: "iiiii@@@@@@@",
|
||||
[aCoder encodeValuesOfObjCTypes: "iiiii@@@@@@@c",
|
||||
&_eventType,
|
||||
&_notificationID,
|
||||
&_perceivedSeverity,
|
||||
|
@ -561,7 +566,8 @@ EcMakeManagedObject(NSString *host, NSString *process, NSString *component)
|
|||
&_specificProblem,
|
||||
&_proposedRepairAction,
|
||||
&_additionalText,
|
||||
&_userInfo];
|
||||
&_userInfo,
|
||||
&_audit];
|
||||
}
|
||||
|
||||
- (NSDate*) eventDate
|
||||
|
@ -750,7 +756,7 @@ EcMakeManagedObject(NSString *host, NSString *process, NSString *component)
|
|||
&_proposedRepairAction,
|
||||
&_additionalText];
|
||||
}
|
||||
else
|
||||
else if (version < 3)
|
||||
{
|
||||
[aCoder decodeValuesOfObjCTypes: "iiiii@@@@@@@",
|
||||
&_eventType,
|
||||
|
@ -766,6 +772,23 @@ EcMakeManagedObject(NSString *host, NSString *process, NSString *component)
|
|||
&_additionalText,
|
||||
&_userInfo];
|
||||
}
|
||||
else
|
||||
{
|
||||
[aCoder decodeValuesOfObjCTypes: "iiiii@@@@@@@c",
|
||||
&_eventType,
|
||||
&_notificationID,
|
||||
&_perceivedSeverity,
|
||||
&_probableCause,
|
||||
&_trendIndicator,
|
||||
&_managedObject,
|
||||
&_eventDate,
|
||||
&_firstEventDate,
|
||||
&_specificProblem,
|
||||
&_proposedRepairAction,
|
||||
&_additionalText,
|
||||
&_userInfo,
|
||||
&_audit];
|
||||
}
|
||||
return self;
|
||||
}
|
||||
|
||||
|
@ -879,6 +902,17 @@ EcMakeManagedObject(NSString *host, NSString *process, NSString *component)
|
|||
return self;
|
||||
}
|
||||
|
||||
- (void) setAudit: (BOOL)flag
|
||||
{
|
||||
if (YES == _frozen)
|
||||
{
|
||||
[NSException raise: NSInternalInconsistencyException
|
||||
format: @"[%@-%@] called for frozen instance",
|
||||
NSStringFromClass([self class]), NSStringFromSelector(_cmd)];
|
||||
}
|
||||
_audit = (flag ? YES : NO);
|
||||
}
|
||||
|
||||
- (void) setDelay: (uint8_t)delay
|
||||
{
|
||||
if (YES == _frozen)
|
||||
|
|
|
@ -1640,16 +1640,19 @@ objectsTable_handler(netsnmp_mib_handler *handler,
|
|||
[prev release];
|
||||
changed = YES;
|
||||
}
|
||||
/* Keep a record of clears which have been acted
|
||||
* upon. The SNMP stuff doesn't need that, but
|
||||
* any monitoring object may need to be kept
|
||||
* informed.
|
||||
*/
|
||||
if (nil != (prev = [_alarmsCleared member: next]))
|
||||
if (nil != prev || [next audit])
|
||||
{
|
||||
[self clearsRemove: prev];
|
||||
/* Keep a record of clears which have been used
|
||||
* or which need to be recorded for audit purposes.
|
||||
* The SNMP stuff doesn't need that, but any
|
||||
* monitoring object may need to be kept informed.
|
||||
*/
|
||||
if (nil != (prev = [_alarmsCleared member: next]))
|
||||
{
|
||||
[self clearsRemove: prev];
|
||||
}
|
||||
[self clearsPut: next];
|
||||
}
|
||||
[self clearsPut: next];
|
||||
}
|
||||
else
|
||||
{
|
||||
|
|
23
EcCommand.m
23
EcCommand.m
|
@ -1351,10 +1351,10 @@ desiredName(Desired state)
|
|||
}
|
||||
else if ([self autolaunch] && 0.0 == clientQuitDate)
|
||||
{
|
||||
ASSIGN(desiredReason, @"autolaunch");
|
||||
/* If the config says we autolaunch and the last process
|
||||
* didn't shut down cleanly, we should start.
|
||||
*/
|
||||
|
||||
if (nil == client)
|
||||
{
|
||||
[self start];
|
||||
|
@ -1382,7 +1382,7 @@ desiredName(Desired state)
|
|||
}
|
||||
if (desired != Live)
|
||||
{
|
||||
[self setDesired: Live reason: @"restart requested"];
|
||||
[self setDesired: Live reason: @"Console restart command"];
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -2197,12 +2197,12 @@ desiredName(Desired state)
|
|||
*/
|
||||
if ([l isActive])
|
||||
{
|
||||
problem = @"Started (audit, not a problem)";
|
||||
problem = @"Started (audit information)";
|
||||
NSLog(@"Started %@", l);
|
||||
}
|
||||
else
|
||||
{
|
||||
problem = @"Stopped (audit, not a problem)";
|
||||
problem = @"Stopped (audit information)";
|
||||
NSLog(@"Stopped %@", l);
|
||||
}
|
||||
managedObject = EcMakeManagedObject(host, @"Command", [l name]);
|
||||
|
@ -2214,6 +2214,7 @@ desiredName(Desired state)
|
|||
perceivedSeverity: EcAlarmSeverityCleared
|
||||
proposedRepairAction: @"none"
|
||||
additionalText: additional];
|
||||
[a setAudit: YES];
|
||||
[self alarm: a];
|
||||
[self update];
|
||||
}
|
||||
|
@ -3230,7 +3231,8 @@ NSLog(@"Problem %@", localException);
|
|||
[s appendFormat:
|
||||
@" %-32.32s is stopping (will restart)\n",
|
||||
[key UTF8String]];
|
||||
[l setDesired: Live reason: @"manual launch"];
|
||||
[l setDesired: Live
|
||||
reason: @"Console launch command"];
|
||||
}
|
||||
else
|
||||
{
|
||||
|
@ -3238,7 +3240,8 @@ NSLog(@"Problem %@", localException);
|
|||
@" %-32.32s will be started\n",
|
||||
[key UTF8String]];
|
||||
[l resetDelay];
|
||||
[l setDesired: Live reason: @"manual launch"];
|
||||
[l setDesired: Live
|
||||
reason: @"Console launch command"];
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -3457,7 +3460,8 @@ NSLog(@"Problem %@", localException);
|
|||
}
|
||||
else
|
||||
{
|
||||
[l setDesired: Dead reason: @"manual quit"];
|
||||
[l setDesired: Dead
|
||||
reason: @"Console quit command"];
|
||||
[l checkAbandonedStartup];
|
||||
}
|
||||
[self clearAll: [c name]
|
||||
|
@ -3491,7 +3495,8 @@ NSLog(@"Problem %@", localException);
|
|||
}
|
||||
else
|
||||
{
|
||||
[l setDesired: Dead reason: @"manual quit"];
|
||||
[l setDesired: Dead
|
||||
reason: @"Console quit command"];
|
||||
m = [m stringByAppendingFormat:
|
||||
@"Suspended %@\n", key];
|
||||
}
|
||||
|
@ -4354,7 +4359,7 @@ NSLog(@"Problem %@", localException);
|
|||
}
|
||||
else
|
||||
{
|
||||
[l setDesired: Live reason: @"launch by remote request"];
|
||||
[l setDesired: Live reason: @"remote API request"];
|
||||
}
|
||||
return YES;
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue