WatchAlpineLog.mesa
Periodically print the page number of the tail record of the Alpine Log. Just how much log space does Alpine use anyway?
Carl Hauser, April 30, 1985 9:17:41 am PDT
DIRECTORY
BasicTime USING [Now],
IO USING [Error, PutF, rope, time, STREAM],
Commander USING [CommandProc, Register],
CommandTool USING [ArgumentVector, Parse, Failed],
Convert USING [IntFromRope, Error],
Interpreter USING [EvaluateToRope],
Process USING [ Pause, SecondsToTicks],
ProcessExtras USING [CheckForAbort]
;
WatchAlpineLogImpl: CEDAR PROGRAM
IMPORTS BasicTime, Commander, Convert, IO, Process, ProcessExtras, CommandTool, Interpreter
EXPORTS
~ BEGIN
Sampler: PROC [ out: IO.STREAM, sampleInterval: CARDINAL ] ~ {
DO
i: INT;
out.PutF["At %g the tail of the log is at %g \n", IO.time[BasicTime.Now[]], IO.rope[Interpreter.EvaluateToRope[ "LogBasicCoreImpl.chunkTable[LogBasicCoreImpl.tail].chunk.pageRun.firstPage"].result]
! IO.Error => EXIT;
];
FOR i IN [1 .. sampleInterval] DO
ProcessExtras.CheckForAbort[];
Process.Pause[Process.SecondsToTicks[60]];
ENDLOOP;
ENDLOOP;
};
SamplerCommand: Commander.CommandProc = {
[cmd: Commander.Handle] RETURNS [result: REF ANY ← NIL, msg: ROPE ← NIL]
seconds: INT;
secondsCard: CARDINAL;
argv: CommandTool.ArgumentVector
← CommandTool.Parse[cmd ! CommandTool.Failed => {msg ← errorMsg; GO TO oops}];
IF argv.argc # 2 THEN {msg ← "Usage: WatchAlpineLog <seconds>"; GO TO oops};
seconds ← Convert.IntFromRope[argv[1] ! Convert.Error => {msg ← "Bad arg"; GO TO oops}];
IF seconds NOT IN [0..LAST[CARDINAL]] THEN {msg ← "Bad arg"; GO TO oops};
secondsCard ← seconds;
Sampler[cmd.out, secondsCard];
EXITS oops => result ← $Failure;
};
Commander.Register[key: "WatchAlpineLog", proc: SamplerCommand, doc: "Periodically prints the page number of the tail of the Alpine Log"]
END.