From da236ca318e515a5a1b2156b8dccdf23166c787f Mon Sep 17 00:00:00 2001 From: Leigh Simpson Date: Wed, 29 Jan 2014 22:41:55 +0000 Subject: Added additional column to monitor OOM killer score of each process --- ProcessList.c | 26 ++++++++++++++++++++++++++ 1 file changed, 26 insertions(+) (limited to 'ProcessList.c') 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; -- cgit v1.2.3