summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorChristian Göttsche <cgzones@googlemail.com>2021-05-02 13:29:39 +0200
committercgzones <cgzones@googlemail.com>2021-05-23 15:43:23 +0200
commit550a1418606f487941b3dddbf81de17c459db66c (patch)
tree7e0b902b406d7858772dc8b14d65fb4cc72b8de9
parent3d5b6d9282e584557999772d3cedd7e8ceddabbd (diff)
Add ELAPSED process column
Add process columns showing the elapsed time since the process was started. Similar to STARTTIME, but shows the time passed since the process start instead of the fixed start time of the process. Closes https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=782636
-rw-r--r--Process.c4
-rw-r--r--Process.h1
-rw-r--r--darwin/DarwinProcess.c2
-rw-r--r--dragonflybsd/DragonFlyBSDProcess.c1
-rw-r--r--freebsd/FreeBSDProcess.c2
-rw-r--r--linux/LinuxProcess.c1
-rw-r--r--openbsd/OpenBSDProcess.c6
-rw-r--r--solaris/SolarisProcess.c1
-rw-r--r--unsupported/UnsupportedProcess.c2
9 files changed, 17 insertions, 3 deletions
diff --git a/Process.c b/Process.c
index f134be53..b2eb5a01 100644
--- a/Process.c
+++ b/Process.c
@@ -777,6 +777,7 @@ void Process_writeField(const Process* this, RichString* str, ProcessField field
Process_printLeftAlignedField(str, attr, procExe, TASK_COMM_LEN - 1);
return;
}
+ case ELAPSED: Process_printTime(str, /* convert to hundreds of a second */ this->processList->realtimeMs / 10 - 100 * this->starttime_ctime, coloring); return;
case MAJFLT: Process_printCount(str, this->majflt, coloring); return;
case MINFLT: Process_printCount(str, this->minflt, coloring); return;
case M_RESIDENT: Process_printKBytes(str, this->m_resident, coloring); return;
@@ -1073,6 +1074,9 @@ int Process_compareByKey_Base(const Process* p1, const Process* p2, ProcessField
const char *exe2 = p2->procExe ? (p2->procExe + p2->procExeBasenameOffset) : (Process_isKernelThread(p2) ? kthreadID : "");
return SPACESHIP_NULLSTR(exe1, exe2);
}
+ case ELAPSED:
+ r = -SPACESHIP_NUMBER(p1->starttime_ctime, p2->starttime_ctime);
+ return r != 0 ? r : SPACESHIP_NUMBER(p1->pid, p2->pid);
case MAJFLT:
return SPACESHIP_NUMBER(p1->majflt, p2->majflt);
case MINFLT:
diff --git a/Process.h b/Process.h
index dfd28135..b2d3482e 100644
--- a/Process.h
+++ b/Process.h
@@ -46,6 +46,7 @@ typedef enum ProcessField_ {
NLWP = 51,
TGID = 52,
PERCENT_NORM_CPU = 53,
+ ELAPSED = 54,
PROC_COMM = 124,
PROC_EXE = 125,
diff --git a/darwin/DarwinProcess.c b/darwin/DarwinProcess.c
index 49265d6f..7aaee110 100644
--- a/darwin/DarwinProcess.c
+++ b/darwin/DarwinProcess.c
@@ -33,7 +33,7 @@ const ProcessFieldData Process_fields[LAST_PROCESSFIELD] = {
[PRIORITY] = { .name = "PRIORITY", .title = "PRI ", .description = "Kernel's internal priority for the process", .flags = 0, },
[NICE] = { .name = "NICE", .title = " NI ", .description = "Nice value (the higher the value, the more it lets other processes take priority)", .flags = 0, },
[STARTTIME] = { .name = "STARTTIME", .title = "START ", .description = "Time the process was started", .flags = 0, },
-
+ [ELAPSED] = { .name = "ELAPSED", .title = "ELAPSED ", .description = "Time since the process was started", .flags = 0, },
[PROCESSOR] = { .name = "PROCESSOR", .title = "CPU ", .description = "Id of the CPU the process last executed on", .flags = 0, },
[M_VIRT] = { .name = "M_VIRT", .title = " VIRT ", .description = "Total program size in virtual memory", .flags = 0, .defaultSortDesc = true, },
[M_RESIDENT] = { .name = "M_RESIDENT", .title = " RES ", .description = "Resident set size, size of the text and data sections, plus stack usage", .flags = 0, .defaultSortDesc = true, },
diff --git a/dragonflybsd/DragonFlyBSDProcess.c b/dragonflybsd/DragonFlyBSDProcess.c
index 662fb225..591aeb77 100644
--- a/dragonflybsd/DragonFlyBSDProcess.c
+++ b/dragonflybsd/DragonFlyBSDProcess.c
@@ -33,6 +33,7 @@ const ProcessFieldData Process_fields[LAST_PROCESSFIELD] = {
[PRIORITY] = { .name = "PRIORITY", .title = "PRI ", .description = "Kernel's internal priority for the process", .flags = 0, },
[NICE] = { .name = "NICE", .title = " NI ", .description = "Nice value (the higher the value, the more it lets other processes take priority)", .flags = 0, },
[STARTTIME] = { .name = "STARTTIME", .title = "START ", .description = "Time the process was started", .flags = 0, },
+ [ELAPSED] = { .name = "ELAPSED", .title = "ELAPSED ", .description = "Time since the process was started", .flags = 0, },
[PROCESSOR] = { .name = "PROCESSOR", .title = "CPU ", .description = "Id of the CPU the process last executed on", .flags = 0, },
[M_VIRT] = { .name = "M_VIRT", .title = " VIRT ", .description = "Total program size in virtual memory", .flags = 0, .defaultSortDesc = true, },
[M_RESIDENT] = { .name = "M_RESIDENT", .title = " RES ", .description = "Resident set size, size of the text and data sections, plus stack usage", .flags = 0, .defaultSortDesc = true, },
diff --git a/freebsd/FreeBSDProcess.c b/freebsd/FreeBSDProcess.c
index 4fd02a9b..3e282a3e 100644
--- a/freebsd/FreeBSDProcess.c
+++ b/freebsd/FreeBSDProcess.c
@@ -32,7 +32,7 @@ const ProcessFieldData Process_fields[LAST_PROCESSFIELD] = {
[PRIORITY] = { .name = "PRIORITY", .title = "PRI ", .description = "Kernel's internal priority for the process", .flags = 0, },
[NICE] = { .name = "NICE", .title = " NI ", .description = "Nice value (the higher the value, the more it lets other processes take priority)", .flags = 0, },
[STARTTIME] = { .name = "STARTTIME", .title = "START ", .description = "Time the process was started", .flags = 0, },
-
+ [ELAPSED] = { .name = "ELAPSED", .title = "ELAPSED ", .description = "Time since the process was started", .flags = 0, },
[PROCESSOR] = { .name = "PROCESSOR", .title = "CPU ", .description = "Id of the CPU the process last executed on", .flags = 0, },
[M_VIRT] = { .name = "M_VIRT", .title = " VIRT ", .description = "Total program size in virtual memory", .flags = 0, .defaultSortDesc = true, },
[M_RESIDENT] = { .name = "M_RESIDENT", .title = " RES ", .description = "Resident set size, size of the text and data sections, plus stack usage", .flags = 0, .defaultSortDesc = true, },
diff --git a/linux/LinuxProcess.c b/linux/LinuxProcess.c
index f5ee21bd..d90c8d1e 100644
--- a/linux/LinuxProcess.c
+++ b/linux/LinuxProcess.c
@@ -50,6 +50,7 @@ const ProcessFieldData Process_fields[LAST_PROCESSFIELD] = {
[PRIORITY] = { .name = "PRIORITY", .title = "PRI ", .description = "Kernel's internal priority for the process", .flags = 0, },
[NICE] = { .name = "NICE", .title = " NI ", .description = "Nice value (the higher the value, the more it lets other processes take priority)", .flags = 0, },
[STARTTIME] = { .name = "STARTTIME", .title = "START ", .description = "Time the process was started", .flags = 0, },
+ [ELAPSED] = { .name = "ELAPSED", .title = "ELAPSED ", .description = "Time since the process was started", .flags = 0, },
[PROCESSOR] = { .name = "PROCESSOR", .title = "CPU ", .description = "Id of the CPU the process last executed on", .flags = 0, },
[M_VIRT] = { .name = "M_VIRT", .title = " VIRT ", .description = "Total program size in virtual memory", .flags = 0, .defaultSortDesc = true, },
[M_RESIDENT] = { .name = "M_RESIDENT", .title = " RES ", .description = "Resident set size, size of the text and data sections, plus stack usage", .flags = 0, .defaultSortDesc = true, },
diff --git a/openbsd/OpenBSDProcess.c b/openbsd/OpenBSDProcess.c
index b518da24..58e2d52b 100644
--- a/openbsd/OpenBSDProcess.c
+++ b/openbsd/OpenBSDProcess.c
@@ -108,6 +108,12 @@ const ProcessFieldData Process_fields[LAST_PROCESSFIELD] = {
.description = "Time the process was started",
.flags = 0,
},
+ [ELAPSED] = {
+ .name = "ELAPSED",
+ .title = "ELAPSED ",
+ .description = "Time since the process was started",
+ .flags = 0,
+ },
[PROCESSOR] = {
.name = "PROCESSOR",
.title = "CPU ",
diff --git a/solaris/SolarisProcess.c b/solaris/SolarisProcess.c
index e49569e9..713bc137 100644
--- a/solaris/SolarisProcess.c
+++ b/solaris/SolarisProcess.c
@@ -35,6 +35,7 @@ const ProcessFieldData Process_fields[LAST_PROCESSFIELD] = {
[PRIORITY] = { .name = "PRIORITY", .title = "PRI ", .description = "Kernel's internal priority for the process", .flags = 0, },
[NICE] = { .name = "NICE", .title = " NI ", .description = "Nice value (the higher the value, the more it lets other processes take priority)", .flags = 0, },
[STARTTIME] = { .name = "STARTTIME", .title = "START ", .description = "Time the process was started", .flags = 0, },
+ [ELAPSED] = { .name = "ELAPSED", .title = "ELAPSED ", .description = "Time since the process was started", .flags = 0, },
[PROCESSOR] = { .name = "PROCESSOR", .title = "CPU ", .description = "Id of the CPU the process last executed on", .flags = 0, },
[M_VIRT] = { .name = "M_VIRT", .title = " VIRT ", .description = "Total program size in virtual memory", .flags = 0, .defaultSortDesc = true, },
[M_RESIDENT] = { .name = "M_RESIDENT", .title = " RES ", .description = "Resident set size, size of the text and data sections, plus stack usage", .flags = 0, .defaultSortDesc = true, },
diff --git a/unsupported/UnsupportedProcess.c b/unsupported/UnsupportedProcess.c
index 86bec176..1b9159b3 100644
--- a/unsupported/UnsupportedProcess.c
+++ b/unsupported/UnsupportedProcess.c
@@ -30,7 +30,7 @@ const ProcessFieldData Process_fields[LAST_PROCESSFIELD] = {
[PRIORITY] = { .name = "PRIORITY", .title = "PRI ", .description = "Kernel's internal priority for the process", .flags = 0, },
[NICE] = { .name = "NICE", .title = " NI ", .description = "Nice value (the higher the value, the more it lets other processes take priority)", .flags = 0, },
[STARTTIME] = { .name = "STARTTIME", .title = "START ", .description = "Time the process was started", .flags = 0, },
-
+ [ELAPSED] = { .name = "ELAPSED", .title = "ELAPSED ", .description = "Time since the process was started", .flags = 0, },
[PROCESSOR] = { .name = "PROCESSOR", .title = "CPU ", .description = "Id of the CPU the process last executed on", .flags = 0, },
[M_VIRT] = { .name = "M_VIRT", .title = " VIRT ", .description = "Total program size in virtual memory", .flags = 0, .defaultSortDesc = true, },
[M_RESIDENT] = { .name = "M_RESIDENT", .title = " RES ", .description = "Resident set size, size of the text and data sections, plus stack usage", .flags = 0, .defaultSortDesc = true, },

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