[gnome-system-monitor/wip/diskio] Implemented disk io monitoring
- From: Robert Roth <robertroth src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-system-monitor/wip/diskio] Implemented disk io monitoring
- Date: Sun, 9 Jul 2017 08:41:09 +0000 (UTC)
commit 60a787b45c44214985559a1a446fa82129a1d885
Author: Robert Roth <robert roth off gmail com>
Date: Sun Jul 9 11:40:43 2017 +0300
Implemented disk io monitoring
configure.ac | 2 +-
src/application.h | 8 +++
...rg.gnome.gnome-system-monitor.gschema.xml.in.in | 59 +++++++++++++++++++-
src/proctable.cpp | 46 +++++++++++++++-
src/proctable.h | 4 +
src/util.cpp | 37 ++++++++++++
src/util.h | 4 +
7 files changed, 157 insertions(+), 3 deletions(-)
---
diff --git a/configure.ac b/configure.ac
index 61cc2e5..b40e267 100644
--- a/configure.ac
+++ b/configure.ac
@@ -30,7 +30,7 @@ LT_INIT
# Package dependencies
GLIB_REQUIRED=2.37.3
LIBWNCK_REQUIRED=2.91.0
-LIBGTOP_REQUIRED=2.28.2
+LIBGTOP_REQUIRED=2.37.2
GTK_REQUIRED=3.22.0
GNOME_ICON_THEME_REQUIRED=2.31
GTKMM_REQUIRED=3.3.18
diff --git a/src/application.h b/src/application.h
index 3190298..0753254 100644
--- a/src/application.h
+++ b/src/application.h
@@ -82,6 +82,10 @@ MutableProcInfo()
#endif
start_time(0UL),
cpu_time(0ULL),
+ disk_write_bytes_current(0ULL),
+ disk_read_bytes_current(0ULL),
+ disk_write_bytes_total(0ULL),
+ disk_read_bytes_total(0ULL),
status(0U),
pcpu(0U),
nice(0)
@@ -109,6 +113,10 @@ MutableProcInfo()
gulong start_time;
guint64 cpu_time;
+ guint64 disk_write_bytes_current;
+ guint64 disk_read_bytes_current;
+ guint64 disk_write_bytes_total;
+ guint64 disk_read_bytes_total;
guint status;
guint pcpu;
gint nice;
diff --git a/src/org.gnome.gnome-system-monitor.gschema.xml.in.in
b/src/org.gnome.gnome-system-monitor.gschema.xml.in.in
index 6095749..dd533c8 100644
--- a/src/org.gnome.gnome-system-monitor.gschema.xml.in.in
+++ b/src/org.gnome.gnome-system-monitor.gschema.xml.in.in
@@ -488,17 +488,74 @@
<key name="col-22-width" type="i">
<default>100
</default>
- <_summary>Width of process “Priority” column
+ <_summary>Width of process “Total disk write” column
</_summary>
</key>
<key name="col-22-visible" type="b">
<default>true
</default>
+ <_summary>Show process “Total disk write” column on startup
+ </_summary>
+ </key>
+
+ <key name="col-23-width" type="i">
+ <default>100
+ </default>
+ <_summary>Width of process “Total disk read” column
+ </_summary>
+ </key>
+
+ <key name="col-23-visible" type="b">
+ <default>true
+ </default>
+ <_summary>Show process “Total disk read” column on startup
+ </_summary>
+ </key>
+
+ <key name="col-24-width" type="i">
+ <default>100
+ </default>
+ <_summary>Width of process “Disk read” column
+ </_summary>
+ </key>
+
+ <key name="col-24-visible" type="b">
+ <default>true
+ </default>
+ <_summary>Show process “Disk read” column on startup
+ </_summary>
+ </key>
+
+ <key name="col-25-width" type="i">
+ <default>100
+ </default>
+ <_summary>Width of process “Disk write” column
+ </_summary>
+ </key>
+
+ <key name="col-25-visible" type="b">
+ <default>true
+ </default>
+ <_summary>Show process “Disk write” column on startup
+ </_summary>
+ </key>
+
+ <key name="col-26-width" type="i">
+ <default>100
+ </default>
+ <_summary>Width of process “Priority” column
+ </_summary>
+ </key>
+
+ <key name="col-26-visible" type="b">
+ <default>true
+ </default>
<_summary>Show process “Priority” column on startup
</_summary>
</key>
+
</schema>
<schema id="org.gnome.gnome-system-monitor.disktreenew"
path="/org/gnome/gnome-system-monitor/disktreenew/">
diff --git a/src/proctable.cpp b/src/proctable.cpp
index 384e55f..e41d6d0 100644
--- a/src/proctable.cpp
+++ b/src/proctable.cpp
@@ -28,6 +28,7 @@
#include <glibtop.h>
#include <glibtop/proclist.h>
#include <glibtop/procstate.h>
+#include <glibtop/procio.h>
#include <glibtop/procmem.h>
#include <glibtop/procmap.h>
#include <glibtop/proctime.h>
@@ -343,6 +344,10 @@ proctable_new (GsmApplication * const app)
for multi-seat environments. See http://en.wikipedia.org/wiki/Multiseat_configuration */
N_("Seat"),
N_("Owner"),
+ N_("Disk read total"),
+ N_("Disk write total"),
+ N_("Disk read"),
+ N_("Disk write"),
N_("Priority"),
NULL,
"POINTER"
@@ -373,6 +378,10 @@ proctable_new (GsmApplication * const app)
G_TYPE_STRING, /* Session */
G_TYPE_STRING, /* Seat */
G_TYPE_STRING, /* Owner */
+ G_TYPE_UINT64, /* Disk read total */
+ G_TYPE_UINT64, /* Disk write total*/
+ G_TYPE_UINT64, /* Disk read */
+ G_TYPE_UINT64, /* Disk write */
G_TYPE_STRING, /* Priority */
GDK_TYPE_PIXBUF, /* Icon */
G_TYPE_POINTER, /* ProcInfo */
@@ -478,6 +487,21 @@ proctable_new (GsmApplication * const app)
GUINT_TO_POINTER(i),
NULL);
break;
+ case COL_DISK_READ_TOTAL:
+ case COL_DISK_WRITE_TOTAL:
+ gtk_tree_view_column_set_cell_data_func(col, cell,
+ &procman::size_na_cell_data_func,
+ GUINT_TO_POINTER(i),
+ NULL);
+ break;
+ case COL_DISK_READ_CURRENT:
+ case COL_DISK_WRITE_CURRENT:
+ gtk_tree_view_column_set_cell_data_func(col, cell,
+ &procman::io_rate_cell_data_func,
+ GUINT_TO_POINTER(i),
+ NULL);
+
+ break;
case COL_PRIORITY:
gtk_tree_view_column_set_cell_data_func(col, cell,
&procman::priority_cell_data_func,
@@ -500,6 +524,10 @@ proctable_new (GsmApplication * const app)
case COL_MEM:
case COL_CPU:
case COL_CPU_TIME:
+ case COL_DISK_READ_TOTAL:
+ case COL_DISK_WRITE_TOTAL:
+ case COL_DISK_READ_CURRENT:
+ case COL_DISK_WRITE_CURRENT:
case COL_START_TIME:
gtk_tree_sortable_set_sort_func (GTK_TREE_SORTABLE (model_sort), i,
procman::number_compare_func,
@@ -527,6 +555,10 @@ proctable_new (GsmApplication * const app)
case COL_CPU:
case COL_NICE:
case COL_PID:
+ case COL_DISK_READ_TOTAL:
+ case COL_DISK_WRITE_TOTAL:
+ case COL_DISK_READ_CURRENT:
+ case COL_DISK_WRITE_CURRENT:
case COL_CPU_TIME:
case COL_MEM:
g_object_set(G_OBJECT(cell), "xalign", 1.0f, NULL);
@@ -740,6 +772,10 @@ update_info_mutable_cols(ProcInfo *info)
#endif
tree_store_update(model, &info->node, COL_CPU, info->pcpu);
tree_store_update(model, &info->node, COL_CPU_TIME, info->cpu_time);
+ tree_store_update(model, &info->node, COL_DISK_READ_TOTAL, info->disk_read_bytes_total);
+ tree_store_update(model, &info->node, COL_DISK_WRITE_TOTAL, info->disk_write_bytes_total);
+ tree_store_update(model, &info->node, COL_DISK_READ_CURRENT, info->disk_read_bytes_current);
+ tree_store_update(model, &info->node, COL_DISK_WRITE_CURRENT, info->disk_write_bytes_current);
tree_store_update(model, &info->node, COL_START_TIME, info->start_time);
tree_store_update(model, &info->node, COL_NICE, info->nice);
tree_store_update(model, &info->node, COL_MEM, info->mem);
@@ -860,7 +896,8 @@ update_info (GsmApplication *app, ProcInfo *info)
glibtop_proc_uid procuid;
glibtop_proc_time proctime;
glibtop_proc_kernel prockernel;
-
+ glibtop_proc_io procio;
+ gdouble update_interval_seconds = app->config.update_interval / 1000;
glibtop_get_proc_kernel(&prockernel, info->pid);
info->wchan = get_proc_kernel_wchan(prockernel);
@@ -869,6 +906,7 @@ update_info (GsmApplication *app, ProcInfo *info)
glibtop_get_proc_uid (&procuid, info->pid);
glibtop_get_proc_time (&proctime, info->pid);
+ glibtop_get_proc_io (&procio, info->pid);
get_process_memory_info(info);
@@ -887,6 +925,12 @@ update_info (GsmApplication *app, ProcInfo *info)
app->processes.cpu_times[info->pid] = info->cpu_time = proctime.rtime;
info->nice = procuid.nice;
+
+ info->disk_write_bytes_current = (procio.disk_wbytes -
info->disk_write_bytes_total)/update_interval_seconds;
+ info->disk_read_bytes_current = (procio.disk_rbytes -
info->disk_read_bytes_total)/update_interval_seconds;
+
+ info->disk_write_bytes_total = procio.disk_wbytes;
+ info->disk_read_bytes_total = procio.disk_rbytes;
// set the ppid only if one can exist
// i.e. pid=0 can never have a parent
diff --git a/src/proctable.h b/src/proctable.h
index ff9e4fd..6382399 100644
--- a/src/proctable.h
+++ b/src/proctable.h
@@ -49,6 +49,10 @@ enum
COL_SESSION,
COL_SEAT,
COL_OWNER,
+ COL_DISK_WRITE_TOTAL,
+ COL_DISK_READ_TOTAL,
+ COL_DISK_WRITE_CURRENT,
+ COL_DISK_READ_CURRENT,
COL_PRIORITY,
COL_PIXBUF,
COL_POINTER,
diff --git a/src/util.cpp b/src/util.cpp
index 205c963..31a215e 100644
--- a/src/util.cpp
+++ b/src/util.cpp
@@ -440,6 +440,43 @@ namespace procman
}
}
+
+ void io_rate_cell_data_func(GtkTreeViewColumn *, GtkCellRenderer *renderer,
+ GtkTreeModel *model, GtkTreeIter *iter,
+ gpointer user_data)
+ {
+ const guint index = GPOINTER_TO_UINT(user_data);
+
+ guint64 size;
+ GValue value = { 0 };
+
+ gtk_tree_model_get_value(model, iter, index, &value);
+
+ switch (G_VALUE_TYPE(&value)) {
+ case G_TYPE_ULONG:
+ size = g_value_get_ulong(&value);
+ break;
+
+ case G_TYPE_UINT64:
+ size = g_value_get_uint64(&value);
+ break;
+
+ default:
+ g_assert_not_reached();
+ }
+
+ g_value_unset(&value);
+
+ if (size == 0) {
+ char *str = g_strdup_printf ("<i>%s</i>", _("N/A"));
+ g_object_set(renderer, "markup", str, NULL);
+ g_free(str);
+ }
+ else {
+ g_object_set(renderer, "text", procman::format_rate(size, size, FALSE).c_str(), NULL);
+ }
+
+ }
/*
Cell data function to format a size value with SI units (to be used only for disk size, see bugzilla
693630)
diff --git a/src/util.h b/src/util.h
index 8d5fb3d..ab38cac 100644
--- a/src/util.h
+++ b/src/util.h
@@ -47,6 +47,10 @@ namespace procman
GtkTreeModel *model, GtkTreeIter *iter,
gpointer user_data);
+ void io_rate_cell_data_func(GtkTreeViewColumn *col, GtkCellRenderer *renderer,
+ GtkTreeModel *model, GtkTreeIter *iter,
+ gpointer user_data);
+
void size_na_cell_data_func(GtkTreeViewColumn *col, GtkCellRenderer *renderer,
GtkTreeModel *model, GtkTreeIter *iter,
gpointer user_data);
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]