mirror of
https://github.com/xzeldon/htop.git
synced 2025-07-12 12:14:36 +03:00
Added additional column to monitor OOM killer score of each process
This commit is contained in:
@ -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;
|
||||
|
||||
|
Reference in New Issue
Block a user