BB Unix Network Monitor - Message
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
{bb} Serializing the BBOUT logfile
- To: bb@bb4.com
- Subject: {bb} Serializing the BBOUT logfile
- From: brent.mccrackin@bell.ca
- Date: Mon, 21 Jun 2004 17:43:22 -0400
- Content-class: urn:content-classes:message
- Content-transfer-encoding: 8bit
- Content-type: text/plain; charset=us-ascii
- Reply-to: bb@bb4.com
- Sender: owner-bb@bb4.com
- Thread-index: AcRX2MX/eAXS9S7tSfO5WtyR6saOog==
- Thread-topic: Serializing the BBOUT logfile
I've identified a problem with the runbb.sh script and the redirection
of the various scripts to the BBOUT logfile which at times makes parsing
the logfile for relevant data difficult or impossible.
When one of the 'backgrounded' scripts is started and redirected to
BBOUT, it opens the file with a pointer to the end of the file at the
time it starts. As the script writes to BBOUT, it keeps track of its
own pointer of the location in the logfile that it is writing to. It
never re-checks the logfile to make sure its at the end of the the file
as it writes. This is evidenced when another script writes to the BBOUT
log file with its OWN pointer to where the end of file was when it was
started. The various scripts end up overwriting each other, and some
logged entries can be lost completely.
I've worked up a solution that helps clean up the BBOUT logfile so its
readable and all entries are in chronological order.
In runbb.sh, right after bbdef.sh is loaded (and $BBOUT is defined) add
this command:
exec 1>>$BBOUT
This redirects all STDOUT output to the logfile defined in the $BBOUT
variable. STDOUT is kept nice and serial by being a first-in first-out
buffer. All echos from this point forward will be dumped into $BBOUT
through STDOUT.
The next step is to go through the rest of the script and remove all
occurrences of '>> $BBOUT' from the script. All backgrounded scripts
started from runbb will now have their output dumped to $BBOUT by way of
STDOUT. Leave everything that redirects STDERR to STDOUT, '2>&1', in
the scripts so that those messages are caught as well.
To get the console messages to display, they now need to be redirected
to STDERR instead of STDOUT.
In places where two identical echos appear, (one would have been
redirected to $BBOUT, but its been removed now), just redirect one to
STDERR.
EG:
echo "Starting Big Brother Daemon (bbd)" # This entry goes
into $BBOUT
echo "Starting Big Brother Daemon (bbd)" >&2 # This entry will
appear on the console
The entries that have the date prepended to them for the BBOUT logfile
need to have the redirection removed, and the other echo redirected to
STDERR. Either way will work, but having the date appear in BBOUT will
let you know when the system was last started.
EG:
echo "Starting the Big Brother System & Network monitor..." >&2 #
Console message
echo "`date`: Starting Big Brother..." #
$BBOUT Logged message
STDERR from any other command run in runbb.sh will appear on the
console, while STDOUT will appear in the BBOUT logfile (unless otherwise
redirected).
The end result is that no log entry in BBOUT is overwritten by any of
the other script, in chronological order.
This has been tested to work on Solaris and Linux on the systems that I
have. I don't know about any other operating systems, though. It may
need further testing and refinement to remain maximally compatible
across all OS's, since runbb.sh is the master script for the whole
system.
---
Brent B McCrackin
UNIX Systems Specialist - Bell Sympatico
Brent.McCrackin@Bell.ca PH: 416-353-0692
"Serenity through viciousness."
--
=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-==-=-=-=-=-=-=-=-=-=-=-=
To unsubscribe from this list, or to subscribe to the bb-digest list
send e-mail to mailto:majordomo@bb4.com with unsubscribe bb -and/or-
subscribe bb-digest in the BODY of the message.
Home |
Main Index |
Thread Index