1 .\" Copyright (c) 2008 Poul-Henning Kamp
2 .\" All rights reserved.
4 .\" Redistribution and use in source and binary forms, with or without
5 .\" modification, are permitted provided that the following conditions
7 .\" 1. Redistributions of source code must retain the above copyright
8 .\" notice, this list of conditions and the following disclaimer.
9 .\" 2. Redistributions in binary form must reproduce the above copyright
10 .\" notice, this list of conditions and the following disclaimer in the
11 .\" documentation and/or other materials provided with the distribution.
13 .\" THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
14 .\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
15 .\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
16 .\" ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
17 .\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
18 .\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
19 .\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
20 .\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
21 .\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
22 .\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
31 .Nm fifolog_create , fifolog_write , fifolog_read
32 .Nd "initialize, write, seek and extract data from a fifolog"
35 .Op Fl l Ar record-size
36 .Op Fl r Ar record-count
50 .Op Fl w Ar write-rate
52 .Op Fl z Ar compression
55 Fifologs provide a compact round-robin circular storage for
56 recording text and binary information to permanent storage in a bounded
57 and predictable fashion, time and space wise.
59 A fifolog can be stored either directly on a disk partition or in a
62 The input data stream is encoded, compressed and marked up with
63 timestamps before it is written to storage, such that it is possible
64 to seek out a particular time interval in the stored data, without
65 having to decompress the entire logfile.
70 is used to initialize the first sector of a disk device
71 or file system file to make it a fifolog and should be called only
76 on an existing fifolog will reset it so that
80 will not see the previous contents.
81 (The previous contents are not physically erased, and with a bit
82 of hand-work all but the first record can be easily recovered.)
86 does not already exist,
88 will attempt to create and
90 it to the specified size, defaulting to 86400 records of 512 bytes
95 options do not specify otherwise.
100 will read standard input and write it to the end of the fifolog
101 according to the parameters given.
103 Writes happen whenever the output buffer is filled with compressed
104 data or when either of two timers expire, forcing a partially filled
105 buffer to be written.
107 The first and faster timer,
108 .Fl w Ar write-rate ,
109 forces available data to be written
110 but does not flush and reset the compression dictionary.
111 This timer is intended to minimize the amount of logdata lost in RAM
112 in case of a crash and by default it fires 10 seconds after
115 The second and slower timer,
117 forces a full flush and reset of the compression
118 engine and causes the next record written to be a synchronization
119 point with an uncompressed timestamp, making it possible to start
120 reading the logfile from that record.
121 By default this timer fires a minute after the previous sync.
127 compression level; legal values are zero to nine which is the default.
132 will retrieve records from the fifolog according to the specified
133 parameters and write them either to standard output or the file specified
137 It is possible to specify a start and end time to limit the amount
141 The lower-case variants
147 value, whereas the upper-case variants
151 take human-readable specifications such as
152 .Dq Li "1 hour ago" .
156 option forces timestamps to be formatted as
157 .Dq Li "YYYYMMDDhhmmss"
162 allows the specification of an
166 Finally, records can be filtered such that only records matching the
168 regular expression specified with
171 .Sh IMPLEMENTATION NOTES
172 The data stored in the fifolog consists of three layers, an outer
173 layer that allows searches to synchronization points based on timestamps
174 without having to decompress and decode the actual contents, a
175 compression layer implemented with
177 and an inner serialization and timestamping layer.
179 The exact encoding is described in the
183 Fifolog is particularly well suited for use on Flash based media, where
184 it results in much lower write-wear, than a file system with regular
185 log files rotated with
189 Create a fifolog with 1024*1024 records of 512 bytes:
191 .Dl "fifolog_create -r 10m /tmp/fifolog"
193 Write a single record to this file:
195 .Dl "date | fifolog_writer /tmp/fifolog"
197 Read it back with human readable timestamps:
199 .Dl "fifolog_reader -t /tmp/fifolog"
201 One particular useful use of
205 using a line such as this in
206 .Xr /etc/syslog.conf 5 :
208 .Dl "*.* |fifolog_writer /var/log/syslog_fifolog"
210 The fifolog tools have been liberated from an open source
214 which monitors and controls remote radio navigation
215 transmitters for the Danish Air Traffic Control system.
217 The fifolog tools were written by
218 .An Poul-Henning Kamp .