output: add some trivia data to json output

These are software version, dhcpd conf and leases paths and mtime epoch
timestamps.

Signed-off-by: Sami Kerola <kerolasa@iki.fi>
This commit is contained in:
Sami Kerola 2017-11-14 20:19:18 +00:00
parent 444815f964
commit 46ec42182b
No known key found for this signature in database
GPG key ID: A9553245FDE9B739
3 changed files with 18 additions and 3 deletions

View file

@ -596,7 +596,19 @@ static int output_json(struct conf_t *state, const int print_mac_addreses)
fprintf(outfile, " \"backup_percent\":%g,\n", oh.bup);
}
fprintf(outfile, " \"status\":%d\n", oh.status);
fprintf(outfile, " }"); /* end of summary */
fprintf(outfile, " },\n"); /* end of summary */
fprintf(outfile, " \"trivia\": {\n");
fprintf(outfile, " \"version\":\"%s\",\n", PACKAGE_VERSION);
fprintf(outfile, " \"conf_file_path\":\"%s\",\n", state->dhcpdconf_file);
fprintf(outfile, " \"conf_file_epoch_mtime\":");
dp_time_tool(outfile, state->dhcpdconf_file, 1);
fprintf(outfile, ",\n");
fprintf(outfile, " \"lease_file_path\":\"%s\",\n", state->dhcpdlease_file);
fprintf(outfile, " \"lease_file_epoch_mtime\":");
dp_time_tool(outfile, state->dhcpdlease_file, 1);
fprintf(outfile, "\n");
fprintf(outfile, " }"); /* end of trivia */
}
fprintf(outfile, "\n}\n");
close_outfile(outfile);

View file

@ -17,5 +17,7 @@
"touch_count":1,
"touch_percent":10,
"status":0
},
"trivia": {
}
}

View file

@ -7,7 +7,8 @@ if [ ! -d tests/outputs ]; then
fi
dhcpd-pools -f J -c $top_srcdir/tests/confs/same-twice \
-l $top_srcdir/tests/leases/same-twice \
-o tests/outputs/same-twice-json
-l $top_srcdir/tests/leases/same-twice |
sed '/"version":"/d; /"conf_file_.*":/d; /"lease_file_.*":/d' \
>| tests/outputs/same-twice-json
diff -u $top_srcdir/tests/expected/same-twice-json tests/outputs/same-twice-json
exit $?