Added additional column to monitor OOM killer score of each process

This commit is contained in:
Leigh Simpson
2014-01-29 22:41:55 +00:00
parent 558b001e2b
commit da236ca318
6 changed files with 72 additions and 0 deletions

View File

@ -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;