summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSteve ODriscoll <sodriscoll@nexgenstorage.com>2015-01-06 12:00:27 -0700
committerMohamad Ayyash <mkayyash@google.com>2015-03-06 17:58:13 -0800
commit0a24a7391078256a4481cab56afb27d58da28768 (patch)
treedb080f8f6d63c8c60fcb4f2143b02a54380ec81f
parentfa52915e33b0685acfec16fae664dfbf728359ad (diff)
downloadfio-0a24a7391078256a4481cab56afb27d58da28768.tar.gz
Add timestamp to json output
Modified by Jens to add humanly readable time as well. Signed-off-by: Jens Axboe <axboe@fb.com>
-rw-r--r--stat.c11
1 files changed, 10 insertions, 1 deletions
diff --git a/stat.c b/stat.c
index bae33385..3f51f0ce 100644
--- a/stat.c
+++ b/stat.c
@@ -1189,7 +1189,6 @@ void __show_run_stats(void)
int unit_base_warned = 0;
struct json_object *root = NULL;
struct json_array *array = NULL;
-
runstats = malloc(sizeof(struct group_run_stats) * (groupid + 1));
for (i = 0; i < groupid + 1; i++)
@@ -1351,8 +1350,18 @@ void __show_run_stats(void)
if (output_format == FIO_OUTPUT_NORMAL)
log_info("\n");
else if (output_format == FIO_OUTPUT_JSON) {
+ char time_buf[64];
+ time_t time_p;
+
+ time(&time_p);
+ os_ctime_r((const time_t *) &time_p, time_buf,
+ sizeof(time_buf));
+ time_buf[strlen(time_buf) - 1] = '\0';
+
root = json_create_object();
json_object_add_value_string(root, "fio version", fio_version_string);
+ json_object_add_value_int(root, "timestamp", time_p);
+ json_object_add_value_string(root, "time", time_buf);
array = json_create_array();
json_object_add_value_array(root, "jobs", array);
}