mirror of
https://github.com/gnustep/libs-ec.git
synced 2025-02-15 08:01:42 +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;
|
void *_extra;
|
||||||
BOOL _frozen;
|
BOOL _frozen;
|
||||||
uint8_t _delay;
|
uint8_t _delay;
|
||||||
|
BOOL _audit;
|
||||||
}
|
}
|
||||||
|
|
||||||
/** Creates and returns an autoreleased instance by calling the
|
/** Creates and returns an autoreleased instance by calling the
|
||||||
|
@ -403,6 +404,11 @@ EcMakeManagedObject(NSString *host, NSString *process, NSString *component);
|
||||||
*/
|
*/
|
||||||
- (NSString*) additionalText;
|
- (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 />
|
/** Compares the other object with the receiver for sorting/ordering.<br />
|
||||||
* If both objects have a notificationID set then the result of the
|
* If both objects have a notificationID set then the result of the
|
||||||
* numeric comparison of those IDs is used.<br />
|
* 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;
|
/** Freeze the state of the receiver;
|
||||||
* no more calls to setters are permitted.<br />
|
* 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;
|
- (void) freeze;
|
||||||
|
|
||||||
|
@ -558,6 +564,11 @@ EcMakeManagedObject(NSString *host, NSString *process, NSString *component);
|
||||||
*/
|
*/
|
||||||
- (EcAlarmProbableCause) probableCause;
|
- (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
|
/** 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
|
* queue to allow coalescing with other matching alarms. This defaults to
|
||||||
* zero so that there is no special delay in processing beyond that imposed
|
* 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])
|
if (self == [EcAlarm class])
|
||||||
{
|
{
|
||||||
[self setVersion: 2];
|
[self setVersion: 3];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -387,6 +387,11 @@ EcMakeManagedObject(NSString *host, NSString *process, NSString *component)
|
||||||
return _additionalText;
|
return _additionalText;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
- (BOOL) audit
|
||||||
|
{
|
||||||
|
return _audit;
|
||||||
|
}
|
||||||
|
|
||||||
- (Class) classForCoder
|
- (Class) classForCoder
|
||||||
{
|
{
|
||||||
return [EcAlarm class];
|
return [EcAlarm class];
|
||||||
|
@ -549,7 +554,7 @@ EcMakeManagedObject(NSString *host, NSString *process, NSString *component)
|
||||||
|
|
||||||
- (void) encodeWithCoder: (NSCoder*)aCoder
|
- (void) encodeWithCoder: (NSCoder*)aCoder
|
||||||
{
|
{
|
||||||
[aCoder encodeValuesOfObjCTypes: "iiiii@@@@@@@",
|
[aCoder encodeValuesOfObjCTypes: "iiiii@@@@@@@c",
|
||||||
&_eventType,
|
&_eventType,
|
||||||
&_notificationID,
|
&_notificationID,
|
||||||
&_perceivedSeverity,
|
&_perceivedSeverity,
|
||||||
|
@ -561,7 +566,8 @@ EcMakeManagedObject(NSString *host, NSString *process, NSString *component)
|
||||||
&_specificProblem,
|
&_specificProblem,
|
||||||
&_proposedRepairAction,
|
&_proposedRepairAction,
|
||||||
&_additionalText,
|
&_additionalText,
|
||||||
&_userInfo];
|
&_userInfo,
|
||||||
|
&_audit];
|
||||||
}
|
}
|
||||||
|
|
||||||
- (NSDate*) eventDate
|
- (NSDate*) eventDate
|
||||||
|
@ -750,7 +756,7 @@ EcMakeManagedObject(NSString *host, NSString *process, NSString *component)
|
||||||
&_proposedRepairAction,
|
&_proposedRepairAction,
|
||||||
&_additionalText];
|
&_additionalText];
|
||||||
}
|
}
|
||||||
else
|
else if (version < 3)
|
||||||
{
|
{
|
||||||
[aCoder decodeValuesOfObjCTypes: "iiiii@@@@@@@",
|
[aCoder decodeValuesOfObjCTypes: "iiiii@@@@@@@",
|
||||||
&_eventType,
|
&_eventType,
|
||||||
|
@ -766,6 +772,23 @@ EcMakeManagedObject(NSString *host, NSString *process, NSString *component)
|
||||||
&_additionalText,
|
&_additionalText,
|
||||||
&_userInfo];
|
&_userInfo];
|
||||||
}
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
[aCoder decodeValuesOfObjCTypes: "iiiii@@@@@@@c",
|
||||||
|
&_eventType,
|
||||||
|
&_notificationID,
|
||||||
|
&_perceivedSeverity,
|
||||||
|
&_probableCause,
|
||||||
|
&_trendIndicator,
|
||||||
|
&_managedObject,
|
||||||
|
&_eventDate,
|
||||||
|
&_firstEventDate,
|
||||||
|
&_specificProblem,
|
||||||
|
&_proposedRepairAction,
|
||||||
|
&_additionalText,
|
||||||
|
&_userInfo,
|
||||||
|
&_audit];
|
||||||
|
}
|
||||||
return self;
|
return self;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -879,6 +902,17 @@ EcMakeManagedObject(NSString *host, NSString *process, NSString *component)
|
||||||
return self;
|
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
|
- (void) setDelay: (uint8_t)delay
|
||||||
{
|
{
|
||||||
if (YES == _frozen)
|
if (YES == _frozen)
|
||||||
|
|
|
@ -1640,16 +1640,19 @@ objectsTable_handler(netsnmp_mib_handler *handler,
|
||||||
[prev release];
|
[prev release];
|
||||||
changed = YES;
|
changed = YES;
|
||||||
}
|
}
|
||||||
/* Keep a record of clears which have been acted
|
if (nil != prev || [next audit])
|
||||||
* upon. 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];
|
/* 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
|
else
|
||||||
{
|
{
|
||||||
|
|
23
EcCommand.m
23
EcCommand.m
|
@ -1351,10 +1351,10 @@ desiredName(Desired state)
|
||||||
}
|
}
|
||||||
else if ([self autolaunch] && 0.0 == clientQuitDate)
|
else if ([self autolaunch] && 0.0 == clientQuitDate)
|
||||||
{
|
{
|
||||||
|
ASSIGN(desiredReason, @"autolaunch");
|
||||||
/* If the config says we autolaunch and the last process
|
/* If the config says we autolaunch and the last process
|
||||||
* didn't shut down cleanly, we should start.
|
* didn't shut down cleanly, we should start.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
if (nil == client)
|
if (nil == client)
|
||||||
{
|
{
|
||||||
[self start];
|
[self start];
|
||||||
|
@ -1382,7 +1382,7 @@ desiredName(Desired state)
|
||||||
}
|
}
|
||||||
if (desired != Live)
|
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])
|
if ([l isActive])
|
||||||
{
|
{
|
||||||
problem = @"Started (audit, not a problem)";
|
problem = @"Started (audit information)";
|
||||||
NSLog(@"Started %@", l);
|
NSLog(@"Started %@", l);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
problem = @"Stopped (audit, not a problem)";
|
problem = @"Stopped (audit information)";
|
||||||
NSLog(@"Stopped %@", l);
|
NSLog(@"Stopped %@", l);
|
||||||
}
|
}
|
||||||
managedObject = EcMakeManagedObject(host, @"Command", [l name]);
|
managedObject = EcMakeManagedObject(host, @"Command", [l name]);
|
||||||
|
@ -2214,6 +2214,7 @@ desiredName(Desired state)
|
||||||
perceivedSeverity: EcAlarmSeverityCleared
|
perceivedSeverity: EcAlarmSeverityCleared
|
||||||
proposedRepairAction: @"none"
|
proposedRepairAction: @"none"
|
||||||
additionalText: additional];
|
additionalText: additional];
|
||||||
|
[a setAudit: YES];
|
||||||
[self alarm: a];
|
[self alarm: a];
|
||||||
[self update];
|
[self update];
|
||||||
}
|
}
|
||||||
|
@ -3230,7 +3231,8 @@ NSLog(@"Problem %@", localException);
|
||||||
[s appendFormat:
|
[s appendFormat:
|
||||||
@" %-32.32s is stopping (will restart)\n",
|
@" %-32.32s is stopping (will restart)\n",
|
||||||
[key UTF8String]];
|
[key UTF8String]];
|
||||||
[l setDesired: Live reason: @"manual launch"];
|
[l setDesired: Live
|
||||||
|
reason: @"Console launch command"];
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
@ -3238,7 +3240,8 @@ NSLog(@"Problem %@", localException);
|
||||||
@" %-32.32s will be started\n",
|
@" %-32.32s will be started\n",
|
||||||
[key UTF8String]];
|
[key UTF8String]];
|
||||||
[l resetDelay];
|
[l resetDelay];
|
||||||
[l setDesired: Live reason: @"manual launch"];
|
[l setDesired: Live
|
||||||
|
reason: @"Console launch command"];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -3457,7 +3460,8 @@ NSLog(@"Problem %@", localException);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
[l setDesired: Dead reason: @"manual quit"];
|
[l setDesired: Dead
|
||||||
|
reason: @"Console quit command"];
|
||||||
[l checkAbandonedStartup];
|
[l checkAbandonedStartup];
|
||||||
}
|
}
|
||||||
[self clearAll: [c name]
|
[self clearAll: [c name]
|
||||||
|
@ -3491,7 +3495,8 @@ NSLog(@"Problem %@", localException);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
[l setDesired: Dead reason: @"manual quit"];
|
[l setDesired: Dead
|
||||||
|
reason: @"Console quit command"];
|
||||||
m = [m stringByAppendingFormat:
|
m = [m stringByAppendingFormat:
|
||||||
@"Suspended %@\n", key];
|
@"Suspended %@\n", key];
|
||||||
}
|
}
|
||||||
|
@ -4354,7 +4359,7 @@ NSLog(@"Problem %@", localException);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
[l setDesired: Live reason: @"launch by remote request"];
|
[l setDesired: Live reason: @"remote API request"];
|
||||||
}
|
}
|
||||||
return YES;
|
return YES;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue