mirror of
git://git.code.sf.net/p/dhcpd-pools/code
synced 2025-12-16 15:57:00 +00:00
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:
parent
444815f964
commit
46ec42182b
3 changed files with 18 additions and 3 deletions
14
src/output.c
14
src/output.c
|
|
@ -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);
|
||||
|
|
|
|||
|
|
@ -17,5 +17,7 @@
|
|||
"touch_count":1,
|
||||
"touch_percent":10,
|
||||
"status":0
|
||||
},
|
||||
"trivia": {
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -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 $?
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue