Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Alternate JSON implementation adding json-log output format #511

Merged
merged 7 commits into from
Mar 9, 2024
Merged
Show file tree
Hide file tree
Changes from 6 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions src/nfdump/nfdump.c
Original file line number Diff line number Diff line change
Expand Up @@ -153,6 +153,7 @@ static void usage(char *name) {
"\t\t extended Even more information.\n"
"\t\t csv ',' separated, machine parseable output format.\n"
"\t\t json json output format.\n"
"\t\t json-log json log output format (one json record per line).\n"
"\t\t pipe '|' separated legacy machine parseable output format.\n"
"\t\t null no flow records, but statistics output.\n"
"\t\t\tmode may be extended by '6' for full IPv6 listing. e.g.long6, extended6.\n"
Expand Down Expand Up @@ -1072,6 +1073,8 @@ int main(int argc, char **argv) {
break;
case MODE_JSON:
break;
case MODE_JSON_LOG:
break;
}

} // else - no output
Expand Down
3 changes: 3 additions & 0 deletions src/nfdump/nfstat.c
Original file line number Diff line number Diff line change
Expand Up @@ -982,6 +982,9 @@ void PrintElementStat(stat_record_t *sum_stat, outputParams_t *outputParams, Rec
case MODE_JSON:
printf("Not yet implemented output format\n");
break;
case MODE_JSON_LOG:
printf("Not yet implemented output format\n");
break;
}
index += increment;
}
Expand Down
5 changes: 4 additions & 1 deletion src/output/output.c
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,8 @@ printmap_t printmap[MAXFORMATS] = {{"raw", raw_record, raw_prolog, raw_epilog, N
{"bilong", fmt_record, fmt_prolog, fmt_epilog, FORMAT_bilong},
{"nsel", fmt_record, fmt_prolog, fmt_epilog, FORMAT_nsel},
{"nat", fmt_record, fmt_prolog, fmt_epilog, FORMAT_nat},
{"json", flow_record_to_json, json_prolog, json_epilog, NULL},
{"json", flow_record_to_json_human, json_prolog, json_epilog, NULL},
{"json-log", flow_record_to_json_log, null_prolog, null_epilog, NULL},
{"csv", csv_record, csv_prolog, csv_epilog, NULL},
{"null", null_record, null_prolog, null_epilog, NULL},

Expand Down Expand Up @@ -210,6 +211,8 @@ RecordPrinter_t SetupOutputMode(char *print_format, outputParams_t *outputParams
outputParams->mode = MODE_CSV;
} else if (strncasecmp(print_format, "json", MAXMODELEN) == 0) {
outputParams->mode = MODE_JSON;
} else if (strncasecmp(print_format, "json-log", MAXMODELEN) == 0) {
outputParams->mode = MODE_JSON_LOG;
} else {
outputParams->mode = MODE_PLAIN;
}
Expand Down
2 changes: 1 addition & 1 deletion src/output/output.h
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ typedef void (*RecordPrinter_t)(FILE *, recordHandle_t *, int);
typedef void (*PrologPrinter_t)(void);
typedef void (*EpilogPrinter_t)(void);

enum { MODE_PLAIN = 0, MODE_JSON, MODE_CSV };
enum { MODE_PLAIN = 0, MODE_JSON, MODE_CSV, MODE_JSON_LOG };
typedef struct outputParams_s {
bool printPlain;
bool doTag;
Expand Down
Loading