logswan

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

commit d793e777898d3614f421c55000af352b74b563c5
parent 163109429f551ff173fdd2bcce0e287e7a5b3e3a
Author: Frederic Cambus <fcambus@users.sourceforge.net>
Date:   Sun, 28 Jun 2015 22:44:36 +0200

Adding hits per protocol in the JSON output

Diffstat:
Msrc/output.c | 13+++++++++++++
1 file changed, 13 insertions(+), 0 deletions(-)

diff --git a/src/output.c b/src/output.c @@ -17,11 +17,17 @@ #include "results.h" char *output(Results results) { + char *protocols[] = { + "HTTP/1.0", + "HTTP/1.1" + }; + json_t *jsonObject = json_object(); json_t *hitsObject = json_object(); json_t *countriesArray = json_array(); json_t *hoursArray = json_array(); json_t *httpStatusArray = json_array(); + json_t *protocolsArray = json_array(); for (int loop=0; loop<255; loop++) { if (results.countries[loop]) { @@ -41,12 +47,19 @@ char *output(Results results) { } } + for (int loop=0; loop<2; loop++) { + if (results.protocols[loop]) { + json_array_append_new(protocolsArray, json_pack("{s:s, s:i}", "data", protocols[loop], "hits", results.protocols[loop])); + } + } + json_object_set_new(hitsObject, "ipv4", json_integer(results.hitsIPv4)); json_object_set_new(hitsObject, "ipv6", json_integer(results.hitsIPv6)); json_object_set_new(hitsObject, "total", json_integer(results.hits)); json_object_set_new(hitsObject, "countries", countriesArray); json_object_set_new(hitsObject, "hours", hoursArray); json_object_set_new(hitsObject, "http_status", httpStatusArray); + json_object_set_new(hitsObject, "protocols", protocolsArray); json_object_set_new(jsonObject, "date", json_string(results.timeStamp)); json_object_set_new(jsonObject, "file_size", json_integer(results.fileSize));