logswan

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

commit 8752273b1466728338b8ce16f4d9fa7be0b6b05c
parent 7a95a769d6bcff3afda6cf5285820f3be08c6ba8
Author: Frederic Cambus <fcambus@users.sourceforge.net>
Date:   Sun, 28 Jun 2015 23:40:22 +0200

Counting HTTP methods occurrences

Diffstat:
Msrc/logswan.c | 21++++++++++++++++++++-
Msrc/results.h | 1+
2 files changed, 21 insertions(+), 1 deletion(-)

diff --git a/src/logswan.c b/src/logswan.c @@ -61,11 +61,23 @@ const char *errstr; int getoptFlag; int main (int argc, char *argv[]) { + char *methods[] = { + "OPTIONS", + "GET", + "HEAD", + "POST", + "PUT", + "DELETE", + "TRACE", + "CONNECT", + "PATCH" + }; + char *protocols[] = { "HTTP/1.0", "HTTP/1.1" }; - + printf("-------------------------------------------------------------------------------\n" \ " Logswan (c) by Frederic Cambus 2015 \n" \ "-------------------------------------------------------------------------------\n\n"); @@ -142,12 +154,19 @@ int main (int argc, char *argv[]) { /* Parse request */ parseRequest(&parsedRequest, parsedLine.resource); + for (int loop = 0; loop<9; loop++) { + if (!strcmp(methods[loop], parsedRequest.method)) { + results.methods[loop] ++; + } + } + for (int loop = 0; loop<2; loop++) { if (!strcmp(protocols[loop], parsedRequest.protocol)) { results.protocols[loop] ++; } } + /* Count HTTP status codes occurences */ if (parsedLine.statusCode) { statusCode = strtonum(parsedLine.statusCode, 0, STATUS_CODE_MAX-1, &errstr); diff --git a/src/results.h b/src/results.h @@ -30,6 +30,7 @@ struct results { double runtime; char timeStamp[20]; uint64_t protocols[2]; + uint64_t methods[9]; }; typedef struct results Results;