logswan

Fast Web log analyzer using probabilistic data structures
Log | Files | Refs | README | LICENSE

commit f121fb90d42f258ef126f4d92aa48c64ba16aee5
parent 73412abefc1b91027ec92bcbcce57c5c415652df
Author: Frederic Cambus <fcambus@users.sourceforge.net>
Date:   Mon, 22 Jun 2015 18:54:01 +0200

Processing hourly distribution of hits

Diffstat:
Msrc/logswan.c | 13++++++++++++-
1 file changed, 12 insertions(+), 1 deletion(-)

diff --git a/src/logswan.c b/src/logswan.c @@ -55,6 +55,9 @@ int isIPv4, isIPv6; int httpStatus[512]; int statusCode; +int hours[24]; +int hour; + struct stat logFileSize; FILE *logFile; @@ -112,9 +115,17 @@ int main (int argc, char *argv[]) { countries[GeoIP_id_by_addr(geoip, parsedLine.remoteHost)]++; } - /* Parse date */ + /* Hourly distribution */ parseDate(&parsedDate, parsedLine.date); + if (parsedDate.hour) { /* Do not feed NULL tokens to atoi */ + hour = atoi(parsedDate.hour); + + if (hour < 24) { + hours[hour] += 1; + } + } + /* Count HTTP status codes occurences */ if (parsedLine.statusCode) { /* Do not feed NULL tokens to strtol */ statusCode = strtol(parsedLine.statusCode, &endptr, 10);