summaryrefslogtreecommitdiff
path: root/src/proctable.cpp
diff options
context:
space:
mode:
authorrbuj <[email protected]>2019-04-20 12:01:36 +0200
committerlukefromdc <[email protected]>2019-04-28 22:34:36 -0400
commitfc1f63b1c04cb6101f3a780e104a7f295c4d307a (patch)
tree0c75dd1010650682f6d199e247ec6d1962511c78 /src/proctable.cpp
parent1f42b9e3ab7f82825f2d0dc83a57163f5c67621c (diff)
downloadmate-system-monitor-fc1f63b1c04cb6101f3a780e104a7f295c4d307a.tar.bz2
mate-system-monitor-fc1f63b1c04cb6101f3a780e104a7f295c4d307a.tar.xz
Add disk IO on process info
Based on GNOME/gnome-system-monitor@60a787b
Diffstat (limited to 'src/proctable.cpp')
-rw-r--r--src/proctable.cpp51
1 files changed, 50 insertions, 1 deletions
diff --git a/src/proctable.cpp b/src/proctable.cpp
index 2e0a4ac..94bf63f 100644
--- a/src/proctable.cpp
+++ b/src/proctable.cpp
@@ -28,6 +28,7 @@
#include <glibtop.h>
#include <glibtop/loadavg.h>
#include <glibtop/proclist.h>
+#include <glibtop/procio.h>
#include <glibtop/procstate.h>
#include <glibtop/procmem.h>
#include <glibtop/procmap.h>
@@ -263,6 +264,10 @@ proctable_new (ProcData * const procdata)
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"
@@ -298,6 +303,10 @@ proctable_new (ProcData * const procdata)
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 */
@@ -397,15 +406,32 @@ proctable_new (ProcData * const procdata)
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::storage_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,
GUINT_TO_POINTER(COL_NICE),
NULL);
break;
+
default:
gtk_tree_view_column_set_attributes(col, cell, "text", i, NULL);
- break;
}
// sorting
@@ -418,6 +444,10 @@ proctable_new (ProcData * const procdata)
case COL_MEMWRITABLE:
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), i,
procman::number_compare_func, GUINT_TO_POINTER(i),
@@ -443,6 +473,10 @@ proctable_new (ProcData * const procdata)
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);
@@ -650,6 +684,10 @@ update_info_mutable_cols(ProcInfo *info)
tree_store_update(model, &info->node, COL_MEMXSERVER, info->memxserver);
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);
@@ -785,6 +823,7 @@ update_info (ProcData *procdata, ProcInfo *info)
glibtop_proc_uid procuid;
glibtop_proc_time proctime;
glibtop_proc_kernel prockernel;
+ glibtop_proc_io procio;
glibtop_get_proc_kernel(&prockernel, info->pid);
g_strlcpy(info->wchan, prockernel.wchan, sizeof info->wchan);
@@ -794,6 +833,7 @@ update_info (ProcData *procdata, 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);
@@ -813,6 +853,15 @@ update_info (ProcData *procdata, ProcInfo *info)
ProcInfo::cpu_times[info->pid] = info->cpu_time = proctime.rtime;
info->nice = procuid.nice;
+ gdouble update_interval_seconds = procdata->config.update_interval / 1000.0;
+ difference = procio.disk_wbytes - info->disk_write_bytes_total;
+ info->disk_write_bytes_current = difference > update_interval_seconds ? difference/update_interval_seconds : 0ULL;
+ difference = procio.disk_rbytes - info->disk_read_bytes_total;
+ info->disk_read_bytes_current = difference > update_interval_seconds ? difference/update_interval_seconds : 0ULL;
+
+ 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
if (info->pid > 0) {