2014-11-24 20:55:49 +00:00
|
|
|
/*
|
|
|
|
htop - UnsupportedProcessList.c
|
|
|
|
(C) 2014 Hisham H. Muhammad
|
2020-10-05 07:51:32 +00:00
|
|
|
Released under the GNU GPLv2, see the COPYING file
|
2014-11-24 20:55:49 +00:00
|
|
|
in the source distribution for its full text.
|
|
|
|
*/
|
|
|
|
|
2021-01-28 17:19:38 +00:00
|
|
|
#include "UnsupportedProcessList.h"
|
2014-11-24 20:55:49 +00:00
|
|
|
|
|
|
|
#include <stdlib.h>
|
2015-07-12 16:26:33 +00:00
|
|
|
#include <string.h>
|
2014-11-24 20:55:49 +00:00
|
|
|
|
2021-01-28 17:19:38 +00:00
|
|
|
#include "ProcessList.h"
|
|
|
|
#include "UnsupportedProcess.h"
|
|
|
|
|
2014-11-24 20:55:49 +00:00
|
|
|
|
PCP: support for 'dynamic columns' added at runtime
Implements support for arbitrary Performance Co-Pilot
metrics with per-process instance domains to form new
htop columns. The column-to-metric mappings are setup
using configuration files which will be documented via
man pages as part of a follow-up commit.
We provide an initial set of column configurations so
as to provide new capabilities to pcp-htop: including
configs for containers, open fd counts, scheduler run
queue time, tcp/udp bytes/calls sent/recv, delay acct,
virtual machine guests, detailed virtual memory, swap.
Note there is a change to the configuration file path
resolution algorithm introduced for 'dynamic meters'.
First, look in any custom PCP_HTOP_DIR location. Then
iterate, in priority order, users home directory, then
local sysadmins files in /etc/pcp/htop, then readonly
configuration files below /usr/share/pcp/htop. This
final location becomes the preferred place for our own
shipped meter and column files.
The Settings file (htoprc) writing code is updated to
not using the numeric identifier for dynamic columns.
The same strategy used for dynamic meters is used here
where we write Dynamic(name) so the name can be setup
once more at start. Regular (static) columns writing
to htoprc - i.e. numerically indexed - is unchanged.
2021-07-11 01:11:29 +00:00
|
|
|
ProcessList* ProcessList_new(UsersTable* usersTable, Hashtable* dynamicMeters, Hashtable* dynamicColumns, Hashtable* pidMatchList, uid_t userId) {
|
2016-02-02 14:53:02 +00:00
|
|
|
ProcessList* this = xCalloc(1, sizeof(ProcessList));
|
PCP: support for 'dynamic columns' added at runtime
Implements support for arbitrary Performance Co-Pilot
metrics with per-process instance domains to form new
htop columns. The column-to-metric mappings are setup
using configuration files which will be documented via
man pages as part of a follow-up commit.
We provide an initial set of column configurations so
as to provide new capabilities to pcp-htop: including
configs for containers, open fd counts, scheduler run
queue time, tcp/udp bytes/calls sent/recv, delay acct,
virtual machine guests, detailed virtual memory, swap.
Note there is a change to the configuration file path
resolution algorithm introduced for 'dynamic meters'.
First, look in any custom PCP_HTOP_DIR location. Then
iterate, in priority order, users home directory, then
local sysadmins files in /etc/pcp/htop, then readonly
configuration files below /usr/share/pcp/htop. This
final location becomes the preferred place for our own
shipped meter and column files.
The Settings file (htoprc) writing code is updated to
not using the numeric identifier for dynamic columns.
The same strategy used for dynamic meters is used here
where we write Dynamic(name) so the name can be setup
once more at start. Regular (static) columns writing
to htoprc - i.e. numerically indexed - is unchanged.
2021-07-11 01:11:29 +00:00
|
|
|
ProcessList_init(this, Class(Process), usersTable, dynamicMeters, dynamicColumns, pidMatchList, userId);
|
2019-10-31 16:39:12 +00:00
|
|
|
|
2021-06-12 16:17:28 +00:00
|
|
|
this->existingCPUs = 1;
|
|
|
|
this->activeCPUs = 1;
|
2021-01-28 17:19:38 +00:00
|
|
|
|
2014-11-24 20:55:49 +00:00
|
|
|
return this;
|
|
|
|
}
|
|
|
|
|
2014-11-27 19:48:38 +00:00
|
|
|
void ProcessList_delete(ProcessList* this) {
|
|
|
|
ProcessList_done(this);
|
|
|
|
free(this);
|
|
|
|
}
|
|
|
|
|
2020-10-13 14:03:37 +00:00
|
|
|
void ProcessList_goThroughEntries(ProcessList* super, bool pauseProcessUpdate) {
|
|
|
|
|
|
|
|
// in pause mode only gather global data for meters (CPU/memory/...)
|
2020-11-01 00:09:51 +00:00
|
|
|
if (pauseProcessUpdate) {
|
2020-10-13 14:03:37 +00:00
|
|
|
return;
|
2020-11-01 00:09:51 +00:00
|
|
|
}
|
2020-10-13 14:03:37 +00:00
|
|
|
|
2020-10-31 21:14:27 +00:00
|
|
|
bool preExisting = true;
|
|
|
|
Process* proc;
|
|
|
|
|
|
|
|
proc = ProcessList_getProcess(super, 1, &preExisting, UnsupportedProcess_new);
|
|
|
|
|
|
|
|
/* Empty values */
|
|
|
|
proc->time = proc->time + 10;
|
|
|
|
proc->pid = 1;
|
|
|
|
proc->ppid = 1;
|
|
|
|
proc->tgid = 0;
|
2021-05-19 15:44:33 +00:00
|
|
|
|
|
|
|
Process_updateComm(proc, "commof16char");
|
|
|
|
Process_updateCmdline(proc, "<unsupported architecture>", 0, 0);
|
|
|
|
Process_updateExe(proc, "/path/to/executable");
|
|
|
|
|
2021-05-25 17:14:45 +00:00
|
|
|
if (proc->settings->flags & PROCESS_FLAG_CWD) {
|
|
|
|
proc->procCwd = "/current/working/directory";
|
|
|
|
}
|
|
|
|
|
2020-10-31 21:14:27 +00:00
|
|
|
proc->updated = true;
|
|
|
|
|
|
|
|
proc->state = 'R';
|
2021-04-10 12:08:26 +00:00
|
|
|
proc->isKernelThread = false;
|
|
|
|
proc->isUserlandThread = false;
|
2020-10-31 21:14:27 +00:00
|
|
|
proc->show = true; /* Reflected in proc->settings-> "hideXXX" really */
|
|
|
|
proc->pgrp = 0;
|
|
|
|
proc->session = 0;
|
|
|
|
proc->tty_nr = 0;
|
2021-03-21 18:40:56 +00:00
|
|
|
proc->tty_name = NULL;
|
2020-10-31 21:14:27 +00:00
|
|
|
proc->tpgid = 0;
|
|
|
|
proc->processor = 0;
|
|
|
|
|
|
|
|
proc->percent_cpu = 2.5;
|
|
|
|
proc->percent_mem = 2.5;
|
2021-06-18 18:43:48 +00:00
|
|
|
|
|
|
|
proc->st_uid = 0;
|
|
|
|
proc->user = "nobody"; /* Update whenever proc->st_uid is changed */
|
2020-10-31 21:14:27 +00:00
|
|
|
|
|
|
|
proc->priority = 0;
|
|
|
|
proc->nice = 0;
|
|
|
|
proc->nlwp = 1;
|
|
|
|
proc->starttime_ctime = 1433116800; // Jun 01, 2015
|
|
|
|
Process_fillStarttimeBuffer(proc);
|
|
|
|
|
2020-11-20 16:09:34 +00:00
|
|
|
proc->m_virt = 100;
|
2020-10-31 21:14:27 +00:00
|
|
|
proc->m_resident = 100;
|
|
|
|
|
|
|
|
proc->minflt = 20;
|
|
|
|
proc->majflt = 20;
|
2021-01-28 17:19:38 +00:00
|
|
|
|
|
|
|
if (!preExisting)
|
|
|
|
ProcessList_add(super, proc);
|
2015-07-12 16:26:33 +00:00
|
|
|
}
|
2021-06-12 20:04:37 +00:00
|
|
|
|
|
|
|
bool ProcessList_isCPUonline(const ProcessList* super, unsigned int id) {
|
|
|
|
assert(id < super->existingCPUs);
|
|
|
|
|
|
|
|
(void) super; (void) id;
|
|
|
|
|
|
|
|
return true;
|
|
|
|
}
|