X-Git-Url: https://git.kernel.dk/?a=blobdiff_plain;f=stat.c;h=3f51f0cefd18a2695bb3df4bac8b90e872e4cf08;hb=91e538700d0a38f25f3f339b1f8d176a5be4b2ef;hp=84d9eefd842e76ca6a1d96a482ad3fd2a4c251a7;hpb=5ddc670712a9e7d11f915bcbaff388ddfb7471d1;p=fio.git diff --git a/stat.c b/stat.c index 84d9eefd..3f51f0ce 100644 --- a/stat.c +++ b/stat.c @@ -14,7 +14,7 @@ #include "lib/getrusage.h" #include "idletime.h" -static struct fio_mutex *stat_mutex; +struct fio_mutex *stat_mutex; void update_rusage_stat(struct thread_data *td) { @@ -263,7 +263,7 @@ int calc_lat(struct io_stat *is, unsigned long *min, unsigned long *max, void show_group_stats(struct group_run_stats *rs) { char *p1, *p2, *p3, *p4; - const char *ddir_str[] = { " READ", " WRITE" , " TRIM"}; + const char *str[] = { " READ", " WRITE" , " TRIM"}; int i; log_info("\nRun status group %d (all jobs):\n", rs->groupid); @@ -281,7 +281,7 @@ void show_group_stats(struct group_run_stats *rs) log_info("%s: io=%s, aggrb=%s/s, minb=%s/s, maxb=%s/s," " mint=%llumsec, maxt=%llumsec\n", - rs->unified_rw_rep ? " MIXED" : ddir_str[i], + rs->unified_rw_rep ? " MIXED" : str[i], p1, p2, p3, p4, (unsigned long long) rs->min_run[i], (unsigned long long) rs->max_run[i]); @@ -363,7 +363,7 @@ static void display_lat(const char *name, unsigned long min, unsigned long max, static void show_ddir_status(struct group_run_stats *rs, struct thread_stat *ts, int ddir) { - const char *ddir_str[] = { "read ", "write", "trim" }; + const char *str[] = { "read ", "write", "trim" }; unsigned long min, max, runt; unsigned long long bw, iops; double mean, dev; @@ -386,7 +386,7 @@ static void show_ddir_status(struct group_run_stats *rs, struct thread_stat *ts, iops_p = num2str(iops, 6, 1, 0, 0); log_info(" %s: io=%s, bw=%s/s, iops=%s, runt=%6llumsec\n", - rs->unified_rw_rep ? "mixed" : ddir_str[ddir], + rs->unified_rw_rep ? "mixed" : str[ddir], io_p, bw_p, iops_p, (unsigned long long) ts->runtime[ddir]); @@ -896,8 +896,7 @@ static void show_thread_status_terse_v3_v4(struct thread_stat *ts, log_info(";%3.2f%%", io_u_lat_m[i]); /* disk util stats, if any */ - if (is_backend) - show_disk_util(1, NULL); + show_disk_util(1, NULL); /* Additional output if continue_on_error set - default off*/ if (ts->continue_on_error) @@ -1190,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++) @@ -1352,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); }