/* * haproxy log time reporter * * Copyright 2000-2009 Willy Tarreau * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public License * as published by the Free Software Foundation; either version * 2 of the License, or (at your option) any later version. * */ /* * gcc -O2 -o halog2 halog2.c -Iinclude src/ebtree.c src/eb32tree.c fgets2.c * * Usage: * $0 [ min_delay [ min_count [ field_shift ]]] < haproxy.log * Note: if min_delay < 0, it only outputs lines with status codes 5xx. */ #include #include #include #include #include #include #include #include #include #define ACCEPT_FIELD 6 #define TIME_FIELD 9 #define STATUS_FIELD 10 #define CONN_FIELD 15 #define MAXLINE 16384 #define QBITS 4 #define SKIP_CHAR(p,c) do { while (1) if (!*p) break; else if (*(p++) == c) break; } while (0) /* [0] = err/date, [1] = req, [2] = conn, [3] = resp, [4] = data */ static struct eb_root timers[5] = { EB_ROOT_UNIQUE, EB_ROOT_UNIQUE, EB_ROOT_UNIQUE, EB_ROOT_UNIQUE, EB_ROOT_UNIQUE, }; struct timer { struct eb32_node node; unsigned int count; }; #define FILT_COUNT_ONLY 0x01 #define FILT_INVERT 0x02 #define FILT_QUIET 0x04 #define FILT_ERRORS_ONLY 0x08 #define FILT_ACC_DELAY 0x10 #define FILT_ACC_COUNT 0x20 #define FILT_GRAPH_TIMERS 0x40 #define FILT_PERCENTILE 0x80 #define FILT_TIME_RESP 0x100 #define FILT_INVERT_ERRORS 0x200 #define FILT_INVERT_TIME_RESP 0x400 unsigned int filter = 0; unsigned int filter_invert = 0; const char *line; const char *fgets2(FILE *stream); void die(const char *msg) { fprintf(stderr, "%s" "Usage: halog [-c] [-v] [-gt] [-pct] [-s ] [-e|-E] [-rt|-RT