clfmerge(1)

πŸ’– clfmerge β€” the logtools girlie who merges your Common-Log Format web logs by time-stamp πŸ’–

okay so bestie, pull up a chair because this one is genuinely one of my faves. clfmerge lives in the logtools manual (section 1, obvs) and it's about to make your giant web logs behave. ✨


🌸 SYNOPSIS 🌸

clfmerge [--help | -h] [-b size] [-d] [-v] [file names]

that's it. that's the whole vibe. 🫢


πŸ¦‹ DESCRIPTION πŸ¦‹

so here's the tea: clfmerge exists so you literally never have to reach for sort to merge multiple web log files. never. πŸ’…

picture this β€” big sites have web logs split across multiple files, all sitting in the >100M size range, coming off a whole bunch of machines. for files like that, using something like gnusort to merge them is just not it:

  • the data isn't always entirely in order, so gnusort's merge option doesn't work so well 😭
  • but it's also not in random order, so doing a complete sort would be a total waste πŸ’€
  • and the date field you'd be sorting on is not particularly easy to specify for gnusort β€” she has seen it done, but it was messy πŸ™ˆ

so this program is designed to simply and quickly sort multiple large log files, with no need for temporary storage space and no overly large buffers in memory. the memory footprint is generally only a few megs. no cap. 🌈


πŸŽ€ OVERVIEW πŸŽ€

  • it'll take a number (from 0 to n) of file-names on the command line
  • it opens them for reading and reads CLF format web log data from all of them
  • any lines that don't appear to be in CLF format get rejected and displayed on standard-error. NB, they aren't parsed fully β€” only minimal parsing to determine the date is performed πŸ‘‘

if zero files are specified β€” no error, bestie, it just silently outputs nothing. this is for scripts that use the find command to find log files and which can't be counted on to find any log files. it saves doing an extra check in your shell scripts. so thoughtful of her honestly. πŸ₯Ή

if one file is specified β€” the data gets read into a 1000 line buffer, and it will be removed from the buffer (and displayed on standard output) in date order. this handles the case of web servers which date entries on the connection time but write them to the log at completion time, and thus generate log files that aren't in order. (Netscape web server does this β€” she hasn't checked what other web servers do πŸ‘€).

if more than one file is specified β€” a line will be read from each file, the file that had the earliest time stamp will be read from until it returns a time stamp later than one of the other files. then the file with the earlier time stamp will be read. with multiple files the buffer size is 1000 lines or 100 * the number of files (whichever is larger). when the buffer becomes full the first line will be removed and displayed on standard output. main character buffering behaviour fr fr. ✨


✨ OPTIONS ✨

  • -b buffer-size β€” specify the buffer-size to use. if 0 is specified then it means to disable the sliding-window sorting of the data, which improves the speed. ⚑
  • -d β€” set domain-name mangling to on. this means that if a line starts with as the name of the site that was requested then that would be removed from the start of the line, and the GET / would be changed to GET http://www.company.com/, which allows programs like Webalizer to produce good graphs for large hosting sites. also it will make the domain name in lower case. πŸ”€
  • -v β€” be more verbose. she's yapping and honestly? we love that. πŸ—£οΈ

πŸ’œ EXIT STATUS πŸ’œ

  • 0 β€” No errors πŸŽ‰
  • 1 β€” Bad parameters πŸ™ƒ
  • 2 β€” Can't open one of the specified files 😬
  • 3 β€” Can't write to output πŸ’€

πŸ‘‘ AUTHOR πŸ‘‘

this program, its manual page, and the Debian package were written by Russell Coker <russell@coker.com.au>. iconic of him. 🫢


🌟 SEE ALSO 🌟

go read those next, iykyk. πŸ’–


and that's the whole page bestie! this one's version 0.06, dated and signed off by Russell Coker <russell@coker.com.au> β€” so if you were wondering who to thank for your nicely merged logs, now you know. mwah. πŸ’…πŸŒΈ