summaryrefslogtreecommitdiffstats
path: root/Process.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 /Process.c
parent558b001e2bdc3e2637da7c80215ad77f9fb8f18b (diff)
Added additional column to monitor OOM killer score of each process
Diffstat (limited to 'Process.c')
-rw-r--r--Process.c28
1 files changed, 28 insertions, 0 deletions
diff --git a/Process.c b/Process.c
index 695e1447..f154657a 100644
--- a/Process.c
+++ b/Process.c
@@ -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;
}*/
@@ -203,6 +209,9 @@ const char *Process_fieldNames[] = {
#ifdef HAVE_CGROUP
"CGROUP",
#endif
+#ifdef HAVE_OOM
+ "OOM",
+#endif
"IO_PRIORITY",
"*** report bug! ***"
};
@@ -229,6 +238,9 @@ const int Process_fieldFlags[] = {
#ifdef HAVE_CGROUP
PROCESS_FLAG_CGROUP,
#endif
+#ifdef HAVE_OOM
+ 0,
+#endif
PROCESS_FLAG_IOPRIO
};
@@ -254,6 +266,9 @@ const char *Process_fieldTitles[] = {
#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:

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