2 * gfio - gui front end for fio - the flexible io tester
4 * Copyright (C) 2012 Stephen M. Cameron <stephenmcameron@gmail.com>
6 * The license below covers all files distributed with fio unless otherwise
7 * noted in the file itself.
9 * This program is free software; you can redistribute it and/or modify
10 * it under the terms of the GNU General Public License version 2 as
11 * published by the Free Software Foundation.
13 * This program is distributed in the hope that it will be useful,
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 * GNU General Public License for more details.
18 * You should have received a copy of the GNU General Public License
19 * along with this program; if not, write to the Free Software
20 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
31 static void gfio_update_thread_status(char *status_message, double perc);
33 #define ARRAYSIZE(x) (sizeof((x)) / (sizeof((x)[0])))
35 typedef void (*clickfunction)(GtkWidget *widget, gpointer data);
37 static void connect_clicked(GtkWidget *widget, gpointer data);
38 static void start_job_clicked(GtkWidget *widget, gpointer data);
40 static struct button_spec {
41 const char *buttontext;
43 const char *tooltiptext;
44 const int start_insensitive;
45 } buttonspeclist[] = {
46 #define CONNECT_BUTTON 0
47 #define START_JOB_BUTTON 1
48 { "Connect", connect_clicked, "Connect to host", 0 },
51 "Send current fio job to fio server to be executed", 1 },
73 GtkWidget *write_iops;
83 GtkWidget *bottomalign;
84 GtkWidget *thread_status_pb;
86 GtkWidget *button[ARRAYSIZE(buttonspeclist)];
87 GtkWidget *scrolled_window;
89 GtkWidget *error_info_bar;
90 GtkWidget *error_label;
92 struct probe_widget probe;
93 struct eta_widget eta;
97 struct fio_client *client;
102 static void clear_ui_info(struct gui *ui)
104 gtk_label_set_text(GTK_LABEL(ui->probe.hostname), "");
105 gtk_label_set_text(GTK_LABEL(ui->probe.os), "");
106 gtk_label_set_text(GTK_LABEL(ui->probe.arch), "");
107 gtk_label_set_text(GTK_LABEL(ui->probe.fio_ver), "");
108 gtk_entry_set_text(GTK_ENTRY(ui->eta.name), "");
109 gtk_entry_set_text(GTK_ENTRY(ui->eta.iotype), "");
110 gtk_entry_set_text(GTK_ENTRY(ui->eta.ioengine), "");
111 gtk_entry_set_text(GTK_ENTRY(ui->eta.iodepth), "");
112 gtk_entry_set_text(GTK_ENTRY(ui->eta.jobs), "");
113 gtk_entry_set_text(GTK_ENTRY(ui->eta.files), "");
114 gtk_entry_set_text(GTK_ENTRY(ui->eta.read_bw), "");
115 gtk_entry_set_text(GTK_ENTRY(ui->eta.read_iops), "");
116 gtk_entry_set_text(GTK_ENTRY(ui->eta.write_bw), "");
117 gtk_entry_set_text(GTK_ENTRY(ui->eta.write_iops), "");
120 static GtkWidget *new_info_entry_in_frame(GtkWidget *box, const char *label)
122 GtkWidget *entry, *frame;
124 frame = gtk_frame_new(label);
125 entry = gtk_entry_new();
126 gtk_entry_set_editable(GTK_ENTRY(entry), 0);
127 gtk_box_pack_start(GTK_BOX(box), frame, TRUE, TRUE, 3);
128 gtk_container_add(GTK_CONTAINER(frame), entry);
133 static GtkWidget *new_info_label_in_frame(GtkWidget *box, const char *label)
135 GtkWidget *label_widget;
138 frame = gtk_frame_new(label);
139 label_widget = gtk_label_new(NULL);
140 gtk_box_pack_start(GTK_BOX(box), frame, TRUE, TRUE, 3);
141 gtk_container_add(GTK_CONTAINER(frame), label_widget);
146 static GtkWidget *create_spinbutton(GtkWidget *hbox, double min, double max, double defval)
148 GtkWidget *button, *box;
150 box = gtk_hbox_new(FALSE, 3);
151 gtk_container_add(GTK_CONTAINER(hbox), box);
153 button = gtk_spin_button_new_with_range(min, max, 1.0);
154 gtk_box_pack_start(GTK_BOX(box), button, TRUE, TRUE, 0);
156 gtk_spin_button_set_update_policy(GTK_SPIN_BUTTON(button), GTK_UPDATE_IF_VALID);
157 gtk_spin_button_set_value(GTK_SPIN_BUTTON(button), defval);
162 static void gfio_set_connected(struct gui *ui, int connected)
165 gtk_widget_set_sensitive(ui->button[START_JOB_BUTTON], 1);
167 gtk_button_set_label(GTK_BUTTON(ui->button[CONNECT_BUTTON]), "Disconnect");
170 gtk_button_set_label(GTK_BUTTON(ui->button[CONNECT_BUTTON]), "Connect");
171 gtk_widget_set_sensitive(ui->button[START_JOB_BUTTON], 0);
175 static void label_set_int_value(GtkWidget *entry, unsigned int val)
179 sprintf(tmp, "%u", val);
180 gtk_label_set_text(GTK_LABEL(entry), tmp);
183 static void entry_set_int_value(GtkWidget *entry, unsigned int val)
187 sprintf(tmp, "%u", val);
188 gtk_entry_set_text(GTK_ENTRY(entry), tmp);
192 #define ALIGN_RIGHT 2
196 GtkTreeViewColumn *tree_view_column(GtkWidget *tree_view, int index, const char *title, unsigned int flags)
198 GtkCellRenderer *renderer;
199 GtkTreeViewColumn *col;
200 double xalign = 0.0; /* left as default */
201 PangoAlignment align;
204 align = (flags & ALIGN_LEFT) ? PANGO_ALIGN_LEFT :
205 (flags & ALIGN_RIGHT) ? PANGO_ALIGN_RIGHT :
207 visible = !(flags & INVISIBLE);
209 renderer = gtk_cell_renderer_text_new();
210 col = gtk_tree_view_column_new();
212 gtk_tree_view_column_set_title(col, title);
213 if (!(flags & UNSORTABLE))
214 gtk_tree_view_column_set_sort_column_id(col, index);
215 gtk_tree_view_column_set_resizable(col, TRUE);
216 gtk_tree_view_column_pack_start(col, renderer, TRUE);
217 gtk_tree_view_column_add_attribute(col, renderer, "text", index);
218 gtk_object_set(GTK_OBJECT(renderer), "alignment", align, NULL);
220 case PANGO_ALIGN_LEFT:
223 case PANGO_ALIGN_CENTER:
226 case PANGO_ALIGN_RIGHT:
230 gtk_cell_renderer_set_alignment(GTK_CELL_RENDERER(renderer), xalign, 0.5);
231 gtk_tree_view_column_set_visible(col, visible);
232 gtk_tree_view_append_column(GTK_TREE_VIEW(tree_view), col);
236 static GtkWidget *gfio_output_clat_percentiles(unsigned int *ovals,
242 GType types[FIO_IO_U_LIST_MAX_LEN];
243 GtkWidget *tree_view;
244 GtkTreeSelection *selection;
249 for (i = 0; i < len; i++)
250 types[i] = G_TYPE_INT;
252 model = gtk_list_store_newv(len, types);
254 tree_view = gtk_tree_view_new_with_model(GTK_TREE_MODEL(model));
255 gtk_widget_set_can_focus(tree_view, FALSE);
257 selection = gtk_tree_view_get_selection(GTK_TREE_VIEW(tree_view));
258 gtk_tree_selection_set_mode(GTK_TREE_SELECTION(selection), GTK_SELECTION_BROWSE);
260 for (i = 0; i < len; i++) {
263 sprintf(fbuf, "%2.2f%%", plist[i].u.f);
264 tree_view_column(tree_view, i, fbuf, ALIGN_RIGHT | UNSORTABLE);
267 gtk_list_store_append(model, &iter);
269 for (i = 0; i < len; i++)
270 gtk_list_store_set(model, &iter, i, ovals[i], -1);
275 static void gfio_show_clat_percentiles(GtkWidget *vbox, struct thread_stat *ts,
278 unsigned int *io_u_plat = ts->io_u_plat[ddir];
279 unsigned long nr = ts->clat_stat[ddir].samples;
280 fio_fp64_t *plist = ts->percentile_list;
281 unsigned int *ovals, len, minv, maxv, scale_down;
283 GtkWidget *tree_view, *frame, *hbox;
286 len = calc_clat_percentiles(io_u_plat, nr, plist, &ovals, &maxv, &minv);
291 * We default to usecs, but if the value range is such that we
292 * should scale down to msecs, do that.
294 if (minv > 2000 && maxv > 99999) {
302 tree_view = gfio_output_clat_percentiles(ovals, plist, len, base, scale_down);
304 sprintf(tmp, "Completion percentiles (%s)", base);
305 frame = gtk_frame_new(tmp);
306 gtk_box_pack_start(GTK_BOX(vbox), frame, FALSE, FALSE, 5);
308 hbox = gtk_hbox_new(FALSE, 3);
309 gtk_container_add(GTK_CONTAINER(frame), hbox);
311 gtk_box_pack_start(GTK_BOX(hbox), tree_view, TRUE, FALSE, 3);
317 static void gfio_show_lat(GtkWidget *vbox, const char *name, unsigned long min,
318 unsigned long max, double mean, double dev)
320 const char *base = "(usec)";
321 GtkWidget *hbox, *label, *frame;
325 if (!usec_to_msec(&min, &max, &mean, &dev))
328 minp = num2str(min, 6, 1, 0);
329 maxp = num2str(max, 6, 1, 0);
331 sprintf(tmp, "%s %s", name, base);
332 frame = gtk_frame_new(tmp);
333 gtk_box_pack_start(GTK_BOX(vbox), frame, FALSE, FALSE, 5);
335 hbox = gtk_hbox_new(FALSE, 3);
336 gtk_container_add(GTK_CONTAINER(frame), hbox);
338 label = new_info_label_in_frame(hbox, "Minimum");
339 gtk_label_set_text(GTK_LABEL(label), minp);
340 label = new_info_label_in_frame(hbox, "Maximum");
341 gtk_label_set_text(GTK_LABEL(label), maxp);
342 label = new_info_label_in_frame(hbox, "Average");
343 sprintf(tmp, "%5.02f", mean);
344 gtk_label_set_text(GTK_LABEL(label), tmp);
345 label = new_info_label_in_frame(hbox, "Standard deviation");
346 sprintf(tmp, "%5.02f", dev);
347 gtk_label_set_text(GTK_LABEL(label), tmp);
358 static void gfio_show_ddir_status(GtkWidget *mbox, struct group_run_stats *rs,
359 struct thread_stat *ts, int ddir)
361 const char *ddir_label[2] = { "Read", "Write" };
362 GtkWidget *frame, *label, *box, *vbox, *main_vbox;
363 unsigned long min, max, runt;
364 unsigned long long bw, iops;
365 unsigned int flags = 0;
367 char *io_p, *bw_p, *iops_p;
370 if (!ts->runtime[ddir])
373 i2p = is_power_of_2(rs->kb_base);
374 runt = ts->runtime[ddir];
376 bw = (1000 * ts->io_bytes[ddir]) / runt;
377 io_p = num2str(ts->io_bytes[ddir], 6, 1, i2p);
378 bw_p = num2str(bw, 6, 1, i2p);
380 iops = (1000 * (uint64_t)ts->total_io_u[ddir]) / runt;
381 iops_p = num2str(iops, 6, 1, 0);
383 box = gtk_hbox_new(FALSE, 3);
384 gtk_box_pack_start(GTK_BOX(mbox), box, TRUE, FALSE, 3);
386 frame = gtk_frame_new(ddir_label[ddir]);
387 gtk_box_pack_start(GTK_BOX(box), frame, FALSE, FALSE, 5);
389 main_vbox = gtk_vbox_new(FALSE, 3);
390 gtk_container_add(GTK_CONTAINER(frame), main_vbox);
392 box = gtk_hbox_new(FALSE, 3);
393 gtk_box_pack_start(GTK_BOX(main_vbox), box, TRUE, FALSE, 3);
395 label = new_info_label_in_frame(box, "IO");
396 gtk_label_set_text(GTK_LABEL(label), io_p);
397 label = new_info_label_in_frame(box, "Bandwidth");
398 gtk_label_set_text(GTK_LABEL(label), bw_p);
399 label = new_info_label_in_frame(box, "IOPS");
400 gtk_label_set_text(GTK_LABEL(label), iops_p);
401 label = new_info_label_in_frame(box, "Runtime (msec)");
402 label_set_int_value(label, ts->runtime[ddir]);
404 if (calc_lat(&ts->bw_stat[ddir], &min, &max, &mean, &dev)) {
405 double p_of_agg = 100.0;
406 const char *bw_str = "KB";
410 p_of_agg = mean * 100 / (double) rs->agg[ddir];
411 if (p_of_agg > 100.0)
415 if (mean > 999999.9) {
423 sprintf(tmp, "Bandwidth (%s)", bw_str);
424 frame = gtk_frame_new(tmp);
425 gtk_box_pack_start(GTK_BOX(main_vbox), frame, FALSE, FALSE, 5);
427 box = gtk_hbox_new(FALSE, 3);
428 gtk_container_add(GTK_CONTAINER(frame), box);
430 label = new_info_label_in_frame(box, "Minimum");
431 label_set_int_value(label, min);
432 label = new_info_label_in_frame(box, "Maximum");
433 label_set_int_value(label, max);
434 label = new_info_label_in_frame(box, "Percentage of jobs");
435 sprintf(tmp, "%3.2f%%", p_of_agg);
436 gtk_label_set_text(GTK_LABEL(label), tmp);
437 label = new_info_label_in_frame(box, "Average");
438 sprintf(tmp, "%5.02f", mean);
439 gtk_label_set_text(GTK_LABEL(label), tmp);
440 label = new_info_label_in_frame(box, "Standard deviation");
441 sprintf(tmp, "%5.02f", dev);
442 gtk_label_set_text(GTK_LABEL(label), tmp);
445 if (calc_lat(&ts->slat_stat[ddir], &min, &max, &mean, &dev))
447 if (calc_lat(&ts->clat_stat[ddir], &min, &max, &mean, &dev))
449 if (calc_lat(&ts->lat_stat[ddir], &min, &max, &mean, &dev))
453 frame = gtk_frame_new("Latency");
454 gtk_box_pack_start(GTK_BOX(main_vbox), frame, FALSE, FALSE, 5);
456 vbox = gtk_vbox_new(FALSE, 3);
457 gtk_container_add(GTK_CONTAINER(frame), vbox);
459 if (flags & GFIO_SLAT)
460 gfio_show_lat(vbox, "Submission latency", min, max, mean, dev);
461 if (flags & GFIO_CLAT)
462 gfio_show_lat(vbox, "Completion latency", min, max, mean, dev);
463 if (flags & GFIO_LAT)
464 gfio_show_lat(vbox, "Total latency", min, max, mean, dev);
467 if (ts->clat_percentiles)
468 gfio_show_clat_percentiles(main_vbox, ts, ddir);
476 static GtkWidget *gfio_output_lat_buckets(double *lat, unsigned int num,
479 GtkWidget *tree_view;
480 GtkTreeSelection *selection;
487 * Check if all are empty, in which case don't bother
489 for (i = 0, skipped = 0; i < num; i++)
496 types = malloc(num * sizeof(GType));
498 for (i = 0; i < num; i++)
499 types[i] = G_TYPE_STRING;
501 model = gtk_list_store_newv(num, types);
505 tree_view = gtk_tree_view_new_with_model(GTK_TREE_MODEL(model));
506 gtk_widget_set_can_focus(tree_view, FALSE);
508 selection = gtk_tree_view_get_selection(GTK_TREE_VIEW(tree_view));
509 gtk_tree_selection_set_mode(GTK_TREE_SELECTION(selection), GTK_SELECTION_BROWSE);
511 for (i = 0; i < num; i++)
512 tree_view_column(tree_view, i, labels[i], ALIGN_RIGHT | UNSORTABLE);
514 gtk_list_store_append(model, &iter);
516 for (i = 0; i < num; i++) {
520 sprintf(fbuf, "0.00");
522 sprintf(fbuf, "%3.2f%%", lat[i]);
524 gtk_list_store_set(model, &iter, i, fbuf, -1);
530 static void gfio_show_latency_buckets(GtkWidget *vbox, struct thread_stat *ts)
532 GtkWidget *box, *frame, *tree_view;
533 double io_u_lat_u[FIO_IO_U_LAT_U_NR];
534 double io_u_lat_m[FIO_IO_U_LAT_M_NR];
535 const char *uranges[] = { "2", "4", "10", "20", "50", "100",
536 "250", "500", "750", "1000", };
537 const char *mranges[] = { "2", "4", "10", "20", "50", "100",
538 "250", "500", "750", "1000", "2000",
541 stat_calc_lat_u(ts, io_u_lat_u);
542 stat_calc_lat_m(ts, io_u_lat_m);
544 tree_view = gfio_output_lat_buckets(io_u_lat_u, FIO_IO_U_LAT_U_NR, uranges);
546 frame = gtk_frame_new("Latency buckets (usec)");
547 gtk_box_pack_start(GTK_BOX(vbox), frame, FALSE, FALSE, 5);
549 box = gtk_hbox_new(FALSE, 3);
550 gtk_container_add(GTK_CONTAINER(frame), box);
551 gtk_box_pack_start(GTK_BOX(box), tree_view, TRUE, FALSE, 3);
554 tree_view = gfio_output_lat_buckets(io_u_lat_m, FIO_IO_U_LAT_M_NR, mranges);
556 frame = gtk_frame_new("Latency buckets (msec)");
557 gtk_box_pack_start(GTK_BOX(vbox), frame, FALSE, FALSE, 5);
559 box = gtk_hbox_new(FALSE, 3);
560 gtk_container_add(GTK_CONTAINER(frame), box);
561 gtk_box_pack_start(GTK_BOX(box), tree_view, TRUE, FALSE, 3);
565 static void gfio_show_cpu_usage(GtkWidget *vbox, struct thread_stat *ts)
567 GtkWidget *box, *frame, *entry;
568 double usr_cpu, sys_cpu;
569 unsigned long runtime;
572 runtime = ts->total_run_time;
574 double runt = (double) runtime;
576 usr_cpu = (double) ts->usr_time * 100 / runt;
577 sys_cpu = (double) ts->sys_time * 100 / runt;
583 frame = gtk_frame_new("OS resources");
584 gtk_box_pack_start(GTK_BOX(vbox), frame, FALSE, FALSE, 5);
586 box = gtk_hbox_new(FALSE, 3);
587 gtk_container_add(GTK_CONTAINER(frame), box);
589 entry = new_info_entry_in_frame(box, "User CPU");
590 sprintf(tmp, "%3.2f%%", usr_cpu);
591 gtk_entry_set_text(GTK_ENTRY(entry), tmp);
592 entry = new_info_entry_in_frame(box, "System CPU");
593 sprintf(tmp, "%3.2f%%", sys_cpu);
594 gtk_entry_set_text(GTK_ENTRY(entry), tmp);
595 entry = new_info_entry_in_frame(box, "Context switches");
596 entry_set_int_value(entry, ts->ctx);
597 entry = new_info_entry_in_frame(box, "Major faults");
598 entry_set_int_value(entry, ts->majf);
599 entry = new_info_entry_in_frame(box, "Minor faults");
600 entry_set_int_value(entry, ts->minf);
602 static void gfio_add_sc_depths_tree(GtkListStore *model,
603 struct thread_stat *ts, unsigned int len,
606 double io_u_dist[FIO_IO_U_MAP_NR];
608 /* Bits 0, and 3-8 */
609 const int add_mask = 0x1f9;
613 stat_calc_dist(ts->io_u_submit, ts->total_submit, io_u_dist);
615 stat_calc_dist(ts->io_u_complete, ts->total_complete, io_u_dist);
617 gtk_list_store_append(model, &iter);
619 gtk_list_store_set(model, &iter, 0, submit ? "Submit" : "Complete", -1);
621 for (i = 1, j = 0; i < len; i++) {
624 if (!(add_mask & (1UL << (i - 1))))
625 sprintf(fbuf, "0.0%%");
627 sprintf(fbuf, "%3.1f%%", io_u_dist[j]);
631 gtk_list_store_set(model, &iter, i, fbuf, -1);
636 static void gfio_add_total_depths_tree(GtkListStore *model,
637 struct thread_stat *ts, unsigned int len)
639 double io_u_dist[FIO_IO_U_MAP_NR];
641 /* Bits 1-6, and 8 */
642 const int add_mask = 0x17e;
645 stat_calc_dist(ts->io_u_map, ts_total_io_u(ts), io_u_dist);
647 gtk_list_store_append(model, &iter);
649 gtk_list_store_set(model, &iter, 0, "Total", -1);
651 for (i = 1, j = 0; i < len; i++) {
654 if (!(add_mask & (1UL << (i - 1))))
655 sprintf(fbuf, "0.0%%");
657 sprintf(fbuf, "%3.1f%%", io_u_dist[j]);
661 gtk_list_store_set(model, &iter, i, fbuf, -1);
666 static void gfio_show_io_depths(GtkWidget *vbox, struct thread_stat *ts)
668 GtkWidget *frame, *box, *tree_view;
669 GtkTreeSelection *selection;
671 GType types[FIO_IO_U_MAP_NR + 1];
674 const char *labels[NR_LABELS] = { "Depth", "0", "1", "2", "4", "8", "16", "32", "64", ">= 64" };
676 frame = gtk_frame_new("IO depths");
677 gtk_box_pack_start(GTK_BOX(vbox), frame, FALSE, FALSE, 5);
679 box = gtk_hbox_new(FALSE, 3);
680 gtk_container_add(GTK_CONTAINER(frame), box);
682 for (i = 0; i < NR_LABELS; i++)
683 types[i] = G_TYPE_STRING;
685 model = gtk_list_store_newv(NR_LABELS, types);
687 tree_view = gtk_tree_view_new_with_model(GTK_TREE_MODEL(model));
688 gtk_widget_set_can_focus(tree_view, FALSE);
690 selection = gtk_tree_view_get_selection(GTK_TREE_VIEW(tree_view));
691 gtk_tree_selection_set_mode(GTK_TREE_SELECTION(selection), GTK_SELECTION_BROWSE);
693 for (i = 0; i < NR_LABELS; i++)
694 tree_view_column(tree_view, i, labels[i], ALIGN_RIGHT | UNSORTABLE);
696 gfio_add_total_depths_tree(model, ts, NR_LABELS);
697 gfio_add_sc_depths_tree(model, ts, NR_LABELS, 1);
698 gfio_add_sc_depths_tree(model, ts, NR_LABELS, 0);
700 gtk_box_pack_start(GTK_BOX(box), tree_view, TRUE, FALSE, 3);
703 static void gfio_display_ts(struct fio_client *client, struct thread_stat *ts,
704 struct group_run_stats *rs)
706 GtkWidget *dialog, *box, *vbox, *entry, *content;
707 struct gui *ui = client->client_data;
711 dialog = gtk_dialog_new_with_buttons("Results", GTK_WINDOW(ui->window),
712 GTK_DIALOG_DESTROY_WITH_PARENT,
713 GTK_STOCK_OK, GTK_RESPONSE_ACCEPT, NULL);
715 g_signal_connect_swapped(dialog, "response",
716 G_CALLBACK(gtk_widget_destroy),
719 content = gtk_dialog_get_content_area(GTK_DIALOG(dialog));
721 vbox = gtk_vbox_new(FALSE, 3);
722 gtk_container_add(GTK_CONTAINER(content), vbox);
724 box = gtk_hbox_new(TRUE, 3);
725 gtk_box_pack_start(GTK_BOX(vbox), box, FALSE, FALSE, 5);
727 entry = new_info_entry_in_frame(box, "Name");
728 gtk_entry_set_text(GTK_ENTRY(entry), ts->name);
729 if (strlen(ts->description)) {
730 entry = new_info_entry_in_frame(box, "Description");
731 gtk_entry_set_text(GTK_ENTRY(entry), ts->description);
733 entry = new_info_entry_in_frame(box, "Group ID");
734 entry_set_int_value(entry, ts->groupid);
735 entry = new_info_entry_in_frame(box, "Jobs");
736 entry_set_int_value(entry, ts->members);
737 entry = new_info_entry_in_frame(box, "Error");
738 entry_set_int_value(entry, ts->error);
739 entry = new_info_entry_in_frame(box, "PID");
740 entry_set_int_value(entry, ts->pid);
742 if (ts->io_bytes[DDIR_READ])
743 gfio_show_ddir_status(vbox, rs, ts, DDIR_READ);
744 if (ts->io_bytes[DDIR_WRITE])
745 gfio_show_ddir_status(vbox, rs, ts, DDIR_WRITE);
747 gfio_show_latency_buckets(vbox, ts);
748 gfio_show_cpu_usage(vbox, ts);
749 gfio_show_io_depths(vbox, ts);
751 gtk_widget_show_all(dialog);
755 static void gfio_text_op(struct fio_client *client, struct fio_net_cmd *cmd)
758 GtkTextBuffer *buffer;
761 buffer = gtk_text_view_get_buffer(GTK_TEXT_VIEW(ui.textview));
763 gtk_text_buffer_get_end_iter(buffer, &end);
764 gtk_text_buffer_insert(buffer, &end, buf, -1);
766 gtk_text_view_scroll_to_iter(GTK_TEXT_VIEW(ui.textview),
767 &end, 0.0, FALSE, 0.0,0.0);
769 fio_client_ops.text_op(client, cmd);
773 static void gfio_disk_util_op(struct fio_client *client, struct fio_net_cmd *cmd)
775 printf("gfio_disk_util_op called\n");
776 fio_client_ops.disk_util(client, cmd);
779 extern int sum_stat_clients;
780 extern struct thread_stat client_ts;
781 extern struct group_run_stats client_gs;
783 static int sum_stat_nr;
785 static void gfio_thread_status_op(struct fio_client *client,
786 struct fio_net_cmd *cmd)
788 struct cmd_ts_pdu *p = (struct cmd_ts_pdu *) cmd->payload;
790 gfio_display_ts(client, &p->ts, &p->rs);
792 if (sum_stat_clients == 1)
795 sum_thread_stats(&client_ts, &p->ts, sum_stat_nr);
796 sum_group_stats(&client_gs, &p->rs);
799 client_ts.groupid = p->ts.groupid;
801 if (++sum_stat_nr == sum_stat_clients) {
802 strcpy(client_ts.name, "All clients");
803 gfio_display_ts(client, &client_ts, &client_gs);
807 static void gfio_group_stats_op(struct fio_client *client,
808 struct fio_net_cmd *cmd)
810 printf("gfio_group_stats_op called\n");
811 fio_client_ops.group_stats(client, cmd);
814 static void gfio_update_eta(struct jobs_eta *je)
826 if (je->eta_sec != INT_MAX && je->elapsed_sec) {
827 perc = (double) je->elapsed_sec / (double) (je->elapsed_sec + je->eta_sec);
828 eta_to_str(eta_str, je->eta_sec);
831 sprintf(tmp, "%u", je->nr_running);
832 gtk_entry_set_text(GTK_ENTRY(ui.eta.jobs), tmp);
833 sprintf(tmp, "%u", je->files_open);
834 gtk_entry_set_text(GTK_ENTRY(ui.eta.files), tmp);
837 if (je->m_rate[0] || je->m_rate[1] || je->t_rate[0] || je->t_rate[1]) {
838 if (je->m_rate || je->t_rate) {
841 mr = num2str(je->m_rate, 4, 0, i2p);
842 tr = num2str(je->t_rate, 4, 0, i2p);
843 gtk_entry_set_text(GTK_ENTRY(ui.eta);
844 p += sprintf(p, ", CR=%s/%s KB/s", tr, mr);
847 } else if (je->m_iops || je->t_iops)
848 p += sprintf(p, ", CR=%d/%d IOPS", je->t_iops, je->m_iops);
850 gtk_entry_set_text(GTK_ENTRY(ui.eta.cr_bw), "---");
851 gtk_entry_set_text(GTK_ENTRY(ui.eta.cr_iops), "---");
852 gtk_entry_set_text(GTK_ENTRY(ui.eta.cw_bw), "---");
853 gtk_entry_set_text(GTK_ENTRY(ui.eta.cw_iops), "---");
856 if (je->eta_sec != INT_MAX && je->nr_running) {
860 if ((!je->eta_sec && !eta_good) || je->nr_ramp == je->nr_running)
861 strcpy(output, "-.-% done");
865 sprintf(output, "%3.1f%% done", perc);
868 rate_str[0] = num2str(je->rate[0], 5, 10, i2p);
869 rate_str[1] = num2str(je->rate[1], 5, 10, i2p);
871 iops_str[0] = num2str(je->iops[0], 4, 1, 0);
872 iops_str[1] = num2str(je->iops[1], 4, 1, 0);
874 gtk_entry_set_text(GTK_ENTRY(ui.eta.read_bw), rate_str[0]);
875 gtk_entry_set_text(GTK_ENTRY(ui.eta.read_iops), iops_str[0]);
876 gtk_entry_set_text(GTK_ENTRY(ui.eta.write_bw), rate_str[1]);
877 gtk_entry_set_text(GTK_ENTRY(ui.eta.write_iops), iops_str[1]);
886 char *dst = output + strlen(output);
888 sprintf(dst, " - %s", eta_str);
891 gfio_update_thread_status(output, perc);
894 static void gfio_probe_op(struct fio_client *client, struct fio_net_cmd *cmd)
896 struct cmd_probe_pdu *probe = (struct cmd_probe_pdu *) cmd->payload;
897 const char *os, *arch;
900 os = fio_get_os_string(probe->os);
904 arch = fio_get_arch_string(probe->arch);
909 client->name = strdup((char *) probe->hostname);
911 gtk_label_set_text(GTK_LABEL(ui.probe.hostname), (char *) probe->hostname);
912 gtk_label_set_text(GTK_LABEL(ui.probe.os), os);
913 gtk_label_set_text(GTK_LABEL(ui.probe.arch), arch);
914 sprintf(buf, "%u.%u.%u", probe->fio_major, probe->fio_minor, probe->fio_patch);
915 gtk_label_set_text(GTK_LABEL(ui.probe.fio_ver), buf);
918 static void gfio_update_thread_status(char *status_message, double perc)
920 static char message[100];
921 const char *m = message;
923 strncpy(message, status_message, sizeof(message) - 1);
924 gtk_progress_bar_set_text(
925 GTK_PROGRESS_BAR(ui.thread_status_pb), m);
926 gtk_progress_bar_set_fraction(
927 GTK_PROGRESS_BAR(ui.thread_status_pb), perc / 100.0);
929 gtk_widget_queue_draw(ui.window);
933 static void gfio_quit_op(struct fio_client *client)
935 struct gui *ui = client->client_data;
937 gfio_set_connected(ui, 0);
940 static void gfio_add_job_op(struct fio_client *client, struct fio_net_cmd *cmd)
942 struct cmd_add_job_pdu *p = (struct cmd_add_job_pdu *) cmd->payload;
943 struct gui *ui = client->client_data;
947 p->iodepth = le32_to_cpu(p->iodepth);
948 p->rw = le32_to_cpu(p->rw);
950 for (i = 0; i < 2; i++) {
951 p->min_bs[i] = le32_to_cpu(p->min_bs[i]);
952 p->max_bs[i] = le32_to_cpu(p->max_bs[i]);
955 p->numjobs = le32_to_cpu(p->numjobs);
956 p->group_reporting = le32_to_cpu(p->group_reporting);
958 gtk_entry_set_text(GTK_ENTRY(ui->eta.name), (gchar *) p->jobname);
959 gtk_entry_set_text(GTK_ENTRY(ui->eta.iotype), ddir_str(p->rw));
960 gtk_entry_set_text(GTK_ENTRY(ui->eta.ioengine), (gchar *) p->ioengine);
962 sprintf(tmp, "%u", p->iodepth);
963 gtk_entry_set_text(GTK_ENTRY(ui->eta.iodepth), tmp);
966 static void gfio_client_timed_out(struct fio_client *client)
968 struct gui *ui = client->client_data;
969 GtkWidget *dialog, *label, *content;
974 gfio_set_connected(ui, 0);
977 sprintf(buf, "Client %s: timeout talking to server.\n", client->hostname);
979 dialog = gtk_dialog_new_with_buttons("Timed out!",
980 GTK_WINDOW(ui->window),
981 GTK_DIALOG_MODAL | GTK_DIALOG_DESTROY_WITH_PARENT,
982 GTK_STOCK_OK, GTK_RESPONSE_OK, NULL);
984 content = gtk_dialog_get_content_area(GTK_DIALOG(dialog));
985 label = gtk_label_new((const gchar *) buf);
986 gtk_container_add(GTK_CONTAINER(content), label);
987 gtk_widget_show_all(dialog);
988 gtk_dialog_set_default_response(GTK_DIALOG(dialog), GTK_RESPONSE_ACCEPT);
990 gtk_dialog_run(GTK_DIALOG(dialog));
991 gtk_widget_destroy(dialog);
996 struct client_ops gfio_client_ops = {
997 .text_op = gfio_text_op,
998 .disk_util = gfio_disk_util_op,
999 .thread_status = gfio_thread_status_op,
1000 .group_stats = gfio_group_stats_op,
1001 .eta = gfio_update_eta,
1002 .probe = gfio_probe_op,
1003 .quit = gfio_quit_op,
1004 .add_job = gfio_add_job_op,
1005 .timed_out = gfio_client_timed_out,
1006 .stay_connected = 1,
1009 static void quit_clicked(__attribute__((unused)) GtkWidget *widget,
1010 __attribute__((unused)) gpointer data)
1015 static void *job_thread(void *arg)
1017 fio_handle_clients(&gfio_client_ops);
1021 static int send_job_files(struct gui *ui)
1025 for (i = 0; i < ui->nr_job_files; i++) {
1026 ret = fio_clients_send_ini(ui->job_files[i]);
1030 free(ui->job_files[i]);
1031 ui->job_files[i] = NULL;
1033 while (i < ui->nr_job_files) {
1034 free(ui->job_files[i]);
1035 ui->job_files[i] = NULL;
1042 static void start_job_thread(struct gui *ui)
1044 if (send_job_files(ui)) {
1045 printf("Yeah, I didn't really like those options too much.\n");
1046 gtk_widget_set_sensitive(ui->button[START_JOB_BUTTON], 1);
1051 static void start_job_clicked(__attribute__((unused)) GtkWidget *widget,
1054 struct gui *ui = data;
1056 gtk_widget_set_sensitive(ui->button[START_JOB_BUTTON], 0);
1057 start_job_thread(ui);
1060 static void file_open(GtkWidget *w, gpointer data);
1062 static void connect_clicked(GtkWidget *widget, gpointer data)
1064 struct gui *ui = data;
1066 if (!ui->connected) {
1067 if (!ui->nr_job_files)
1068 file_open(widget, data);
1069 gtk_progress_bar_set_text(GTK_PROGRESS_BAR(ui->thread_status_pb), "No jobs running");
1070 fio_clients_connect();
1071 pthread_create(&ui->t, NULL, job_thread, NULL);
1072 gfio_set_connected(ui, 1);
1074 fio_clients_terminate();
1075 gfio_set_connected(ui, 0);
1080 static void add_button(struct gui *ui, int i, GtkWidget *buttonbox,
1081 struct button_spec *buttonspec)
1083 ui->button[i] = gtk_button_new_with_label(buttonspec->buttontext);
1084 g_signal_connect(ui->button[i], "clicked", G_CALLBACK (buttonspec->f), ui);
1085 gtk_box_pack_start(GTK_BOX (ui->buttonbox), ui->button[i], FALSE, FALSE, 3);
1086 gtk_widget_set_tooltip_text(ui->button[i], buttonspeclist[i].tooltiptext);
1087 gtk_widget_set_sensitive(ui->button[i], !buttonspec->start_insensitive);
1090 static void add_buttons(struct gui *ui,
1091 struct button_spec *buttonlist,
1096 for (i = 0; i < nbuttons; i++)
1097 add_button(ui, i, ui->buttonbox, &buttonlist[i]);
1100 static void on_info_bar_response(GtkWidget *widget, gint response,
1103 if (response == GTK_RESPONSE_OK) {
1104 gtk_widget_destroy(widget);
1105 ui.error_info_bar = NULL;
1109 void report_error(GError *error)
1111 if (ui.error_info_bar == NULL) {
1112 ui.error_info_bar = gtk_info_bar_new_with_buttons(GTK_STOCK_OK,
1115 g_signal_connect(ui.error_info_bar, "response", G_CALLBACK(on_info_bar_response), NULL);
1116 gtk_info_bar_set_message_type(GTK_INFO_BAR(ui.error_info_bar),
1119 ui.error_label = gtk_label_new(error->message);
1120 GtkWidget *container = gtk_info_bar_get_content_area(GTK_INFO_BAR(ui.error_info_bar));
1121 gtk_container_add(GTK_CONTAINER(container), ui.error_label);
1123 gtk_box_pack_start(GTK_BOX(ui.vbox), ui.error_info_bar, FALSE, FALSE, 0);
1124 gtk_widget_show_all(ui.vbox);
1127 snprintf(buffer, sizeof(buffer), "Failed to open file.");
1128 gtk_label_set(GTK_LABEL(ui.error_label), buffer);
1132 static int get_connection_details(char **host, int *port, int *type,
1135 GtkWidget *dialog, *box, *vbox, *hentry, *hbox, *frame, *pentry, *combo;
1139 dialog = gtk_dialog_new_with_buttons("Connection details",
1140 GTK_WINDOW(ui.window),
1141 GTK_DIALOG_DESTROY_WITH_PARENT,
1142 GTK_STOCK_OK, GTK_RESPONSE_ACCEPT,
1143 GTK_STOCK_CANCEL, GTK_RESPONSE_REJECT, NULL);
1145 frame = gtk_frame_new("Hostname / socket name");
1146 vbox = gtk_dialog_get_content_area(GTK_DIALOG(dialog));
1147 gtk_box_pack_start(GTK_BOX(vbox), frame, FALSE, FALSE, 5);
1149 box = gtk_vbox_new(FALSE, 6);
1150 gtk_container_add(GTK_CONTAINER(frame), box);
1152 hbox = gtk_hbox_new(TRUE, 10);
1153 gtk_box_pack_start(GTK_BOX(box), hbox, FALSE, FALSE, 0);
1154 hentry = gtk_entry_new();
1155 gtk_entry_set_text(GTK_ENTRY(hentry), "localhost");
1156 gtk_box_pack_start(GTK_BOX(hbox), hentry, TRUE, TRUE, 0);
1158 frame = gtk_frame_new("Port");
1159 gtk_box_pack_start(GTK_BOX(vbox), frame, FALSE, FALSE, 5);
1160 box = gtk_vbox_new(FALSE, 10);
1161 gtk_container_add(GTK_CONTAINER(frame), box);
1163 hbox = gtk_hbox_new(TRUE, 4);
1164 gtk_box_pack_start(GTK_BOX(box), hbox, FALSE, FALSE, 0);
1165 pentry = create_spinbutton(hbox, 1, 65535, FIO_NET_PORT);
1167 frame = gtk_frame_new("Type");
1168 gtk_box_pack_start(GTK_BOX(vbox), frame, FALSE, FALSE, 5);
1169 box = gtk_vbox_new(FALSE, 10);
1170 gtk_container_add(GTK_CONTAINER(frame), box);
1172 hbox = gtk_hbox_new(TRUE, 4);
1173 gtk_box_pack_start(GTK_BOX(box), hbox, FALSE, FALSE, 0);
1175 combo = gtk_combo_box_text_new();
1176 gtk_combo_box_text_append_text(GTK_COMBO_BOX_TEXT(combo), "IPv4");
1177 gtk_combo_box_text_append_text(GTK_COMBO_BOX_TEXT(combo), "IPv6");
1178 gtk_combo_box_text_append_text(GTK_COMBO_BOX_TEXT(combo), "local socket");
1179 gtk_combo_box_set_active(GTK_COMBO_BOX(combo), 0);
1181 gtk_container_add(GTK_CONTAINER(hbox), combo);
1183 frame = gtk_frame_new("Options");
1184 gtk_box_pack_start(GTK_BOX(vbox), frame, FALSE, FALSE, 5);
1185 box = gtk_vbox_new(FALSE, 10);
1186 gtk_container_add(GTK_CONTAINER(frame), box);
1188 hbox = gtk_hbox_new(TRUE, 4);
1189 gtk_box_pack_start(GTK_BOX(box), hbox, FALSE, FALSE, 0);
1191 button = gtk_check_button_new_with_label("Auto-spawn fio backend");
1192 gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(button), 1);
1193 gtk_widget_set_tooltip_text(button, "When running fio locally, it is necessary to have the backend running on the same system. If this is checked, gfio will start the backend automatically for you if it isn't already running.");
1194 gtk_box_pack_start(GTK_BOX(hbox), button, FALSE, FALSE, 6);
1196 gtk_widget_show_all(dialog);
1198 if (gtk_dialog_run(GTK_DIALOG(dialog)) != GTK_RESPONSE_ACCEPT) {
1199 gtk_widget_destroy(dialog);
1203 *host = strdup(gtk_entry_get_text(GTK_ENTRY(hentry)));
1204 *port = gtk_spin_button_get_value_as_int(GTK_SPIN_BUTTON(pentry));
1206 typeentry = gtk_combo_box_text_get_active_text(GTK_COMBO_BOX_TEXT(combo));
1207 if (!typeentry || !strncmp(typeentry, "IPv4", 4))
1208 *type = Fio_client_ipv4;
1209 else if (!strncmp(typeentry, "IPv6", 4))
1210 *type = Fio_client_ipv6;
1212 *type = Fio_client_socket;
1215 *server_start = gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(button));
1217 gtk_widget_destroy(dialog);
1221 static void file_open(GtkWidget *w, gpointer data)
1224 GSList *filenames, *fn_glist;
1225 GtkFileFilter *filter;
1227 int port, type, server_start;
1229 dialog = gtk_file_chooser_dialog_new("Open File",
1230 GTK_WINDOW(ui.window),
1231 GTK_FILE_CHOOSER_ACTION_OPEN,
1232 GTK_STOCK_CANCEL, GTK_RESPONSE_CANCEL,
1233 GTK_STOCK_OPEN, GTK_RESPONSE_ACCEPT,
1235 gtk_file_chooser_set_select_multiple(GTK_FILE_CHOOSER(dialog), TRUE);
1237 filter = gtk_file_filter_new();
1238 gtk_file_filter_add_pattern(filter, "*.fio");
1239 gtk_file_filter_add_pattern(filter, "*.job");
1240 gtk_file_filter_add_mime_type(filter, "text/fio");
1241 gtk_file_filter_set_name(filter, "Fio job file");
1242 gtk_file_chooser_set_filter(GTK_FILE_CHOOSER(dialog), filter);
1244 if (gtk_dialog_run(GTK_DIALOG(dialog)) != GTK_RESPONSE_ACCEPT) {
1245 gtk_widget_destroy(dialog);
1249 fn_glist = gtk_file_chooser_get_filenames(GTK_FILE_CHOOSER(dialog));
1251 gtk_widget_destroy(dialog);
1253 if (get_connection_details(&host, &port, &type, &server_start))
1256 filenames = fn_glist;
1257 while (filenames != NULL) {
1258 ui.job_files = realloc(ui.job_files, (ui.nr_job_files + 1) * sizeof(char *));
1259 ui.job_files[ui.nr_job_files] = strdup(filenames->data);
1262 ui.client = fio_client_add_explicit(&gfio_client_ops, host, type, port);
1266 error = g_error_new(g_quark_from_string("fio"), 1,
1267 "Failed to add client %s", host);
1268 report_error(error);
1269 g_error_free(error);
1271 ui.client->client_data = &ui;
1273 g_free(filenames->data);
1274 filenames = g_slist_next(filenames);
1278 g_slist_free(fn_glist);
1281 static void file_save(GtkWidget *w, gpointer data)
1285 dialog = gtk_file_chooser_dialog_new("Save File",
1286 GTK_WINDOW(ui.window),
1287 GTK_FILE_CHOOSER_ACTION_SAVE,
1288 GTK_STOCK_CANCEL, GTK_RESPONSE_CANCEL,
1289 GTK_STOCK_SAVE, GTK_RESPONSE_ACCEPT,
1292 gtk_file_chooser_set_do_overwrite_confirmation(GTK_FILE_CHOOSER(dialog), TRUE);
1293 gtk_file_chooser_set_current_name(GTK_FILE_CHOOSER(dialog), "Untitled document");
1295 if (gtk_dialog_run(GTK_DIALOG(dialog)) == GTK_RESPONSE_ACCEPT) {
1298 filename = gtk_file_chooser_get_filename(GTK_FILE_CHOOSER(dialog));
1299 // save_job_file(filename);
1302 gtk_widget_destroy(dialog);
1305 static void preferences(GtkWidget *w, gpointer data)
1307 GtkWidget *dialog, *frame, *box, **buttons;
1310 dialog = gtk_dialog_new_with_buttons("Preferences",
1311 GTK_WINDOW(ui.window),
1312 GTK_DIALOG_DESTROY_WITH_PARENT,
1313 GTK_STOCK_OK, GTK_RESPONSE_ACCEPT,
1314 GTK_STOCK_CANCEL, GTK_RESPONSE_REJECT,
1317 frame = gtk_frame_new("Debug logging");
1318 gtk_box_pack_start(GTK_BOX(GTK_DIALOG(dialog)->vbox), frame, FALSE, FALSE, 5);
1319 box = gtk_hbox_new(FALSE, 6);
1320 gtk_container_add(GTK_CONTAINER(frame), box);
1322 buttons = malloc(sizeof(GtkWidget *) * FD_DEBUG_MAX);
1324 for (i = 0; i < FD_DEBUG_MAX; i++) {
1325 buttons[i] = gtk_check_button_new_with_label(debug_levels[i].name);
1326 gtk_widget_set_tooltip_text(buttons[i], debug_levels[i].help);
1327 gtk_box_pack_start(GTK_BOX(box), buttons[i], FALSE, FALSE, 6);
1330 gtk_widget_show_all(dialog);
1332 if (gtk_dialog_run(GTK_DIALOG(dialog)) != GTK_RESPONSE_ACCEPT) {
1333 gtk_widget_destroy(dialog);
1337 for (i = 0; i < FD_DEBUG_MAX; i++) {
1340 set = gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(buttons[i]));
1342 fio_debug |= (1UL << i);
1345 gtk_widget_destroy(dialog);
1348 static void about_dialog(GtkWidget *w, gpointer data)
1350 gtk_show_about_dialog(NULL,
1351 "program-name", "gfio",
1352 "comments", "Gtk2 UI for fio",
1354 "version", fio_version_string,
1355 "copyright", "Jens Axboe <axboe@kernel.dk> 2012",
1356 "logo-icon-name", "fio",
1362 static GtkActionEntry menu_items[] = {
1363 { "FileMenuAction", GTK_STOCK_FILE, "File", NULL, NULL, NULL},
1364 { "HelpMenuAction", GTK_STOCK_HELP, "Help", NULL, NULL, NULL},
1365 { "OpenFile", GTK_STOCK_OPEN, NULL, "<Control>O", NULL, G_CALLBACK(file_open) },
1366 { "SaveFile", GTK_STOCK_SAVE, NULL, "<Control>S", NULL, G_CALLBACK(file_save) },
1367 { "Preferences", GTK_STOCK_PREFERENCES, NULL, "<Control>p", NULL, G_CALLBACK(preferences) },
1368 { "Quit", GTK_STOCK_QUIT, NULL, "<Control>Q", NULL, G_CALLBACK(quit_clicked) },
1369 { "About", GTK_STOCK_ABOUT, NULL, NULL, NULL, G_CALLBACK(about_dialog) },
1371 static gint nmenu_items = sizeof(menu_items) / sizeof(menu_items[0]);
1373 static const gchar *ui_string = " \
1375 <menubar name=\"MainMenu\"> \
1376 <menu name=\"FileMenu\" action=\"FileMenuAction\"> \
1377 <menuitem name=\"Open\" action=\"OpenFile\" /> \
1378 <menuitem name=\"Save\" action=\"SaveFile\" /> \
1379 <separator name=\"Separator\"/> \
1380 <menuitem name=\"Preferences\" action=\"Preferences\" /> \
1381 <separator name=\"Separator2\"/> \
1382 <menuitem name=\"Quit\" action=\"Quit\" /> \
1384 <menu name=\"Help\" action=\"HelpMenuAction\"> \
1385 <menuitem name=\"About\" action=\"About\" /> \
1391 static GtkWidget *get_menubar_menu(GtkWidget *window, GtkUIManager *ui_manager)
1393 GtkActionGroup *action_group = gtk_action_group_new("Menu");
1396 action_group = gtk_action_group_new("Menu");
1397 gtk_action_group_add_actions(action_group, menu_items, nmenu_items, 0);
1399 gtk_ui_manager_insert_action_group(ui_manager, action_group, 0);
1400 gtk_ui_manager_add_ui_from_string(GTK_UI_MANAGER(ui_manager), ui_string, -1, &error);
1402 gtk_window_add_accel_group(GTK_WINDOW(window), gtk_ui_manager_get_accel_group(ui_manager));
1403 return gtk_ui_manager_get_widget(ui_manager, "/MainMenu");
1406 void gfio_ui_setup(GtkSettings *settings, GtkWidget *menubar,
1407 GtkWidget *vbox, GtkUIManager *ui_manager)
1409 gtk_box_pack_start(GTK_BOX(vbox), menubar, FALSE, FALSE, 0);
1412 static void init_ui(int *argc, char **argv[], struct gui *ui)
1414 GtkSettings *settings;
1415 GtkUIManager *uimanager;
1416 GtkWidget *menu, *probe, *probe_frame, *probe_box;
1418 memset(ui, 0, sizeof(*ui));
1420 /* Magical g*thread incantation, you just need this thread stuff.
1421 * Without it, the update that happens in gfio_update_thread_status
1422 * doesn't really happen in a timely fashion, you need expose events
1424 if (!g_thread_supported())
1425 g_thread_init(NULL);
1428 gtk_init(argc, argv);
1429 settings = gtk_settings_get_default();
1430 gtk_settings_set_long_property(settings, "gtk_tooltip_timeout", 10, "gfio setting");
1433 ui->window = gtk_window_new(GTK_WINDOW_TOPLEVEL);
1434 gtk_window_set_title(GTK_WINDOW(ui->window), "fio");
1435 gtk_window_set_default_size(GTK_WINDOW(ui->window), 700, 500);
1437 g_signal_connect(ui->window, "delete-event", G_CALLBACK(quit_clicked), NULL);
1438 g_signal_connect(ui->window, "destroy", G_CALLBACK(quit_clicked), NULL);
1440 ui->vbox = gtk_vbox_new(FALSE, 0);
1441 gtk_container_add(GTK_CONTAINER (ui->window), ui->vbox);
1443 uimanager = gtk_ui_manager_new();
1444 menu = get_menubar_menu(ui->window, uimanager);
1445 gfio_ui_setup(settings, menu, ui->vbox, uimanager);
1448 * Set up alignments for widgets at the top of ui,
1449 * align top left, expand horizontally but not vertically
1451 ui->topalign = gtk_alignment_new(0, 0, 1, 0);
1452 ui->topvbox = gtk_vbox_new(FALSE, 3);
1453 gtk_container_add(GTK_CONTAINER(ui->topalign), ui->topvbox);
1454 gtk_box_pack_start(GTK_BOX(ui->vbox), ui->topalign, FALSE, FALSE, 0);
1456 probe = gtk_frame_new("Job");
1457 gtk_box_pack_start(GTK_BOX(ui->topvbox), probe, TRUE, FALSE, 3);
1458 probe_frame = gtk_vbox_new(FALSE, 3);
1459 gtk_container_add(GTK_CONTAINER(probe), probe_frame);
1461 probe_box = gtk_hbox_new(FALSE, 3);
1462 gtk_box_pack_start(GTK_BOX(probe_frame), probe_box, TRUE, FALSE, 3);
1463 ui->probe.hostname = new_info_label_in_frame(probe_box, "Host");
1464 ui->probe.os = new_info_label_in_frame(probe_box, "OS");
1465 ui->probe.arch = new_info_label_in_frame(probe_box, "Architecture");
1466 ui->probe.fio_ver = new_info_label_in_frame(probe_box, "Fio version");
1468 probe_box = gtk_hbox_new(FALSE, 3);
1469 gtk_box_pack_start(GTK_BOX(probe_frame), probe_box, TRUE, FALSE, 3);
1471 ui->eta.name = new_info_entry_in_frame(probe_box, "Name");
1472 ui->eta.iotype = new_info_entry_in_frame(probe_box, "IO");
1473 ui->eta.ioengine = new_info_entry_in_frame(probe_box, "IO Engine");
1474 ui->eta.iodepth = new_info_entry_in_frame(probe_box, "IO Depth");
1475 ui->eta.jobs = new_info_entry_in_frame(probe_box, "Jobs");
1476 ui->eta.files = new_info_entry_in_frame(probe_box, "Open files");
1478 probe_box = gtk_hbox_new(FALSE, 3);
1479 gtk_box_pack_start(GTK_BOX(probe_frame), probe_box, TRUE, FALSE, 3);
1480 ui->eta.read_bw = new_info_entry_in_frame(probe_box, "Read BW");
1481 ui->eta.read_iops = new_info_entry_in_frame(probe_box, "IOPS");
1482 ui->eta.write_bw = new_info_entry_in_frame(probe_box, "Write BW");
1483 ui->eta.write_iops = new_info_entry_in_frame(probe_box, "IOPS");
1486 * Only add this if we have a commit rate
1489 probe_box = gtk_hbox_new(FALSE, 3);
1490 gtk_box_pack_start(GTK_BOX(probe_frame), probe_box, TRUE, FALSE, 3);
1492 ui->eta.cr_bw = new_info_label_in_frame(probe_box, "Commit BW");
1493 ui->eta.cr_iops = new_info_label_in_frame(probe_box, "Commit IOPS");
1495 ui->eta.cw_bw = new_info_label_in_frame(probe_box, "Commit BW");
1496 ui->eta.cw_iops = new_info_label_in_frame(probe_box, "Commit IOPS");
1500 * Add a text box for text op messages
1502 ui->textview = gtk_text_view_new();
1503 ui->text = gtk_text_view_get_buffer(GTK_TEXT_VIEW(ui->textview));
1504 gtk_text_buffer_set_text(ui->text, "", -1);
1505 gtk_text_view_set_editable(GTK_TEXT_VIEW(ui->textview), FALSE);
1506 gtk_text_view_set_cursor_visible(GTK_TEXT_VIEW(ui->textview), FALSE);
1507 ui->scrolled_window = gtk_scrolled_window_new(NULL, NULL);
1508 gtk_scrolled_window_set_policy(GTK_SCROLLED_WINDOW(ui->scrolled_window),
1509 GTK_POLICY_AUTOMATIC, GTK_POLICY_AUTOMATIC);
1510 gtk_container_add(GTK_CONTAINER(ui->scrolled_window), ui->textview);
1511 gtk_box_pack_start(GTK_BOX(ui->vbox), ui->scrolled_window,
1515 * Set up alignments for widgets at the bottom of ui,
1516 * align bottom left, expand horizontally but not vertically
1518 ui->bottomalign = gtk_alignment_new(0, 1, 1, 0);
1519 ui->buttonbox = gtk_hbox_new(FALSE, 0);
1520 gtk_container_add(GTK_CONTAINER(ui->bottomalign), ui->buttonbox);
1521 gtk_box_pack_start(GTK_BOX(ui->vbox), ui->bottomalign,
1524 add_buttons(ui, buttonspeclist, ARRAYSIZE(buttonspeclist));
1527 * Set up thread status progress bar
1529 ui->thread_status_pb = gtk_progress_bar_new();
1530 gtk_progress_bar_set_fraction(GTK_PROGRESS_BAR(ui->thread_status_pb), 0.0);
1531 gtk_progress_bar_set_text(GTK_PROGRESS_BAR(ui->thread_status_pb), "No connections");
1532 gtk_container_add(GTK_CONTAINER(ui->buttonbox), ui->thread_status_pb);
1535 gtk_widget_show_all(ui->window);
1538 int main(int argc, char *argv[], char *envp[])
1540 if (initialize_fio(envp))
1542 if (fio_init_options())
1545 init_ui(&argc, &argv, &ui);
1547 gdk_threads_enter();
1549 gdk_threads_leave();