Rework TTY column for the PCP platform

This commit is contained in:
Nathan Scott 2021-04-15 09:03:12 +10:00
parent 9ce9557e69
commit 4d7cee56f0
3 changed files with 4 additions and 13 deletions

View File

@ -32,7 +32,7 @@ const ProcessFieldData Process_fields[] = {
[PPID] = { .name = "PPID", .title = "PPID", .description = "Parent process ID", .flags = 0, }, [PPID] = { .name = "PPID", .title = "PPID", .description = "Parent process ID", .flags = 0, },
[PGRP] = { .name = "PGRP", .title = "PGRP", .description = "Process group ID", .flags = 0, }, [PGRP] = { .name = "PGRP", .title = "PGRP", .description = "Process group ID", .flags = 0, },
[SESSION] = { .name = "SESSION", .title = "SID", .description = "Process's session ID", .flags = 0, }, [SESSION] = { .name = "SESSION", .title = "SID", .description = "Process's session ID", .flags = 0, },
[TTY_NR] = { .name = "TTY_NR", .title = "TTY ", .description = "Controlling terminal", .flags = 0, }, [TTY] = { .name = "TTY", .title = "TTY ", .description = "Controlling terminal", .flags = 0, },
[TPGID] = { .name = "TPGID", .title = "TPGID", .description = "Process ID of the fg process group of the controlling terminal", .flags = 0, }, [TPGID] = { .name = "TPGID", .title = "TPGID", .description = "Process ID of the fg process group of the controlling terminal", .flags = 0, },
[MINFLT] = { .name = "MINFLT", .title = " MINFLT ", .description = "Number of minor faults which have not required loading a memory page from disk", .flags = 0, .defaultSortDesc = true, }, [MINFLT] = { .name = "MINFLT", .title = " MINFLT ", .description = "Number of minor faults which have not required loading a memory page from disk", .flags = 0, .defaultSortDesc = true, },
[CMINFLT] = { .name = "CMINFLT", .title = " CMINFLT ", .description = "Children processes' minor faults", .flags = 0, .defaultSortDesc = true, }, [CMINFLT] = { .name = "CMINFLT", .title = " CMINFLT ", .description = "Children processes' minor faults", .flags = 0, .defaultSortDesc = true, },
@ -107,7 +107,6 @@ void Process_delete(Object* cast) {
Process_done((Process*)cast); Process_done((Process*)cast);
free(this->cgroup); free(this->cgroup);
free(this->secattr); free(this->secattr);
free(this->ttyDevice);
free(this->procComm); free(this->procComm);
free(this->mergedCommand.str); free(this->mergedCommand.str);
free(this); free(this);
@ -332,13 +331,6 @@ static void PCPProcess_writeField(const Process* this, RichString* str, ProcessF
int attr = CRT_colors[DEFAULT_COLOR]; int attr = CRT_colors[DEFAULT_COLOR];
int n = sizeof(buffer) - 1; int n = sizeof(buffer) - 1;
switch ((int)field) { switch ((int)field) {
case TTY_NR:
if (pp->ttyDevice) {
xSnprintf(buffer, n, "%-8s", pp->ttyDevice + 5 /* skip "/dev/" */);
break;
}
Process_writeField(this, str, field);
break;
case CMINFLT: Process_colorNumber(str, pp->cminflt, coloring); return; case CMINFLT: Process_colorNumber(str, pp->cminflt, coloring); return;
case CMAJFLT: Process_colorNumber(str, pp->cmajflt, coloring); return; case CMAJFLT: Process_colorNumber(str, pp->cmajflt, coloring); return;
case M_DRS: Process_humanNumber(str, pp->m_drs, coloring); return; case M_DRS: Process_humanNumber(str, pp->m_drs, coloring); return;

View File

@ -98,7 +98,6 @@ typedef struct PCPProcess_ {
double io_rate_write_bps; double io_rate_write_bps;
char* cgroup; char* cgroup;
unsigned int oom; unsigned int oom;
char* ttyDevice;
unsigned long long int delay_read_time; unsigned long long int delay_read_time;
unsigned long long cpu_delay_total; unsigned long long cpu_delay_total;
unsigned long long blkio_delay_total; unsigned long long blkio_delay_total;

View File

@ -352,8 +352,8 @@ static char* setString(Metric metric, int pid, int offset, char* string) {
return string; return string;
} }
static void PCPProcessList_updateTTY(PCPProcess* process, int pid, int offset) { static void PCPProcessList_updateTTY(Process* process, int pid, int offset) {
process->ttyDevice = setString(PCP_PROC_TTYNAME, pid, offset, process->ttyDevice); process->tty_name = setString(PCP_PROC_TTYNAME, pid, offset, process->tty_name);
} }
static void PCPProcessList_readCGroups(PCPProcess* process, int pid, int offset) { static void PCPProcessList_readCGroups(PCPProcess* process, int pid, int offset) {
@ -495,7 +495,7 @@ static bool PCPProcessList_updateProcesses(PCPProcessList* this, double period,
PCPProcessList_updateInfo(proc, pid, offset, command, sizeof(command)); PCPProcessList_updateInfo(proc, pid, offset, command, sizeof(command));
proc->starttime_ctime += Platform_getBootTime(); proc->starttime_ctime += Platform_getBootTime();
if (tty_nr != proc->tty_nr) if (tty_nr != proc->tty_nr)
PCPProcessList_updateTTY(pp, pid, offset); PCPProcessList_updateTTY(proc, pid, offset);
float percent_cpu = (pp->utime + pp->stime - lasttimes) / period * 100.0; float percent_cpu = (pp->utime + pp->stime - lasttimes) / period * 100.0;
proc->percent_cpu = isnan(percent_cpu) ? proc->percent_cpu = isnan(percent_cpu) ?