Skip to content

Commit

Permalink
Linux: add process column whether it is marked a container process
Browse files Browse the repository at this point in the history
Might be useful for some users and for debugging the
hideRunningInContainer detection.
  • Loading branch information
cgzones committed Jan 9, 2024
1 parent a8b522c commit 15b78bc
Show file tree
Hide file tree
Showing 4 changed files with 30 additions and 13 deletions.
15 changes: 15 additions & 0 deletions linux/LinuxProcess.c
Original file line number Diff line number Diff line change
Expand Up @@ -106,6 +106,7 @@ const ProcessFieldData Process_fields[LAST_PROCESSFIELD] = {
[CWD] = { .name = "CWD", .title = "CWD ", .description = "The current working directory of the process", .flags = PROCESS_FLAG_CWD, },
[AUTOGROUP_ID] = { .name = "AUTOGROUP_ID", .title = "AGRP", .description = "The autogroup identifier of the process", .flags = PROCESS_FLAG_LINUX_AUTOGROUP, },
[AUTOGROUP_NICE] = { .name = "AUTOGROUP_NICE", .title = " ANI", .description = "Nice value (the higher the value, the more other processes take priority) associated with the process autogroup", .flags = PROCESS_FLAG_LINUX_AUTOGROUP, },
[ISCONTAINER] = { .name = "ISCONTAINER", .title = "CONT ", .description = "Whether the process is running inside a child container", .flags = PROCESS_FLAG_LINUX_ISCONTAINER, },
#ifdef SCHEDULER_SUPPORT
[SCHEDULERPOLICY] = { .name = "SCHEDULERPOLICY", .title = "SCHED ", .description = "Current scheduling policy of the process", .flags = PROCESS_FLAG_SCHEDPOL, },
#endif
Expand Down Expand Up @@ -339,6 +340,18 @@ static void LinuxProcess_rowWriteField(const Row* super, RichString* str, Proces
xSnprintf(buffer, n, "N/A ");
}
break;
case ISCONTAINER:
switch (this->isRunningInContainer) {
case TRI_ON:
xSnprintf(buffer, n, "YES ");
break;
case TRI_OFF:
xSnprintf(buffer, n, "NO ");
break;
default:
xSnprintf(buffer, n, "N/A ");
}
break;
default:
Process_writeField(this, str, field);
return;
Expand Down Expand Up @@ -441,6 +454,8 @@ static int LinuxProcess_compareByKey(const Process* v1, const Process* v2, Proce
}
case GPU_TIME:
return SPACESHIP_NUMBER(p1->gpu_time, p2->gpu_time);
case ISCONTAINER:
return SPACESHIP_NUMBER(v1->isRunningInContainer, v2->isRunningInContainer);
default:
return Process_compareByKey_Base(v1, v2, key);
}
Expand Down
25 changes: 13 additions & 12 deletions linux/LinuxProcess.h
Original file line number Diff line number Diff line change
Expand Up @@ -18,18 +18,19 @@ in the source distribution for its full text.
#include "linux/IOPriority.h"


#define PROCESS_FLAG_LINUX_IOPRIO 0x00000100
#define PROCESS_FLAG_LINUX_OPENVZ 0x00000200
#define PROCESS_FLAG_LINUX_VSERVER 0x00000400
#define PROCESS_FLAG_LINUX_CGROUP 0x00000800
#define PROCESS_FLAG_LINUX_OOM 0x00001000
#define PROCESS_FLAG_LINUX_SMAPS 0x00002000
#define PROCESS_FLAG_LINUX_CTXT 0x00004000
#define PROCESS_FLAG_LINUX_SECATTR 0x00008000
#define PROCESS_FLAG_LINUX_LRS_FIX 0x00010000
#define PROCESS_FLAG_LINUX_DELAYACCT 0x00040000
#define PROCESS_FLAG_LINUX_AUTOGROUP 0x00080000
#define PROCESS_FLAG_LINUX_GPU 0x00100000
#define PROCESS_FLAG_LINUX_IOPRIO 0x00000100
#define PROCESS_FLAG_LINUX_OPENVZ 0x00000200
#define PROCESS_FLAG_LINUX_VSERVER 0x00000400
#define PROCESS_FLAG_LINUX_CGROUP 0x00000800
#define PROCESS_FLAG_LINUX_OOM 0x00001000
#define PROCESS_FLAG_LINUX_SMAPS 0x00002000
#define PROCESS_FLAG_LINUX_CTXT 0x00004000
#define PROCESS_FLAG_LINUX_SECATTR 0x00008000
#define PROCESS_FLAG_LINUX_LRS_FIX 0x00010000
#define PROCESS_FLAG_LINUX_DELAYACCT 0x00040000
#define PROCESS_FLAG_LINUX_AUTOGROUP 0x00080000
#define PROCESS_FLAG_LINUX_GPU 0x00100000
#define PROCESS_FLAG_LINUX_ISCONTAINER 0x00200000

typedef struct LinuxProcess_ {
Process super;
Expand Down
2 changes: 1 addition & 1 deletion linux/LinuxProcessTable.c
Original file line number Diff line number Diff line change
Expand Up @@ -1714,7 +1714,7 @@ static bool LinuxProcessTable_recurseProcTree(LinuxProcessTable* this, openat_ar
}

if (ss->flags & PROCESS_FLAG_LINUX_CTXT
|| (hideRunningInContainer && proc->isRunningInContainer == TRI_INITIAL)
|| ((hideRunningInContainer || ss->flags & PROCESS_FLAG_LINUX_ISCONTAINER) && proc->isRunningInContainer == TRI_INITIAL)
#ifdef HAVE_VSERVER
|| ss->flags & PROCESS_FLAG_LINUX_VSERVER
#endif
Expand Down
1 change: 1 addition & 0 deletions linux/ProcessField.h
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,7 @@ in the source distribution for its full text.
M_PRIV = 131, \
GPU_TIME = 132, \
GPU_PERCENT = 133, \
ISCONTAINER = 134, \
// End of list


Expand Down

0 comments on commit 15b78bc

Please sign in to comment.