From qmail-return-42080-nelson-l-6ca615d95fcb76f5bb3afdc1a6ef9814=crynwr.com@list.cr.yp.to Wed Feb 02 07:10:03 2000 X-VM-v5-Data: ([nil nil nil nil nil nil nil nil nil] ["2282" "" "1" "February" "2000" "23:08:28" "-0800" "Russ Allbery" "rra@stanford.edu" nil "87" "qmailanalog and current daemontools" "^From:" nil nil "2" nil nil nil nil nil] nil) Return-Path: Delivered-To: nelson-l-6ca615d95fcb76f5bb3afdc1a6ef9814@desk.crynwr.com Received: (qmail 5159 invoked by uid 0); 2 Feb 2000 07:10:03 -0000 Received: from ns.crynwr.com (192.203.178.14) by desk.crynwr.com with SMTP; 2 Feb 2000 07:10:03 -0000 Received: (qmail 11257 invoked by uid 500); 2 Feb 2000 07:09:30 -0000 Delivered-To: nelson-l-6ca615d95fcb76f5bb3afdc1a6ef9814@crynwr.com Received: (qmail 11253 invoked from network); 2 Feb 2000 07:09:30 -0000 Received: from muncher.math.uic.edu (131.193.178.181) by pdam.crynwr.com with SMTP; 2 Feb 2000 07:09:30 -0000 Received: (qmail 22611 invoked by uid 1002); 2 Feb 2000 07:08:58 -0000 Mailing-List: contact qmail-help@list.cr.yp.to; run by ezmlm Precedence: bulk Delivered-To: mailing list qmail@list.cr.yp.to Received: (qmail 22509 invoked from network); 2 Feb 2000 07:08:57 -0000 Received: from windlord.stanford.edu (171.64.12.23) by koobera.math.uic.edu with SMTP; 2 Feb 2000 07:08:57 -0000 Received: (qmail 23603 invoked by uid 50); 2 Feb 2000 07:08:29 -0000 Organization: The Eyrie Message-ID: Lines: 16 User-Agent: Gnus/5.0802 (Gnus v5.8.2) XEmacs/21.1 (Biscayne) MIME-Version: 1.0 Content-Type: multipart/mixed; boundary="=-=-=" From: Russ Allbery To: qmail@list.cr.yp.to Subject: qmailanalog and current daemontools Date: 01 Feb 2000 23:08:28 -0800 --=-=-= qmailanalog wants seconds and fractional seconds (since start of epoch, I suppose, although I don't think it actually matters since I believe all of its calculations are relative). Dan, were you planning on releasing a new version of qmailanalog sometime at or after qmail 2.0? Is the logging format going to change sufficiently that I shouldn't put a lot of time into approving log analysis for 1.03? Attached is a small program based on tai64nlocal that will convert from tai64n format to what qmailanalog expects. -- Russ Allbery (rra@stanford.edu) --=-=-= Content-Disposition: inline; filename=tai64nfrac.c /* $Id$ Convert external TAI64N timestamps to fractional seconds since epoch. Written by Russ Allbery This work is in the public domain. Usage: tai64nfrac < input > output Expects the input stream to be a sequence of lines beginning with @, a timestamp in external TAI64N format, and a space. Replaces the @ and the timestamp with fractional seconds since epoch (1970-01-01 00:00:00 UTC). The input time format is the format written by tai64n and multilog. The output time format is expected by qmailanalog. */ #include /* Read a TAI64N external format timestamp from stdin and write fractional seconds since epoch (TAI, not UTC) to stdout. Return the character after the timestamp. */ int decode(void) { int c; unsigned long u; unsigned long seconds = 0; unsigned long nanoseconds = 0; while ((c = getchar()) != EOF) { u = c - '0'; if (u >= 10) { u = c - 'a'; if (u >= 6) break; u += 10; } seconds <<= 4; seconds += nanoseconds >> 28; nanoseconds &= 0xfffffff; nanoseconds <<= 4; nanoseconds += u; } seconds -= 4611686018427387914ULL; printf("%lu.%lu ", seconds, nanoseconds); return c; } int main(void) { int c; unsigned long seconds; unsigned long nanoseconds; while ((c = getchar()) != EOF) { if (c == '@') c = decode(); while (c != EOF) { putchar(c); if (c == '\n') break; c = getchar(); } } } --=-=-=-- .