mirror of
https://github.com/gnustep/libs-ec.git
synced 2025-02-22 19:31:53 +00:00
config and alerting improvements
git-svn-id: svn+ssh://svn.gna.org/svn/gnustep/libs/ec/trunk@36355 72102866-910b-0410-8b05-ffd578937521
This commit is contained in:
parent
0cce314dd3
commit
b6a1742a05
3 changed files with 123 additions and 32 deletions
|
@ -1,3 +1,12 @@
|
||||||
|
2013-03-13 Richard Frith-Macdonald <rfm@gnu.org>
|
||||||
|
|
||||||
|
* EcProcess.h:
|
||||||
|
* EcProcess.m:
|
||||||
|
Improve documentation of sequence of calls of configuration update
|
||||||
|
methods and add convenience functionality to support alarming for
|
||||||
|
fatal configuration errors.
|
||||||
|
Add Ecmemoryincrement config to adjust alerting about potential leaks.
|
||||||
|
|
||||||
2013-01-26 Richard Frith-Macdonald <rfm@gnu.org>
|
2013-01-26 Richard Frith-Macdonald <rfm@gnu.org>
|
||||||
|
|
||||||
* EcAlarmDestination.m:
|
* EcAlarmDestination.m:
|
||||||
|
|
64
EcProcess.h
64
EcProcess.h
|
@ -63,6 +63,17 @@
|
||||||
may be overridden by using the 'release' command in the
|
may be overridden by using the 'release' command in the
|
||||||
Console program.
|
Console program.
|
||||||
</desc>
|
</desc>
|
||||||
|
<term>EcMemoryIncrement</term>
|
||||||
|
<desc>
|
||||||
|
This integer value controls the (KBytes) increment in process
|
||||||
|
memory usage after which an alert is generated.<br />
|
||||||
|
If this is not set (or is set to a value less than 1) then
|
||||||
|
a value of 500 is used unless EcMemory is set (in which case
|
||||||
|
the lower value of 20 is used).<br />
|
||||||
|
Setting a higher value make memory leak detection less
|
||||||
|
sensitive (but reduces unnecessary alerts).<br />
|
||||||
|
This may be set on the command line or in Control.plist
|
||||||
|
</desc>
|
||||||
<term>EcRelease</term>
|
<term>EcRelease</term>
|
||||||
<desc>
|
<desc>
|
||||||
This boolean value determines whether checks for memory problems
|
This boolean value determines whether checks for memory problems
|
||||||
|
@ -448,15 +459,19 @@ extern NSString* cmdVersion(NSString *ver);
|
||||||
*/
|
*/
|
||||||
- (void) cmdDebug: (NSString*)fmt, ...;
|
- (void) cmdDebug: (NSString*)fmt, ...;
|
||||||
|
|
||||||
/** Called whenever the user defaults are updated due to a central
|
/** Called whenever the user defaults are updated (which may be due to a
|
||||||
* configuration change (or another defaults system change).<br />
|
* central configuration in additions to other defaults system changes).<br />
|
||||||
* This is also called by -cmdUpdate: even if no configuration
|
* This is automatically called by -cmdUpdate: (even if the user defaults
|
||||||
* actually changed ... in which case the notification argument
|
* database has not actually changed), in this case the notification
|
||||||
* is nil.<br />
|
* argument is nil.<br />
|
||||||
* If you override this to handle configuration changes, don't forget
|
* If you override this to handle configuration changes, don't forget
|
||||||
* to call the superclass implementation.<br />
|
* to call the superclass implementation.<br />
|
||||||
* This method is provided to allow subclasses to control the order
|
* This method is provided to allow subclasses to control the order
|
||||||
* in which defaults changes are handled by them and their superclasses.
|
* in which defaults changes are handled by them and their superclasses.<br />
|
||||||
|
* Generally, this method is for use handling changes in the local
|
||||||
|
* NSUserDefaults database; to handle explict configuration changes from
|
||||||
|
* the central configuration in the Control server, you should usually
|
||||||
|
* override the -cmdUpdated method instead.
|
||||||
*/
|
*/
|
||||||
- (void) cmdDefaultsChanged: (NSNotification*)n;
|
- (void) cmdDefaultsChanged: (NSNotification*)n;
|
||||||
|
|
||||||
|
@ -562,9 +577,30 @@ extern NSString* cmdVersion(NSString *ver);
|
||||||
* defaults system ... so be sure that your implementation calls the
|
* defaults system ... so be sure that your implementation calls the
|
||||||
* superclass implementation (unless you wish to suppress the configuration
|
* superclass implementation (unless you wish to suppress the configuration
|
||||||
* update).<br />
|
* update).<br />
|
||||||
* You may alter the info dictionary prior to passign it to the superclass
|
* You may alter the info dictionary prior to passing it to the superclass
|
||||||
* implementation if you wish to adjust the new configuration before it
|
* implementation if you wish to adjust the new configuration before it
|
||||||
* takes effect.
|
* takes effect.<br />
|
||||||
|
* The order of execution of a configuration update is therefore as follows:
|
||||||
|
* <list>
|
||||||
|
* <item>Any subclass implementation of -cmdUpdate: is entered.
|
||||||
|
* </item>
|
||||||
|
* <item>The base implementation of -cmdUpdate: is entered, the stored
|
||||||
|
* configuration is changed as necessary, the user defaults database is
|
||||||
|
* updated.
|
||||||
|
* </item>
|
||||||
|
* <item>The -cmdDefaultsChanged: method is called (either as a result of
|
||||||
|
* a user defaults update, or directly by the base -cmdUpdate: method.
|
||||||
|
* </item>
|
||||||
|
* <item>The base implementation of the -cmdDefaults: method ends.
|
||||||
|
* </item>
|
||||||
|
* <item>Any subclass implementation of the -cmdDefaults: method ends.
|
||||||
|
* </item>
|
||||||
|
* <item>The -cmdUpdated method is called.
|
||||||
|
* </item>
|
||||||
|
* </list>
|
||||||
|
* You should usually override the -cmdUpdated method to handle configuration
|
||||||
|
* changes, using this method only when you want to check/override changes
|
||||||
|
* before they take effect.
|
||||||
*/
|
*/
|
||||||
- (void) cmdUpdate: (NSMutableDictionary*)info;
|
- (void) cmdUpdate: (NSMutableDictionary*)info;
|
||||||
|
|
||||||
|
@ -576,10 +612,16 @@ extern NSString* cmdVersion(NSString *ver);
|
||||||
* NB. This method will be called even if your implementation of
|
* NB. This method will be called even if your implementation of
|
||||||
* -cmdUpdate: suppresses the actual update. In this situation this
|
* -cmdUpdate: suppresses the actual update. In this situation this
|
||||||
* method will find the configuration unchanged since the previous
|
* method will find the configuration unchanged since the previous
|
||||||
* time that it was called.
|
* time that it was called.<br />
|
||||||
|
* The base implementation of this method does nothing and return nil.<br />
|
||||||
|
* The return value of this method is used to control automatic generation
|
||||||
|
* of alarms for fatal configuration errors. If the return value is nil
|
||||||
|
* (the default), then any configuration error alarm is cleared.
|
||||||
|
* Otherwise, a configuration error alarm will be raised (using the
|
||||||
|
* returned string as the 'additional text' of the alarm), and the
|
||||||
|
* process will be terminated by a call to -cmdQuit: with an argument of 1.
|
||||||
*/
|
*/
|
||||||
- (void) cmdUpdated;
|
- (NSString*) cmdUpdated;
|
||||||
|
|
||||||
|
|
||||||
- (void) log: (NSString*)message type: (EcLogType)t;
|
- (void) log: (NSString*)message type: (EcLogType)t;
|
||||||
|
|
||||||
|
|
82
EcProcess.m
82
EcProcess.m
|
@ -1891,6 +1891,8 @@ NSLog(@"Ignored attempt to set timer interval to %g ... using 10.0", interval);
|
||||||
average = ((average / 1024) + 1) * 1024;
|
average = ((average / 1024) + 1) * 1024;
|
||||||
if (average > memPeak)
|
if (average > memPeak)
|
||||||
{
|
{
|
||||||
|
int inc;
|
||||||
|
|
||||||
/* Alert if the we have peaked above the allowed size.
|
/* Alert if the we have peaked above the allowed size.
|
||||||
*/
|
*/
|
||||||
if (average > (memAllowed * 1024 * 1024))
|
if (average > (memAllowed * 1024 * 1024))
|
||||||
|
@ -1912,24 +1914,29 @@ NSLog(@"Ignored attempt to set timer interval to %g ... using 10.0", interval);
|
||||||
memPeak = size;
|
memPeak = size;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (YES == [cmdDefs boolForKey: @"Memory"])
|
inc = (int)[cmdDefs integerForKey: @"MemoryIncrement"];
|
||||||
{
|
if (inc < 1)
|
||||||
/* We want detailed memory information, so we set the next
|
{
|
||||||
* alerting threshold from 20 to 40 KB above the current
|
if (YES == [cmdDefs boolForKey: @"Memory"])
|
||||||
* peak usage.
|
{
|
||||||
*/
|
/* We want detailed memory information, so we set the next
|
||||||
memPeak = ((memPeak / (20 * 1024)) + 2) * (20 * 1024);
|
* alerting threshold from 20 to 40 KB above the current
|
||||||
}
|
* peak usage.
|
||||||
else
|
*/
|
||||||
{
|
inc = 20;
|
||||||
/* We do not want detailed memory information,
|
}
|
||||||
* so we set the next alerting threshold from
|
else
|
||||||
* 500 to 1000 KB above the current peak usage,
|
{
|
||||||
* ensuring that only serious increases
|
/* We do not want detailed memory information,
|
||||||
* in usage will generate an alert.
|
* so we set the next alerting threshold from
|
||||||
*/
|
* 500 to 1000 KB above the current peak usage,
|
||||||
memPeak = ((memPeak / (500 * 1024)) + 2) * (500 * 1024);
|
* ensuring that only serious increases
|
||||||
}
|
* in usage will generate an alert.
|
||||||
|
*/
|
||||||
|
inc = 500;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
memPeak = ((memPeak / (inc * 1024)) + 2) * (inc * 1024);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
/* Record the latest memory usage.
|
/* Record the latest memory usage.
|
||||||
|
@ -2904,9 +2911,9 @@ NSLog(@"Ignored attempt to set timer interval to %g ... using 10.0", interval);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
- (void) cmdUpdated
|
- (NSString*) cmdUpdated
|
||||||
{
|
{
|
||||||
return;
|
return nil;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -3892,16 +3899,49 @@ NSLog(@"Ignored attempt to set timer interval to %g ... using 10.0", interval);
|
||||||
|
|
||||||
if (nil == cmdConf || [cmdConf isEqual: newConfig] == NO)
|
if (nil == cmdConf || [cmdConf isEqual: newConfig] == NO)
|
||||||
{
|
{
|
||||||
|
NSString *err;
|
||||||
|
|
||||||
NS_DURING
|
NS_DURING
|
||||||
[self cmdUpdate: newConfig];
|
[self cmdUpdate: newConfig];
|
||||||
NS_HANDLER
|
NS_HANDLER
|
||||||
[self cmdError: @"Problem before updating config: %@", localException];
|
[self cmdError: @"Problem before updating config: %@", localException];
|
||||||
NS_ENDHANDLER
|
NS_ENDHANDLER
|
||||||
NS_DURING
|
NS_DURING
|
||||||
[self cmdUpdated];
|
err = [self cmdUpdated];
|
||||||
NS_HANDLER
|
NS_HANDLER
|
||||||
|
err = nil;
|
||||||
[self cmdError: @"Problem after updating config: %@", localException];
|
[self cmdError: @"Problem after updating config: %@", localException];
|
||||||
NS_ENDHANDLER
|
NS_ENDHANDLER
|
||||||
|
if (nil != err)
|
||||||
|
{
|
||||||
|
EcAlarm *a;
|
||||||
|
|
||||||
|
a = [EcAlarm alarmForManagedObject: nil
|
||||||
|
at: nil
|
||||||
|
withEventType: EcAlarmEventTypeProcessingError
|
||||||
|
probableCause: EcAlarmConfigurationOrCustomizationError
|
||||||
|
specificProblem: @"fatal configuration error"
|
||||||
|
perceivedSeverity: EcAlarmSeverityMajor
|
||||||
|
proposedRepairAction: _(@"Correct config (check log for details).")
|
||||||
|
additionalText: err];
|
||||||
|
[self alarm: a];
|
||||||
|
[alarmDestination shutdown];
|
||||||
|
[self cmdQuit: 1];
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
EcAlarm *a;
|
||||||
|
|
||||||
|
a = [EcAlarm alarmForManagedObject: nil
|
||||||
|
at: nil
|
||||||
|
withEventType: EcAlarmEventTypeProcessingError
|
||||||
|
probableCause: EcAlarmConfigurationOrCustomizationError
|
||||||
|
specificProblem: @"fatal configuration error"
|
||||||
|
perceivedSeverity: EcAlarmSeverityCleared
|
||||||
|
proposedRepairAction: nil
|
||||||
|
additionalText: nil];
|
||||||
|
[self alarm: a];
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue