Solaris: add EXE and COMM columns and use merged command line helpers

This commit is contained in:
Christian Göttsche 2021-05-19 17:43:38 +02:00 committed by BenBE
parent 72724d42f3
commit d9feff150c
3 changed files with 21 additions and 5 deletions

View File

@ -16,6 +16,8 @@ in the source distribution for its full text.
POOLID = 104, \
CONTID = 105, \
LWPID = 106, \
\
DUMMY_BUMP_FIELD = PROC_EXE, \
// End of list

View File

@ -46,7 +46,9 @@ const ProcessFieldData Process_fields[LAST_PROCESSFIELD] = {
[TIME] = { .name = "TIME", .title = " TIME+ ", .description = "Total time the process has spent in user and system time", .flags = 0, .defaultSortDesc = true, },
[NLWP] = { .name = "NLWP", .title = "NLWP ", .description = "Number of threads in the process", .flags = 0, },
[TGID] = { .name = "TGID", .title = "TGID", .description = "Thread group ID (i.e. process ID)", .flags = 0, .pidColumn = true, },
[ZONEID] = { .name = "ZONEID", .title = "ZNID", .description = "Zone ID", .flags = 0, .pidColumn = true, },
[PROC_COMM] = { .name = "COMM", .title = "COMM ", .description = "comm string of the process", .flags = 0, },
[PROC_EXE] = { .name = "EXE", .title = "EXE ", .description = "Basename of exe of the process", .flags = 0, },
[ZONEID] = { .name = "ZONEID", .title = "ZONEID", .description = "Zone ID", .flags = 0, .pidColumn = true, },
[ZONE] = { .name = "ZONE", .title = "ZONE ", .description = "Zone name", .flags = 0, },
[PROJID] = { .name = "PROJID", .title = "PRJID", .description = "Project ID", .flags = 0, .pidColumn = true, },
[TASKID] = { .name = "TASKID", .title = "TSKID", .description = "Task ID", .flags = 0, .pidColumn = true, },

View File

@ -296,6 +296,19 @@ void ProcessList_delete(ProcessList* pl) {
free(spl);
}
static void SolarisProcessList_updateExe(pid_t pid, Process* proc) {
char path[32];
xSnprintf(path, sizeof(path), "/proc/%d/path/a.out", pid);
char target[PATH_MAX];
ssize_t ret = readlink(path, target, sizeof(target) - 1);
if (ret <= 0)
return;
target[ret] = '\0';
Process_updateExe(proc, target);
}
/* NOTE: the following is a callback function of type proc_walk_f
* and MUST conform to the appropriate definition in order
* to work. See libproc(3LIB) on a Solaris or Illumos
@ -363,8 +376,9 @@ static int SolarisProcessList_walkproc(psinfo_t* _psinfo, lwpsinfo_t* _lwpsinfo,
sproc->zoneid = _psinfo->pr_zoneid;
sproc->zname = SolarisProcessList_readZoneName(spl->kd, sproc);
proc->user = UsersTable_getRef(pl->usersTable, proc->st_uid);
proc->cmdline = xStrdup(_psinfo->pr_fname);
proc->mergedCommand.cmdlineChanged = true;
SolarisProcessList_updateExe(_psinfo->pr_pid, proc);
Process_updateComm(proc, _psinfo->pr_fname);
Process_updateCmdline(proc, _psinfo->pr_psargs, 0, 0);
}
// End common code pass 1
@ -406,13 +420,11 @@ static int SolarisProcessList_walkproc(psinfo_t* _psinfo, lwpsinfo_t* _lwpsinfo,
proc->time = _lwpsinfo->pr_time.tv_sec;
if (!preExisting) { // Tasks done only for NEW LWPs
proc->isUserlandThread = true;
proc->cmdlineBasenameEnd = -1;
proc->ppid = _psinfo->pr_pid * 1024;
proc->tgid = _psinfo->pr_pid * 1024;
sproc->realppid = _psinfo->pr_pid;
sproc->realtgid = _psinfo->pr_pid;
proc->starttime_ctime = _lwpsinfo->pr_start.tv_sec;
proc->mergedCommand.cmdlineChanged = true;
}
// Top-level process only gets this for the representative LWP