summaryrefslogtreecommitdiff
path: root/src/proctable.cpp
diff options
context:
space:
mode:
authorinfirit <[email protected]>2014-12-18 20:58:16 +0100
committerinfirit <[email protected]>2014-12-18 21:04:53 +0100
commit76eff089e1ba541cece59f6d2f5847f349448f89 (patch)
treea45acda13ac9ff08b898a9f98638a1ee4edcaf45 /src/proctable.cpp
parent396b01dc3e3a704c0015874002b76a5ccda0678a (diff)
downloadmate-system-monitor-76eff089e1ba541cece59f6d2f5847f349448f89.tar.bz2
mate-system-monitor-76eff089e1ba541cece59f6d2f5847f349448f89.tar.xz
Add cgroup support in the process view
Add a new 'Control Group' column to the process view tab. The format for the column is: <path name> (controller name), <path name> (controller name)... Processes that share the same path name across controllers are colesced. For example if a process is in the /foo cgroup for both the memory and cpu controllers, it would display as: /foo (memory,cpu), ... Taken from GSM commits: 2d33adcbc4347c112d57082956b4e199ff7132db Add cgroup support in the process view 645d38a218fedcbf9c7b674740bf213e02933820 Optimize cgroup updating From: Jason Baron <[email protected]>
Diffstat (limited to 'src/proctable.cpp')
-rw-r--r--src/proctable.cpp21
1 files changed, 19 insertions, 2 deletions
diff --git a/src/proctable.cpp b/src/proctable.cpp
index 6824124..13a4fa4 100644
--- a/src/proctable.cpp
+++ b/src/proctable.cpp
@@ -52,6 +52,7 @@
#include "util.h"
#include "interface.h"
#include "selinux.h"
+#include "cgroups.h"
ProcInfo::UserMap ProcInfo::users;
@@ -258,6 +259,7 @@ proctable_new (ProcData * const procdata)
N_("Memory"),
/* xgettext: wchan, see ps(1) or top(1) */
N_("Waiting Channel"),
+ N_("Control Group"),
NULL,
"POINTER"
};
@@ -287,6 +289,7 @@ proctable_new (ProcData * const procdata)
G_TYPE_STRING, /* Arguments */
G_TYPE_ULONG, /* Memory */
G_TYPE_STRING, /* wchan */
+ G_TYPE_STRING, /* Cgroup */
GDK_TYPE_PIXBUF, /* Icon */
G_TYPE_POINTER, /* ProcInfo */
G_TYPE_STRING /* Sexy tooltip */
@@ -330,7 +333,7 @@ proctable_new (ProcData * const procdata)
gtk_tree_view_set_expander_column (GTK_TREE_VIEW (proctree), column);
- for (i = COL_USER; i <= COL_WCHAN; i++) {
+ for (i = COL_USER; i <= COL_CGROUP; i++) {
GtkCellRenderer *cell;
GtkTreeViewColumn *col;
@@ -435,6 +438,14 @@ proctable_new (ProcData * const procdata)
gtk_tree_view_column_set_visible (column, FALSE);
}
+ if (!cgroups_enabled()) {
+ GtkTreeViewColumn *column;
+
+ column = my_gtk_tree_view_get_column_with_sort_column_id(GTK_TREE_VIEW(proctree), COL_CGROUP);
+ gtk_tree_view_column_set_visible(column, FALSE);
+ }
+
+
g_signal_connect (G_OBJECT (gtk_tree_view_get_selection (GTK_TREE_VIEW (proctree))),
"changed",
G_CALLBACK (cb_row_selected), procdata);
@@ -459,6 +470,7 @@ ProcInfo::~ProcInfo()
g_free(this->tooltip);
g_free(this->arguments);
g_free(this->security_context);
+ g_free(this->cgroup_name);
}
@@ -544,7 +556,6 @@ static void get_process_memory_writable(ProcInfo *info)
g_free(maps);
}
-
static void
get_process_memory_info(ProcInfo *info)
{
@@ -593,6 +604,7 @@ update_info_mutable_cols(ProcInfo *info)
tree_store_update(model, &info->node, COL_NICE, info->nice);
tree_store_update(model, &info->node, COL_MEM, info->mem);
tree_store_update(model, &info->node, COL_WCHAN, info->wchan);
+ tree_store_update(model, &info->node, COL_CGROUP, info->cgroup_name);
}
@@ -709,6 +721,9 @@ update_info (ProcData *procdata, ProcInfo *info)
ProcInfo::cpu_times[info->pid] = info->cpu_time = proctime.rtime;
info->nice = procuid.nice;
info->ppid = procuid.ppid;
+
+ /* get cgroup data */
+ get_process_cgroup_info(info);
}
@@ -753,6 +768,8 @@ ProcInfo::ProcInfo(pid_t pid)
info->start_time = proctime.start_time;
get_process_selinux_context (info);
+ info->cgroup_name = NULL;
+ get_process_cgroup_info(info);
}