+ gtk_scrolled_window_add_with_viewport(GTK_SCROLLED_WINDOW(scroll), vbox);
+
+ gtk_notebook_append_page(GTK_NOTEBOOK(win), scroll, gtk_label_new(ts->name));
+
+ entry = new_info_entry_in_frame(box, "Name");
+ gtk_entry_set_text(GTK_ENTRY(entry), ts->name);
+ if (strlen(ts->description)) {
+ entry = new_info_entry_in_frame(box, "Description");
+ gtk_entry_set_text(GTK_ENTRY(entry), ts->description);
+ }
+ entry = new_info_entry_in_frame(box, "Group ID");
+ entry_set_int_value(entry, ts->groupid);
+ entry = new_info_entry_in_frame(box, "Jobs");
+ entry_set_int_value(entry, ts->members);
+ gc->err_entry = entry = new_info_entry_in_frame(box, "Error");
+ entry_set_int_value(entry, ts->error);
+ entry = new_info_entry_in_frame(box, "PID");
+ entry_set_int_value(entry, ts->pid);
+
+ if (ts->io_bytes[DDIR_READ])
+ gfio_show_ddir_status(gc, vbox, rs, ts, DDIR_READ);
+ if (ts->io_bytes[DDIR_WRITE])
+ gfio_show_ddir_status(gc, vbox, rs, ts, DDIR_WRITE);
+
+ gfio_show_latency_buckets(gc, vbox, ts);
+ gfio_show_cpu_usage(vbox, ts);
+ gfio_show_io_depths(vbox, ts);
+}
+
+static void gfio_display_end_results(struct gfio_client *gc)
+{
+ struct gui_entry *ge = gc->ge;
+ GtkWidget *res_notebook;
+ int i;
+
+ res_notebook = get_results_window(ge);
+
+ for (i = 0; i < gc->nr_results; i++) {
+ struct end_results *e = &gc->results[i];
+
+ __gfio_display_end_results(res_notebook, gc, &e->ts, &e->gs);
+ }
+
+ if (gfio_disk_util_show(gc))
+ gtk_widget_show_all(ge->results_window);
+}
+
+static void gfio_display_ts(struct fio_client *client, struct thread_stat *ts,
+ struct group_run_stats *rs)
+{
+ struct gfio_client *gc = client->client_data;
+ struct gui_entry *ge = gc->ge;
+
+ gfio_add_end_results(gc, ts, rs);
+
+ gdk_threads_enter();
+ if (ge->results_window)
+ __gfio_display_end_results(ge->results_notebook, gc, ts, rs);
+ else
+ gfio_display_end_results(gc);
+ gdk_threads_leave();
+}
+
+static void gfio_text_op(struct fio_client *client, struct fio_net_cmd *cmd)
+{
+ struct cmd_text_pdu *p = (struct cmd_text_pdu *) cmd->payload;
+ struct gui *ui = &main_ui;
+ GtkTreeIter iter;
+ struct tm *tm;
+ time_t sec;
+ char tmp[64], timebuf[80];
+
+ sec = p->log_sec;
+ tm = localtime(&sec);
+ strftime(tmp, sizeof(tmp), "%Y-%m-%d %H:%M:%S", tm);
+ sprintf(timebuf, "%s.%03ld", tmp, p->log_usec / 1000);
+
+ gdk_threads_enter();
+
+ gtk_list_store_append(ui->log_model, &iter);
+ gtk_list_store_set(ui->log_model, &iter, 0, timebuf, -1);
+ gtk_list_store_set(ui->log_model, &iter, 1, client->hostname, -1);
+ gtk_list_store_set(ui->log_model, &iter, 2, p->level, -1);
+ gtk_list_store_set(ui->log_model, &iter, 3, p->buf, -1);
+
+ if (p->level == FIO_LOG_ERR)
+ view_log(NULL, (gpointer) ui);
+
+ gdk_threads_leave();
+}
+
+static void gfio_disk_util_op(struct fio_client *client, struct fio_net_cmd *cmd)
+{
+ struct cmd_du_pdu *p = (struct cmd_du_pdu *) cmd->payload;
+ struct gfio_client *gc = client->client_data;
+ struct gui_entry *ge = gc->ge;
+ unsigned int nr = gc->nr_du;
+
+ gc->du = realloc(gc->du, (nr + 1) * sizeof(struct cmd_du_pdu));
+ memcpy(&gc->du[nr], p, sizeof(*p));
+ gc->nr_du++;
+
+ gdk_threads_enter();
+ if (ge->results_window)
+ __gfio_disk_util_show(ge->results_notebook, gc, p);
+ else
+ gfio_disk_util_show(gc);
+ gdk_threads_leave();
+}
+
+extern int sum_stat_clients;
+extern struct thread_stat client_ts;
+extern struct group_run_stats client_gs;
+
+static int sum_stat_nr;
+
+static void gfio_thread_status_op(struct fio_client *client,
+ struct fio_net_cmd *cmd)
+{
+ struct cmd_ts_pdu *p = (struct cmd_ts_pdu *) cmd->payload;
+
+ gfio_display_ts(client, &p->ts, &p->rs);
+
+ if (sum_stat_clients == 1)
+ return;
+
+ sum_thread_stats(&client_ts, &p->ts, sum_stat_nr);
+ sum_group_stats(&client_gs, &p->rs);
+
+ client_ts.members++;
+ client_ts.thread_number = p->ts.thread_number;
+ client_ts.groupid = p->ts.groupid;
+
+ if (++sum_stat_nr == sum_stat_clients) {
+ strcpy(client_ts.name, "All clients");
+ gfio_display_ts(client, &client_ts, &client_gs);
+ }
+}
+
+static void gfio_group_stats_op(struct fio_client *client,
+ struct fio_net_cmd *cmd)
+{
+ /* We're ignoring group stats for now */
+}
+
+static gint on_config_drawing_area(GtkWidget *w, GdkEventConfigure *event,
+ gpointer data)
+{
+ struct gfio_graphs *g = data;
+
+ graph_set_size(g->iops_graph, w->allocation.width / 2.0, w->allocation.height);
+ graph_set_position(g->iops_graph, w->allocation.width / 2.0, 0.0);
+ graph_set_size(g->bandwidth_graph, w->allocation.width / 2.0, w->allocation.height);
+ graph_set_position(g->bandwidth_graph, 0, 0);
+ return TRUE;
+}
+
+static void draw_graph(struct graph *g, cairo_t *cr)
+{
+ line_graph_draw(g, cr);
+ cairo_stroke(cr);
+}
+
+static gboolean graph_tooltip(GtkWidget *w, gint x, gint y,
+ gboolean keyboard_mode, GtkTooltip *tooltip,
+ gpointer data)
+{
+ struct gfio_graphs *g = data;
+ const char *text = NULL;
+
+ if (graph_contains_xy(g->iops_graph, x, y))
+ text = graph_find_tooltip(g->iops_graph, x, y);
+ else if (graph_contains_xy(g->bandwidth_graph, x, y))
+ text = graph_find_tooltip(g->bandwidth_graph, x, y);
+
+ if (text) {
+ gtk_tooltip_set_text(tooltip, text);
+ return TRUE;
+ }
+
+ return FALSE;
+}
+
+static int on_expose_drawing_area(GtkWidget *w, GdkEvent *event, gpointer p)
+{
+ struct gfio_graphs *g = p;
+ cairo_t *cr;
+
+ cr = gdk_cairo_create(w->window);
+
+ if (graph_has_tooltips(g->iops_graph) ||
+ graph_has_tooltips(g->bandwidth_graph)) {
+ g_object_set(w, "has-tooltip", TRUE, NULL);
+ g_signal_connect(w, "query-tooltip", G_CALLBACK(graph_tooltip), g);
+ }
+
+ cairo_set_source_rgb(cr, 0, 0, 0);
+ draw_graph(g->iops_graph, cr);
+ draw_graph(g->bandwidth_graph, cr);
+ cairo_destroy(cr);
+
+ return FALSE;
+}
+
+/*
+ * Client specific ETA
+ */
+static void gfio_update_client_eta(struct fio_client *client, struct jobs_eta *je)
+{
+ struct gfio_client *gc = client->client_data;
+ struct gui_entry *ge = gc->ge;
+ static int eta_good;
+ char eta_str[128];
+ char output[256];
+ char tmp[32];
+ double perc = 0.0;
+ int i2p = 0;
+
+ gdk_threads_enter();
+
+ eta_str[0] = '\0';
+ output[0] = '\0';
+
+ if (je->eta_sec != INT_MAX && je->elapsed_sec) {
+ perc = (double) je->elapsed_sec / (double) (je->elapsed_sec + je->eta_sec);
+ eta_to_str(eta_str, je->eta_sec);
+ }
+
+ sprintf(tmp, "%u", je->nr_running);
+ gtk_entry_set_text(GTK_ENTRY(ge->eta.jobs), tmp);