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 gfio_set_connected(struct gui *ui, int connected)
105 gtk_widget_set_sensitive(ui->button[START_JOB_BUTTON], 1);
107 gtk_button_set_label(GTK_BUTTON(ui->button[CONNECT_BUTTON]), "Disconnect");
110 gtk_button_set_label(GTK_BUTTON(ui->button[CONNECT_BUTTON]), "Connect");
111 gtk_widget_set_sensitive(ui->button[START_JOB_BUTTON], 0);
115 static void gfio_text_op(struct fio_client *client,
116 FILE *f, __u16 pdu_len, const char *buf)
119 GtkTextBuffer *buffer;
122 buffer = gtk_text_view_get_buffer(GTK_TEXT_VIEW(ui.textview));
124 gtk_text_buffer_get_end_iter(buffer, &end);
125 gtk_text_buffer_insert(buffer, &end, buf, -1);
127 gtk_text_view_scroll_to_iter(GTK_TEXT_VIEW(ui.textview),
128 &end, 0.0, FALSE, 0.0,0.0);
130 fio_client_ops.text_op(client, f, pdu_len, buf);
134 static void gfio_disk_util_op(struct fio_client *client, struct fio_net_cmd *cmd)
136 printf("gfio_disk_util_op called\n");
137 fio_client_ops.disk_util(client, cmd);
140 static void gfio_thread_status_op(struct fio_net_cmd *cmd)
142 printf("gfio_thread_status_op called\n");
143 fio_client_ops.thread_status(cmd);
146 static void gfio_group_stats_op(struct fio_net_cmd *cmd)
148 printf("gfio_group_stats_op called\n");
149 fio_client_ops.group_stats(cmd);
152 static void gfio_update_eta(struct jobs_eta *je)
164 if (je->eta_sec != INT_MAX && je->elapsed_sec) {
165 perc = (double) je->elapsed_sec / (double) (je->elapsed_sec + je->eta_sec);
166 eta_to_str(eta_str, je->eta_sec);
169 sprintf(tmp, "%u", je->nr_running);
170 gtk_label_set_text(GTK_LABEL(ui.eta.jobs), tmp);
171 sprintf(tmp, "%u", je->files_open);
172 gtk_label_set_text(GTK_LABEL(ui.eta.files), tmp);
175 if (je->m_rate[0] || je->m_rate[1] || je->t_rate[0] || je->t_rate[1]) {
176 if (je->m_rate || je->t_rate) {
179 mr = num2str(je->m_rate, 4, 0, i2p);
180 tr = num2str(je->t_rate, 4, 0, i2p);
181 gtk_label_set_text(GTK_LABEL(ui.eta.
182 p += sprintf(p, ", CR=%s/%s KB/s", tr, mr);
185 } else if (je->m_iops || je->t_iops)
186 p += sprintf(p, ", CR=%d/%d IOPS", je->t_iops, je->m_iops);
188 gtk_label_set_text(GTK_LABEL(ui.eta.cr_bw), "---");
189 gtk_label_set_text(GTK_LABEL(ui.eta.cr_iops), "---");
190 gtk_label_set_text(GTK_LABEL(ui.eta.cw_bw), "---");
191 gtk_label_set_text(GTK_LABEL(ui.eta.cw_iops), "---");
194 if (je->eta_sec != INT_MAX && je->nr_running) {
198 if ((!je->eta_sec && !eta_good) || je->nr_ramp == je->nr_running)
199 strcpy(output, "-.-% done");
203 sprintf(output, "%3.1f%% done", perc);
206 rate_str[0] = num2str(je->rate[0], 5, 10, i2p);
207 rate_str[1] = num2str(je->rate[1], 5, 10, i2p);
209 iops_str[0] = num2str(je->iops[0], 4, 1, 0);
210 iops_str[1] = num2str(je->iops[1], 4, 1, 0);
212 gtk_label_set_text(GTK_LABEL(ui.eta.read_bw), rate_str[0]);
213 gtk_label_set_text(GTK_LABEL(ui.eta.read_iops), iops_str[0]);
214 gtk_label_set_text(GTK_LABEL(ui.eta.write_bw), rate_str[1]);
215 gtk_label_set_text(GTK_LABEL(ui.eta.write_iops), iops_str[1]);
224 char *dst = output + strlen(output);
226 sprintf(dst, " - %s", eta_str);
229 gfio_update_thread_status(output, perc);
232 static void gfio_eta_op(struct fio_client *client, struct fio_net_cmd *cmd)
234 struct jobs_eta *je = (struct jobs_eta *) cmd->payload;
235 struct client_eta *eta = (struct client_eta *) (uintptr_t) cmd->tag;
237 client->eta_in_flight = NULL;
238 flist_del_init(&client->eta_list);
240 fio_client_convert_jobs_eta(je);
241 fio_client_sum_jobs_eta(&eta->eta, je);
242 fio_client_dec_jobs_eta(eta, gfio_update_eta);
245 static void gfio_probe_op(struct fio_client *client, struct fio_net_cmd *cmd)
247 struct cmd_probe_pdu *probe = (struct cmd_probe_pdu *) cmd->payload;
248 const char *os, *arch;
251 os = fio_get_os_string(probe->os);
255 arch = fio_get_arch_string(probe->arch);
260 client->name = strdup((char *) probe->hostname);
262 gtk_label_set_text(GTK_LABEL(ui.probe.hostname), (char *) probe->hostname);
263 gtk_label_set_text(GTK_LABEL(ui.probe.os), os);
264 gtk_label_set_text(GTK_LABEL(ui.probe.arch), arch);
265 sprintf(buf, "%u.%u.%u", probe->fio_major, probe->fio_minor, probe->fio_patch);
266 gtk_label_set_text(GTK_LABEL(ui.probe.fio_ver), buf);
269 static void gfio_update_thread_status(char *status_message, double perc)
271 static char message[100];
272 const char *m = message;
274 strncpy(message, status_message, sizeof(message) - 1);
275 gtk_progress_bar_set_text(
276 GTK_PROGRESS_BAR(ui.thread_status_pb), m);
277 gtk_progress_bar_set_fraction(
278 GTK_PROGRESS_BAR(ui.thread_status_pb), perc / 100.0);
280 gtk_widget_queue_draw(ui.window);
284 static void gfio_quit_op(struct fio_client *client)
286 struct gui *ui = client->client_data;
288 gfio_set_connected(ui, 0);
291 static void gfio_add_job_op(struct fio_client *client, struct fio_net_cmd *cmd)
293 struct cmd_add_job_pdu *p = (struct cmd_add_job_pdu *) cmd->payload;
294 struct gui *ui = client->client_data;
298 p->iodepth = le32_to_cpu(p->iodepth);
299 p->rw = le32_to_cpu(p->rw);
301 for (i = 0; i < 2; i++) {
302 p->min_bs[i] = le32_to_cpu(p->min_bs[i]);
303 p->max_bs[i] = le32_to_cpu(p->max_bs[i]);
306 p->numjobs = le32_to_cpu(p->numjobs);
307 p->group_reporting = le32_to_cpu(p->group_reporting);
309 gtk_label_set_text(GTK_LABEL(ui->eta.name), (gchar *) p->jobname);
310 gtk_label_set_text(GTK_LABEL(ui->eta.iotype), ddir_str(p->rw));
311 gtk_label_set_text(GTK_LABEL(ui->eta.ioengine), (gchar *) p->ioengine);
313 sprintf(tmp, "%u", p->iodepth);
314 gtk_label_set_text(GTK_LABEL(ui->eta.iodepth), tmp);
317 static void gfio_client_timed_out(struct fio_client *client)
319 struct gui *ui = client->client_data;
320 GtkWidget *dialog, *label, *content;
325 gfio_set_connected(ui, 0);
327 sprintf(buf, "Client %s: timeout talking to server.\n", client->hostname);
329 dialog = gtk_dialog_new_with_buttons("Timed out!",
330 GTK_WINDOW(ui->window),
331 GTK_DIALOG_MODAL | GTK_DIALOG_DESTROY_WITH_PARENT,
332 GTK_STOCK_OK, GTK_RESPONSE_OK, NULL);
334 content = gtk_dialog_get_content_area(GTK_DIALOG(dialog));
335 label = gtk_label_new((const gchar *) buf);
336 gtk_container_add(GTK_CONTAINER(content), label);
337 gtk_widget_show_all(dialog);
338 gtk_dialog_set_default_response(GTK_DIALOG(dialog), GTK_RESPONSE_ACCEPT);
340 gtk_dialog_run(GTK_DIALOG(dialog));
341 gtk_widget_destroy(dialog);
346 struct client_ops gfio_client_ops = {
347 .text_op = gfio_text_op,
348 .disk_util = gfio_disk_util_op,
349 .thread_status = gfio_thread_status_op,
350 .group_stats = gfio_group_stats_op,
352 .probe = gfio_probe_op,
353 .quit = gfio_quit_op,
354 .add_job = gfio_add_job_op,
355 .timed_out = gfio_client_timed_out,
359 static void quit_clicked(__attribute__((unused)) GtkWidget *widget,
360 __attribute__((unused)) gpointer data)
365 static void *job_thread(void *arg)
367 fio_handle_clients(&gfio_client_ops);
371 static int send_job_files(struct gui *ui)
375 for (i = 0; i < ui->nr_job_files; i++) {
376 ret = fio_clients_send_ini(ui->job_files[i]);
380 free(ui->job_files[i]);
381 ui->job_files[i] = NULL;
383 while (i < ui->nr_job_files) {
384 free(ui->job_files[i]);
385 ui->job_files[i] = NULL;
392 static void start_job_thread(struct gui *ui)
394 if (send_job_files(ui)) {
395 printf("Yeah, I didn't really like those options too much.\n");
396 gtk_widget_set_sensitive(ui->button[START_JOB_BUTTON], 1);
401 static GtkWidget *new_info_label_in_frame(GtkWidget *box, const char *label)
403 GtkWidget *label_widget;
406 frame = gtk_frame_new(label);
407 label_widget = gtk_label_new(NULL);
408 gtk_box_pack_start(GTK_BOX(box), frame, TRUE, TRUE, 3);
409 gtk_container_add(GTK_CONTAINER(frame), label_widget);
414 static GtkWidget *create_spinbutton(GtkWidget *hbox, double min, double max, double defval)
416 GtkWidget *button, *box;
418 box = gtk_hbox_new(FALSE, 3);
419 gtk_container_add(GTK_CONTAINER(hbox), box);
421 button = gtk_spin_button_new_with_range(min, max, 1.0);
422 gtk_box_pack_start(GTK_BOX(box), button, TRUE, TRUE, 0);
424 gtk_spin_button_set_update_policy(GTK_SPIN_BUTTON(button), GTK_UPDATE_IF_VALID);
425 gtk_spin_button_set_value(GTK_SPIN_BUTTON(button), defval);
430 static void start_job_clicked(__attribute__((unused)) GtkWidget *widget,
433 struct gui *ui = data;
435 gtk_widget_set_sensitive(ui->button[START_JOB_BUTTON], 0);
436 start_job_thread(ui);
439 static void file_open(GtkWidget *w, gpointer data);
441 static void connect_clicked(GtkWidget *widget, gpointer data)
443 struct gui *ui = data;
445 if (!ui->connected) {
446 if (!ui->nr_job_files)
447 file_open(widget, data);
448 fio_clients_connect();
449 pthread_create(&ui->t, NULL, job_thread, NULL);
450 gfio_set_connected(ui, 1);
452 fio_clients_terminate();
453 gfio_set_connected(ui, 0);
457 static void add_button(struct gui *ui, int i, GtkWidget *buttonbox,
458 struct button_spec *buttonspec)
460 ui->button[i] = gtk_button_new_with_label(buttonspec->buttontext);
461 g_signal_connect(ui->button[i], "clicked", G_CALLBACK (buttonspec->f), ui);
462 gtk_box_pack_start(GTK_BOX (ui->buttonbox), ui->button[i], FALSE, FALSE, 3);
463 gtk_widget_set_tooltip_text(ui->button[i], buttonspeclist[i].tooltiptext);
464 gtk_widget_set_sensitive(ui->button[i], !buttonspec->start_insensitive);
467 static void add_buttons(struct gui *ui,
468 struct button_spec *buttonlist,
473 for (i = 0; i < nbuttons; i++)
474 add_button(ui, i, ui->buttonbox, &buttonlist[i]);
477 static void on_info_bar_response(GtkWidget *widget, gint response,
480 if (response == GTK_RESPONSE_OK) {
481 gtk_widget_destroy(widget);
482 ui.error_info_bar = NULL;
486 void report_error(GError *error)
488 if (ui.error_info_bar == NULL) {
489 ui.error_info_bar = gtk_info_bar_new_with_buttons(GTK_STOCK_OK,
492 g_signal_connect(ui.error_info_bar, "response", G_CALLBACK(on_info_bar_response), NULL);
493 gtk_info_bar_set_message_type(GTK_INFO_BAR(ui.error_info_bar),
496 ui.error_label = gtk_label_new(error->message);
497 GtkWidget *container = gtk_info_bar_get_content_area(GTK_INFO_BAR(ui.error_info_bar));
498 gtk_container_add(GTK_CONTAINER(container), ui.error_label);
500 gtk_box_pack_start(GTK_BOX(ui.vbox), ui.error_info_bar, FALSE, FALSE, 0);
501 gtk_widget_show_all(ui.vbox);
504 snprintf(buffer, sizeof(buffer), "Failed to open file.");
505 gtk_label_set(GTK_LABEL(ui.error_label), buffer);
509 static int get_connection_details(char **host, int *port, int *type)
511 GtkWidget *dialog, *box, *vbox, *hentry, *hbox, *frame, *pentry, *combo;
514 dialog = gtk_dialog_new_with_buttons("Connection details",
515 GTK_WINDOW(ui.window),
516 GTK_DIALOG_DESTROY_WITH_PARENT,
517 GTK_STOCK_OK, GTK_RESPONSE_ACCEPT,
518 GTK_STOCK_CANCEL, GTK_RESPONSE_REJECT, NULL);
520 frame = gtk_frame_new("Hostname / socket name");
521 vbox = gtk_dialog_get_content_area(GTK_DIALOG(dialog));
522 gtk_box_pack_start(GTK_BOX(vbox), frame, FALSE, FALSE, 5);
524 box = gtk_vbox_new(FALSE, 6);
525 gtk_container_add(GTK_CONTAINER(frame), box);
527 hbox = gtk_hbox_new(TRUE, 10);
528 gtk_box_pack_start(GTK_BOX(box), hbox, FALSE, FALSE, 0);
529 hentry = gtk_entry_new();
530 gtk_entry_set_text(GTK_ENTRY(hentry), "localhost");
531 gtk_box_pack_start(GTK_BOX(hbox), hentry, TRUE, TRUE, 0);
533 frame = gtk_frame_new("Port");
534 gtk_box_pack_start(GTK_BOX(vbox), frame, FALSE, FALSE, 5);
535 box = gtk_vbox_new(FALSE, 10);
536 gtk_container_add(GTK_CONTAINER(frame), box);
538 hbox = gtk_hbox_new(TRUE, 4);
539 gtk_box_pack_start(GTK_BOX(box), hbox, FALSE, FALSE, 0);
540 pentry = create_spinbutton(hbox, 1, 65535, FIO_NET_PORT);
542 frame = gtk_frame_new("Type");
543 gtk_box_pack_start(GTK_BOX(vbox), frame, FALSE, FALSE, 5);
544 box = gtk_vbox_new(FALSE, 10);
545 gtk_container_add(GTK_CONTAINER(frame), box);
547 hbox = gtk_hbox_new(TRUE, 4);
548 gtk_box_pack_start(GTK_BOX(box), hbox, FALSE, FALSE, 0);
550 combo = gtk_combo_box_text_new();
551 gtk_combo_box_text_append_text(GTK_COMBO_BOX_TEXT(combo), "IPv4");
552 gtk_combo_box_text_append_text(GTK_COMBO_BOX_TEXT(combo), "IPv6");
553 gtk_combo_box_text_append_text(GTK_COMBO_BOX_TEXT(combo), "local socket");
554 gtk_combo_box_set_active(GTK_COMBO_BOX(combo), 0);
556 gtk_container_add(GTK_CONTAINER(hbox), combo);
558 gtk_widget_show_all(dialog);
560 if (gtk_dialog_run(GTK_DIALOG(dialog)) != GTK_RESPONSE_ACCEPT) {
561 gtk_widget_destroy(dialog);
565 *host = strdup(gtk_entry_get_text(GTK_ENTRY(hentry)));
566 *port = gtk_spin_button_get_value_as_int(GTK_SPIN_BUTTON(pentry));
568 typeentry = gtk_combo_box_text_get_active_text(GTK_COMBO_BOX_TEXT(combo));
569 if (!typeentry || !strncmp(typeentry, "IPv4", 4))
570 *type = Fio_client_ipv4;
571 else if (!strncmp(typeentry, "IPv6", 4))
572 *type = Fio_client_ipv6;
574 *type = Fio_client_socket;
577 gtk_widget_destroy(dialog);
581 static void file_open(GtkWidget *w, gpointer data)
584 GSList *filenames, *fn_glist;
585 GtkFileFilter *filter;
589 dialog = gtk_file_chooser_dialog_new("Open File",
590 GTK_WINDOW(ui.window),
591 GTK_FILE_CHOOSER_ACTION_OPEN,
592 GTK_STOCK_CANCEL, GTK_RESPONSE_CANCEL,
593 GTK_STOCK_OPEN, GTK_RESPONSE_ACCEPT,
595 gtk_file_chooser_set_select_multiple(GTK_FILE_CHOOSER(dialog), TRUE);
597 filter = gtk_file_filter_new();
598 gtk_file_filter_add_pattern(filter, "*.fio");
599 gtk_file_filter_add_pattern(filter, "*.job");
600 gtk_file_filter_add_mime_type(filter, "text/fio");
601 gtk_file_filter_set_name(filter, "Fio job file");
602 gtk_file_chooser_set_filter(GTK_FILE_CHOOSER(dialog), filter);
604 if (gtk_dialog_run(GTK_DIALOG(dialog)) != GTK_RESPONSE_ACCEPT) {
605 gtk_widget_destroy(dialog);
609 fn_glist = gtk_file_chooser_get_filenames(GTK_FILE_CHOOSER(dialog));
611 gtk_widget_destroy(dialog);
613 if (get_connection_details(&host, &port, &type))
616 filenames = fn_glist;
617 while (filenames != NULL) {
618 ui.job_files = realloc(ui.job_files, (ui.nr_job_files + 1) * sizeof(char *));
619 ui.job_files[ui.nr_job_files] = strdup(filenames->data);
622 ui.client = fio_client_add_explicit(host, type, port);
626 error = g_error_new(g_quark_from_string("fio"), 1,
627 "Failed to add client %s", host);
631 ui.client->client_data = &ui;
633 g_free(filenames->data);
634 filenames = g_slist_next(filenames);
638 g_slist_free(fn_glist);
641 static void file_save(GtkWidget *w, gpointer data)
645 dialog = gtk_file_chooser_dialog_new("Save File",
646 GTK_WINDOW(ui.window),
647 GTK_FILE_CHOOSER_ACTION_SAVE,
648 GTK_STOCK_CANCEL, GTK_RESPONSE_CANCEL,
649 GTK_STOCK_SAVE, GTK_RESPONSE_ACCEPT,
652 gtk_file_chooser_set_do_overwrite_confirmation(GTK_FILE_CHOOSER(dialog), TRUE);
653 gtk_file_chooser_set_current_name(GTK_FILE_CHOOSER(dialog), "Untitled document");
655 if (gtk_dialog_run(GTK_DIALOG(dialog)) == GTK_RESPONSE_ACCEPT) {
658 filename = gtk_file_chooser_get_filename(GTK_FILE_CHOOSER(dialog));
659 // save_job_file(filename);
662 gtk_widget_destroy(dialog);
665 static void about_dialog(GtkWidget *w, gpointer data)
667 gtk_show_about_dialog(NULL,
668 "program-name", "gfio",
669 "comments", "Gtk2 UI for fio",
671 "version", fio_version_string,
672 "copyright", "Jens Axboe <axboe@kernel.dk> 2012",
673 "logo-icon-name", "fio",
679 static GtkActionEntry menu_items[] = {
680 { "FileMenuAction", GTK_STOCK_FILE, "File", NULL, NULL, NULL},
681 { "HelpMenuAction", GTK_STOCK_HELP, "Help", NULL, NULL, NULL},
682 { "OpenFile", GTK_STOCK_OPEN, NULL, "<Control>O", NULL, G_CALLBACK(file_open) },
683 { "SaveFile", GTK_STOCK_SAVE, NULL, "<Control>S", NULL, G_CALLBACK(file_save) },
684 { "Quit", GTK_STOCK_QUIT, NULL, "<Control>Q", NULL, G_CALLBACK(quit_clicked) },
685 { "About", GTK_STOCK_ABOUT, NULL, NULL, NULL, G_CALLBACK(about_dialog) },
687 static gint nmenu_items = sizeof(menu_items) / sizeof(menu_items[0]);
689 static const gchar *ui_string = " \
691 <menubar name=\"MainMenu\"> \
692 <menu name=\"FileMenu\" action=\"FileMenuAction\"> \
693 <menuitem name=\"Open\" action=\"OpenFile\" /> \
694 <menuitem name=\"Save\" action=\"SaveFile\" /> \
695 <separator name=\"Separator\"/> \
696 <menuitem name=\"Quit\" action=\"Quit\" /> \
698 <menu name=\"Help\" action=\"HelpMenuAction\"> \
699 <menuitem name=\"About\" action=\"About\" /> \
705 static GtkWidget *get_menubar_menu(GtkWidget *window, GtkUIManager *ui_manager)
707 GtkActionGroup *action_group = gtk_action_group_new("Menu");
710 action_group = gtk_action_group_new("Menu");
711 gtk_action_group_add_actions(action_group, menu_items, nmenu_items, 0);
713 gtk_ui_manager_insert_action_group(ui_manager, action_group, 0);
714 gtk_ui_manager_add_ui_from_string(GTK_UI_MANAGER(ui_manager), ui_string, -1, &error);
716 gtk_window_add_accel_group(GTK_WINDOW(window), gtk_ui_manager_get_accel_group(ui_manager));
717 return gtk_ui_manager_get_widget(ui_manager, "/MainMenu");
720 void gfio_ui_setup(GtkSettings *settings, GtkWidget *menubar,
721 GtkWidget *vbox, GtkUIManager *ui_manager)
723 gtk_box_pack_start(GTK_BOX(vbox), menubar, FALSE, FALSE, 0);
726 static void init_ui(int *argc, char **argv[], struct gui *ui)
728 GtkSettings *settings;
729 GtkUIManager *uimanager;
730 GtkWidget *menu, *probe, *probe_frame, *probe_box;
732 memset(ui, 0, sizeof(*ui));
734 /* Magical g*thread incantation, you just need this thread stuff.
735 * Without it, the update that happens in gfio_update_thread_status
736 * doesn't really happen in a timely fashion, you need expose events
738 if (!g_thread_supported())
742 gtk_init(argc, argv);
743 settings = gtk_settings_get_default();
744 gtk_settings_set_long_property(settings, "gtk_tooltip_timeout", 10, "gfio setting");
747 ui->window = gtk_window_new(GTK_WINDOW_TOPLEVEL);
748 gtk_window_set_title(GTK_WINDOW(ui->window), "fio");
749 gtk_window_set_default_size(GTK_WINDOW(ui->window), 700, 500);
751 g_signal_connect(ui->window, "delete-event", G_CALLBACK(quit_clicked), NULL);
752 g_signal_connect(ui->window, "destroy", G_CALLBACK(quit_clicked), NULL);
754 ui->vbox = gtk_vbox_new(FALSE, 0);
755 gtk_container_add(GTK_CONTAINER (ui->window), ui->vbox);
757 uimanager = gtk_ui_manager_new();
758 menu = get_menubar_menu(ui->window, uimanager);
759 gfio_ui_setup(settings, menu, ui->vbox, uimanager);
762 * Set up alignments for widgets at the top of ui,
763 * align top left, expand horizontally but not vertically
765 ui->topalign = gtk_alignment_new(0, 0, 1, 0);
766 ui->topvbox = gtk_vbox_new(FALSE, 3);
767 gtk_container_add(GTK_CONTAINER(ui->topalign), ui->topvbox);
768 gtk_box_pack_start(GTK_BOX(ui->vbox), ui->topalign, FALSE, FALSE, 0);
770 probe = gtk_frame_new("Job");
771 gtk_box_pack_start(GTK_BOX(ui->topvbox), probe, TRUE, FALSE, 3);
772 probe_frame = gtk_vbox_new(FALSE, 3);
773 gtk_container_add(GTK_CONTAINER(probe), probe_frame);
775 probe_box = gtk_hbox_new(FALSE, 3);
776 gtk_box_pack_start(GTK_BOX(probe_frame), probe_box, TRUE, FALSE, 3);
777 ui->probe.hostname = new_info_label_in_frame(probe_box, "Host");
778 ui->probe.os = new_info_label_in_frame(probe_box, "OS");
779 ui->probe.arch = new_info_label_in_frame(probe_box, "Architecture");
780 ui->probe.fio_ver = new_info_label_in_frame(probe_box, "Fio version");
782 probe_box = gtk_hbox_new(FALSE, 3);
783 gtk_box_pack_start(GTK_BOX(probe_frame), probe_box, TRUE, FALSE, 3);
785 ui->eta.name = new_info_label_in_frame(probe_box, "Name");
786 ui->eta.iotype = new_info_label_in_frame(probe_box, "IO");
787 ui->eta.ioengine = new_info_label_in_frame(probe_box, "IO Engine");
788 ui->eta.iodepth = new_info_label_in_frame(probe_box, "IO Depth");
789 ui->eta.jobs = new_info_label_in_frame(probe_box, "Jobs");
790 ui->eta.files = new_info_label_in_frame(probe_box, "Open files");
792 probe_box = gtk_hbox_new(FALSE, 3);
793 gtk_box_pack_start(GTK_BOX(probe_frame), probe_box, TRUE, FALSE, 3);
794 ui->eta.read_bw = new_info_label_in_frame(probe_box, "Read BW");
795 ui->eta.read_iops = new_info_label_in_frame(probe_box, "IOPS");
796 ui->eta.write_bw = new_info_label_in_frame(probe_box, "Write BW");
797 ui->eta.write_iops = new_info_label_in_frame(probe_box, "IOPS");
800 * Only add this if we have a commit rate
803 probe_box = gtk_hbox_new(FALSE, 3);
804 gtk_box_pack_start(GTK_BOX(probe_frame), probe_box, TRUE, FALSE, 3);
806 ui->eta.cr_bw = new_info_label_in_frame(probe_box, "Commit BW");
807 ui->eta.cr_iops = new_info_label_in_frame(probe_box, "Commit IOPS");
809 ui->eta.cw_bw = new_info_label_in_frame(probe_box, "Commit BW");
810 ui->eta.cw_iops = new_info_label_in_frame(probe_box, "Commit IOPS");
814 * Add a text box for text op messages
816 ui->textview = gtk_text_view_new();
817 ui->text = gtk_text_view_get_buffer(GTK_TEXT_VIEW(ui->textview));
818 gtk_text_buffer_set_text(ui->text, "", -1);
819 gtk_text_view_set_editable(GTK_TEXT_VIEW(ui->textview), FALSE);
820 gtk_text_view_set_cursor_visible(GTK_TEXT_VIEW(ui->textview), FALSE);
821 ui->scrolled_window = gtk_scrolled_window_new(NULL, NULL);
822 gtk_scrolled_window_set_policy(GTK_SCROLLED_WINDOW(ui->scrolled_window),
823 GTK_POLICY_AUTOMATIC, GTK_POLICY_AUTOMATIC);
824 gtk_container_add(GTK_CONTAINER(ui->scrolled_window), ui->textview);
825 gtk_box_pack_start(GTK_BOX(ui->vbox), ui->scrolled_window,
829 * Set up alignments for widgets at the bottom of ui,
830 * align bottom left, expand horizontally but not vertically
832 ui->bottomalign = gtk_alignment_new(0, 1, 1, 0);
833 ui->buttonbox = gtk_hbox_new(FALSE, 0);
834 gtk_container_add(GTK_CONTAINER(ui->bottomalign), ui->buttonbox);
835 gtk_box_pack_start(GTK_BOX(ui->vbox), ui->bottomalign,
838 add_buttons(ui, buttonspeclist, ARRAYSIZE(buttonspeclist));
841 * Set up thread status progress bar
843 ui->thread_status_pb = gtk_progress_bar_new();
844 gtk_progress_bar_set_fraction(GTK_PROGRESS_BAR(ui->thread_status_pb), 0.0);
845 gtk_progress_bar_set_text(GTK_PROGRESS_BAR(ui->thread_status_pb), "No jobs running");
846 gtk_container_add(GTK_CONTAINER(ui->buttonbox), ui->thread_status_pb);
849 gtk_widget_show_all(ui->window);
852 int main(int argc, char *argv[], char *envp[])
854 if (initialize_fio(envp))
856 if (fio_init_options())
860 init_ui(&argc, &argv, &ui);