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

@ -81,6 +81,9 @@ typedef enum ProcessField_ {
#ifdef HAVE_CGROUP
CGROUP,
#endif
#ifdef HAVE_OOM
OOM,
#endif
IO_PRIORITY,
LAST_PROCESSFIELD
} ProcessField;
@ -177,6 +180,9 @@ typedef struct Process_ {
#ifdef HAVE_CGROUP
char* cgroup;
#endif
#ifdef HAVE_OOM
unsigned int oom;
#endif
} Process;
}*/
@ -202,6 +208,9 @@ const char *Process_fieldNames[] = {
#endif
#ifdef HAVE_CGROUP
"CGROUP",
#endif
#ifdef HAVE_OOM
"OOM",
#endif
"IO_PRIORITY",
"*** report bug! ***"
@ -228,6 +237,9 @@ const int Process_fieldFlags[] = {
#endif
#ifdef HAVE_CGROUP
PROCESS_FLAG_CGROUP,
#endif
#ifdef HAVE_OOM
0,
#endif
PROCESS_FLAG_IOPRIO
};
@ -253,6 +265,9 @@ const char *Process_fieldTitles[] = {
#endif
#ifdef HAVE_CGROUP
" CGROUP ",
#endif
#ifdef HAVE_OOM
" OOM ",
#endif
"IO ",
"*** report bug! ***"
@ -276,6 +291,9 @@ void Process_getMaxPid() {
Process_fieldTitles[TGID] = " TGID ";
Process_fieldTitles[PGRP] = " PGRP ";
Process_fieldTitles[SESSION] = " SESN ";
#ifdef HAVE_OOM
Process_fieldTitles[OOM] = " OOM ";
#endif
Process_pidFormat = "%7u ";
Process_tpgidFormat = "%7d ";
} else {
@ -285,6 +303,9 @@ void Process_getMaxPid() {
Process_fieldTitles[TGID] = " TGID ";
Process_fieldTitles[PGRP] = " PGRP ";
Process_fieldTitles[SESSION] = " SESN ";
#ifdef HAVE_OOM
Process_fieldTitles[OOM] = " OOM ";
#endif
Process_pidFormat = "%5u ";
Process_tpgidFormat = "%5d ";
}
@ -545,6 +566,9 @@ static void Process_writeField(Process* this, RichString* str, ProcessField fiel
#ifdef HAVE_CGROUP
case CGROUP: snprintf(buffer, n, "%-10s ", this->cgroup); break;
#endif
#ifdef HAVE_OOM
case OOM: snprintf(buffer, n, Process_pidFormat, this->oom); break;
#endif
case IO_PRIORITY: {
int klass = IOPriority_class(this->ioPriority);
if (klass == IOPRIO_CLASS_NONE) {
@ -814,6 +838,10 @@ int Process_compare(const void* v1, const void* v2) {
case CGROUP:
return strcmp(p1->cgroup ? p1->cgroup : "", p2->cgroup ? p2->cgroup : "");
#endif
#ifdef HAVE_OOM
case OOM:
return (p1->oom - p2->oom);
#endif
case IO_PRIORITY:
return Process_effectiveIOPriority(p1) - Process_effectiveIOPriority(p2);
default: