Don't output json headers for fio backend
[fio.git] / stat.c
diff --git a/stat.c b/stat.c
index 2c218158b8cd61aa2780acb6d412e7a42b4bb5b4..da3ad2a22412dcadba647e7b5cee0250e6cfdec9 100644 (file)
--- a/stat.c
+++ b/stat.c
@@ -832,7 +832,7 @@ static void add_ddir_status_json(struct thread_stat *ts,
        unsigned int len, minv, maxv;
        int i;
        const char *ddirname[] = {"read", "write", "trim"};
-       struct json_object *dir_object, *tmp_object, *percentile_object;
+       struct json_object *dir_object, *tmp_object, *percentile_object, *clat_bins_object;
        char buf[120];
        double p_of_agg = 100.0;
 
@@ -903,6 +903,18 @@ static void add_ddir_status_json(struct thread_stat *ts,
                json_object_add_value_int(percentile_object, (const char *)buf, ovals[i]);
        }
 
+       if (output_format & FIO_OUTPUT_JSON_PLUS) {
+               clat_bins_object = json_create_object();
+               json_object_add_value_object(tmp_object, "bins", clat_bins_object);
+               for(i = 0; i < FIO_IO_U_PLAT_NR; i++) {
+                       snprintf(buf, sizeof(buf), "%d", i);
+                       json_object_add_value_int(clat_bins_object, (const char *)buf, ts->io_u_plat[ddir][i]);
+               }
+               json_object_add_value_int(clat_bins_object, "FIO_IO_U_PLAT_BITS", FIO_IO_U_PLAT_BITS);
+               json_object_add_value_int(clat_bins_object, "FIO_IO_U_PLAT_VAL", FIO_IO_U_PLAT_VAL);
+               json_object_add_value_int(clat_bins_object, "FIO_IO_U_PLAT_NR", FIO_IO_U_PLAT_NR);
+       }
+
        if (!calc_lat(&ts->lat_stat[ddir], &min, &max, &mean, &dev)) {
                min = max = 0;
                mean = dev = 0.0;
@@ -1083,9 +1095,10 @@ static struct json_object *show_thread_status_json(struct thread_stat *ts,
 
        /* ETA Info */
        je = get_jobs_eta(1, &size);
-       json_object_add_value_int(root, "eta", je->eta_sec);
-       json_object_add_value_int(root, "elapsed", je->elapsed_sec);
-
+       if (je) {
+               json_object_add_value_int(root, "eta", je->eta_sec);
+               json_object_add_value_int(root, "elapsed", je->elapsed_sec);
+       }
 
        add_ddir_status_json(ts, rs, DDIR_READ, root);
        add_ddir_status_json(ts, rs, DDIR_WRITE, root);
@@ -1172,7 +1185,7 @@ static struct json_object *show_thread_status_json(struct thread_stat *ts,
 
                if (len) {
                        struct json_object *block, *percentile_object, *states;
-                       int state, i;
+                       int state;
                        block = json_create_object();
                        json_object_add_value_object(root, "block", block);
 
@@ -1599,7 +1612,7 @@ void __show_run_stats(void)
                                show_thread_status_normal(ts, rs, &output[__FIO_OUTPUT_NORMAL]);
                }
        }
-       if (output_format & FIO_OUTPUT_JSON) {
+       if (!is_backend && (output_format & FIO_OUTPUT_JSON)) {
                /* disk util stats, if any */
                show_disk_util(1, root, &output[__FIO_OUTPUT_JSON]);
 
@@ -1627,15 +1640,14 @@ void __show_run_stats(void)
                show_idle_prof_stats(FIO_OUTPUT_NORMAL, NULL, &output[__FIO_OUTPUT_NORMAL]);
        }
 
-       for (i = 0; i < FIO_OUTPUT_NR; i++)
+       for (i = 0; i < FIO_OUTPUT_NR; i++) {
                buf_output_flush(&output[i]);
+               buf_output_free(&output[i]);
+       }
 
        log_info_flush();
        free(runstats);
        free(threadstats);
-
-       for (i = 0; i < FIO_OUTPUT_NR; i++)
-               buf_output_free(&output[i]);
 }
 
 void show_run_stats(void)