tmbuf - timed data slicer
tmbuf [-e] [-seconds] [-t seconds]
Tmbuf program accepts input on stdin that might be coming out in
"spurts". The output might be from a monitoring program, or from some
real time data collector. The program captures a time based slice of
data from the input then flushes it to the output and exists.
Because standard UNIX utilities _buffer_ data very well, when we need
to filter a stream, say with grep, as in:
collect_data | grep -v "hack_this_out" | control_expr
what we find is that grep(1) will buffer lots of data. It will in fact
buffer until enough "good" data has come in to flush its output buffer.
So if you get a good "control event" as the first input line you might
not see it until after a few hundred control events make it through the
pipeline. By that time it is way too late.
If we re-code that as
collect_data | while tmbuf >slice ; do
grep -v "hack_this_out" <slice | control_expr
then the process works to feed back in near real time. Tune the tmbuf
options for the delay you need. (Because we've force grep to do a
small window, not wait for more input.)
If the program is called as tmbuf then no options are forced.
Time to stall between lines (default 5 seconds). As long as
lines flow within seconds seconds of each other tmbuf passes
Exit nonzero at EOF, even if some input was processed.
Print only a bried help message.
Total time to delay after first read (default forever). Even
though lines are still coming we have to stop processing after
Show only version information.
tail -0f status | tmbuf -t 30 | Mail -s "found" ksb
When the file status gets some lines appened mail ksb with the
subject "found", only wait 30 seconds before sending the mail
after the first line appears.
conserver -v | pager.ksh
The pager script uses tmbuf internally to slice the output of
the console server.
Output the standard version banner.
There should be an initial timeout, but one can do that in the shell as
tmbuf at nospam.ksb.npcguild.org
mailx(1) Mail(1), tail(1), sh(1), Tee(1l), tee(1), conserver(8l)