summaryrefslogtreecommitdiffstats
path: root/ProcessList.c
diff options
context:
space:
mode:
authorLeigh Simpson <leigh.simpson@fusepump.com>2014-01-29 22:41:55 +0000
committerLeigh Simpson <leigh.simpson@fusepump.com>2014-01-29 22:41:55 +0000
commitda236ca318e515a5a1b2156b8dccdf23166c787f (patch)
tree5e33a842e8b4e55fde72ba50bc86fd9e070e769b /ProcessList.c
parent558b001e2bdc3e2637da7c80215ad77f9fb8f18b (diff)
Added additional column to monitor OOM killer score of each process
Diffstat (limited to 'ProcessList.c')
-rw-r--r--ProcessList.c26
1 files changed, 26 insertions, 0 deletions
diff --git a/ProcessList.c b/ProcessList.c
index b470344c..a5b9568b 100644
--- a/ProcessList.c
+++ b/ProcessList.c
@@ -660,6 +660,28 @@ static void ProcessList_readVServerData(Process* process, const char* dirname, c
#endif
+#ifdef HAVE_OOM
+
+static void ProcessList_readOomData(Process* process, const char* dirname, const char* name) {
+ char filename[MAX_NAME+1];
+ snprintf(filename, MAX_NAME, "%s/%s/oom_score", dirname, name);
+ FILE* file = fopen(filename, "r");
+ if (!file)
+ return;
+ char buffer[256];
+ if (!fgets(buffer, 255, file)) {
+ return;
+ }
+ unsigned int oom;
+ int ok = sscanf(buffer, "%u", &oom);
+ if (ok >= 1) {
+ process->oom = oom;
+ }
+ fclose(file);
+}
+
+#endif
+
static bool ProcessList_readCmdlineFile(Process* process, const char* dirname, const char* name) {
if (Process_isKernelThread(process))
return true;
@@ -784,6 +806,10 @@ static bool ProcessList_processEntries(ProcessList* this, const char* dirname, P
ProcessList_readVServerData(process, dirname, name);
#endif
+ #ifdef HAVE_OOM
+ ProcessList_readOomData(process, dirname, name);
+ #endif
+
if (! ProcessList_readCmdlineFile(process, dirname, name))
goto errorReadingProcess;

© 2014-2024 Faster IT GmbH | imprint | privacy policy