Add a platform for Performance Co-Pilot (PCP) metrics
This introduces an initial platform for extracting metrics
using the PCP performance metrics API - PMAPI(3). It can
be used via the --enable-pcp=yes configure option.
So far I've added support for live localhost metrics only,
and only using pre-defined metrics already found in htop.
If available, all sampling is performed by pmcd(1) - else,
we fallback to htop doing the metric sampling itself (all
below the PMAPI). When pmcd is used, it may be configured
to run children with elevated privileges, so htop does not
need to be setuid (authentication with pmcd is available).
Additionally, the PMAPI allows us to support archives (for
historical analysis and for automated regression tests in
htop). We'll need platform-specific command line argument
additions, which isn't yet feasible in htop (not difficult
to add though).
The goal of this first version is minimal impact in terms
of modifying the htop codebase, to introduce key ideas in
PCP (metric namespace, metadata, APIs and so on) and give
us something to discuss, experiment with and build on.
2021-02-17 03:43:56 +00:00
|
|
|
/*
|
|
|
|
htop - PCPProcessList.c
|
|
|
|
(C) 2014 Hisham H. Muhammad
|
2021-03-16 22:54:15 +00:00
|
|
|
(C) 2020-2021 htop dev team
|
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
|
|
|
(C) 2020-2021 Red Hat, Inc.
|
2021-09-22 09:33:00 +00:00
|
|
|
Released under the GNU GPLv2+, see the COPYING file
|
Add a platform for Performance Co-Pilot (PCP) metrics
This introduces an initial platform for extracting metrics
using the PCP performance metrics API - PMAPI(3). It can
be used via the --enable-pcp=yes configure option.
So far I've added support for live localhost metrics only,
and only using pre-defined metrics already found in htop.
If available, all sampling is performed by pmcd(1) - else,
we fallback to htop doing the metric sampling itself (all
below the PMAPI). When pmcd is used, it may be configured
to run children with elevated privileges, so htop does not
need to be setuid (authentication with pmcd is available).
Additionally, the PMAPI allows us to support archives (for
historical analysis and for automated regression tests in
htop). We'll need platform-specific command line argument
additions, which isn't yet feasible in htop (not difficult
to add though).
The goal of this first version is minimal impact in terms
of modifying the htop codebase, to introduce key ideas in
PCP (metric namespace, metadata, APIs and so on) and give
us something to discuss, experiment with and build on.
2021-02-17 03:43:56 +00:00
|
|
|
in the source distribution for its full text.
|
|
|
|
*/
|
|
|
|
|
|
|
|
#include "config.h" // IWYU pragma: keep
|
|
|
|
|
2021-06-07 03:46:29 +00:00
|
|
|
#include "pcp/PCPProcessList.h"
|
Add a platform for Performance Co-Pilot (PCP) metrics
This introduces an initial platform for extracting metrics
using the PCP performance metrics API - PMAPI(3). It can
be used via the --enable-pcp=yes configure option.
So far I've added support for live localhost metrics only,
and only using pre-defined metrics already found in htop.
If available, all sampling is performed by pmcd(1) - else,
we fallback to htop doing the metric sampling itself (all
below the PMAPI). When pmcd is used, it may be configured
to run children with elevated privileges, so htop does not
need to be setuid (authentication with pmcd is available).
Additionally, the PMAPI allows us to support archives (for
historical analysis and for automated regression tests in
htop). We'll need platform-specific command line argument
additions, which isn't yet feasible in htop (not difficult
to add though).
The goal of this first version is minimal impact in terms
of modifying the htop codebase, to introduce key ideas in
PCP (metric namespace, metadata, APIs and so on) and give
us something to discuss, experiment with and build on.
2021-02-17 03:43:56 +00:00
|
|
|
|
2021-08-14 21:30:19 +00:00
|
|
|
#include <assert.h>
|
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
|
|
|
#include <limits.h>
|
Add a platform for Performance Co-Pilot (PCP) metrics
This introduces an initial platform for extracting metrics
using the PCP performance metrics API - PMAPI(3). It can
be used via the --enable-pcp=yes configure option.
So far I've added support for live localhost metrics only,
and only using pre-defined metrics already found in htop.
If available, all sampling is performed by pmcd(1) - else,
we fallback to htop doing the metric sampling itself (all
below the PMAPI). When pmcd is used, it may be configured
to run children with elevated privileges, so htop does not
need to be setuid (authentication with pmcd is available).
Additionally, the PMAPI allows us to support archives (for
historical analysis and for automated regression tests in
htop). We'll need platform-specific command line argument
additions, which isn't yet feasible in htop (not difficult
to add though).
The goal of this first version is minimal impact in terms
of modifying the htop codebase, to introduce key ideas in
PCP (metric namespace, metadata, APIs and so on) and give
us something to discuss, experiment with and build on.
2021-02-17 03:43:56 +00:00
|
|
|
#include <math.h>
|
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
|
|
|
#include <stdlib.h>
|
|
|
|
#include <string.h>
|
|
|
|
#include <sys/time.h>
|
Add a platform for Performance Co-Pilot (PCP) metrics
This introduces an initial platform for extracting metrics
using the PCP performance metrics API - PMAPI(3). It can
be used via the --enable-pcp=yes configure option.
So far I've added support for live localhost metrics only,
and only using pre-defined metrics already found in htop.
If available, all sampling is performed by pmcd(1) - else,
we fallback to htop doing the metric sampling itself (all
below the PMAPI). When pmcd is used, it may be configured
to run children with elevated privileges, so htop does not
need to be setuid (authentication with pmcd is available).
Additionally, the PMAPI allows us to support archives (for
historical analysis and for automated regression tests in
htop). We'll need platform-specific command line argument
additions, which isn't yet feasible in htop (not difficult
to add though).
The goal of this first version is minimal impact in terms
of modifying the htop codebase, to introduce key ideas in
PCP (metric namespace, metadata, APIs and so on) and give
us something to discuss, experiment with and build on.
2021-02-17 03:43:56 +00:00
|
|
|
|
|
|
|
#include "Macros.h"
|
|
|
|
#include "Object.h"
|
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
|
|
|
#include "Platform.h"
|
Add a platform for Performance Co-Pilot (PCP) metrics
This introduces an initial platform for extracting metrics
using the PCP performance metrics API - PMAPI(3). It can
be used via the --enable-pcp=yes configure option.
So far I've added support for live localhost metrics only,
and only using pre-defined metrics already found in htop.
If available, all sampling is performed by pmcd(1) - else,
we fallback to htop doing the metric sampling itself (all
below the PMAPI). When pmcd is used, it may be configured
to run children with elevated privileges, so htop does not
need to be setuid (authentication with pmcd is available).
Additionally, the PMAPI allows us to support archives (for
historical analysis and for automated regression tests in
htop). We'll need platform-specific command line argument
additions, which isn't yet feasible in htop (not difficult
to add though).
The goal of this first version is minimal impact in terms
of modifying the htop codebase, to introduce key ideas in
PCP (metric namespace, metadata, APIs and so on) and give
us something to discuss, experiment with and build on.
2021-02-17 03:43:56 +00:00
|
|
|
#include "Process.h"
|
|
|
|
#include "Settings.h"
|
|
|
|
#include "XUtils.h"
|
|
|
|
|
2021-08-14 21:30:19 +00:00
|
|
|
#include "pcp/PCPMetric.h"
|
2021-06-07 03:46:29 +00:00
|
|
|
#include "pcp/PCPProcess.h"
|
|
|
|
|
Add a platform for Performance Co-Pilot (PCP) metrics
This introduces an initial platform for extracting metrics
using the PCP performance metrics API - PMAPI(3). It can
be used via the --enable-pcp=yes configure option.
So far I've added support for live localhost metrics only,
and only using pre-defined metrics already found in htop.
If available, all sampling is performed by pmcd(1) - else,
we fallback to htop doing the metric sampling itself (all
below the PMAPI). When pmcd is used, it may be configured
to run children with elevated privileges, so htop does not
need to be setuid (authentication with pmcd is available).
Additionally, the PMAPI allows us to support archives (for
historical analysis and for automated regression tests in
htop). We'll need platform-specific command line argument
additions, which isn't yet feasible in htop (not difficult
to add though).
The goal of this first version is minimal impact in terms
of modifying the htop codebase, to introduce key ideas in
PCP (metric namespace, metadata, APIs and so on) and give
us something to discuss, experiment with and build on.
2021-02-17 03:43:56 +00:00
|
|
|
|
|
|
|
static void PCPProcessList_updateCPUcount(PCPProcessList* this) {
|
|
|
|
ProcessList* pl = &(this->super);
|
2021-08-14 21:30:19 +00:00
|
|
|
pl->activeCPUs = PCPMetric_instanceCount(PCP_PERCPU_SYSTEM);
|
2021-08-09 02:42:45 +00:00
|
|
|
unsigned int cpus = Platform_getMaxCPU();
|
2021-06-12 16:17:28 +00:00
|
|
|
if (cpus == pl->existingCPUs)
|
Add a platform for Performance Co-Pilot (PCP) metrics
This introduces an initial platform for extracting metrics
using the PCP performance metrics API - PMAPI(3). It can
be used via the --enable-pcp=yes configure option.
So far I've added support for live localhost metrics only,
and only using pre-defined metrics already found in htop.
If available, all sampling is performed by pmcd(1) - else,
we fallback to htop doing the metric sampling itself (all
below the PMAPI). When pmcd is used, it may be configured
to run children with elevated privileges, so htop does not
need to be setuid (authentication with pmcd is available).
Additionally, the PMAPI allows us to support archives (for
historical analysis and for automated regression tests in
htop). We'll need platform-specific command line argument
additions, which isn't yet feasible in htop (not difficult
to add though).
The goal of this first version is minimal impact in terms
of modifying the htop codebase, to introduce key ideas in
PCP (metric namespace, metadata, APIs and so on) and give
us something to discuss, experiment with and build on.
2021-02-17 03:43:56 +00:00
|
|
|
return;
|
2021-08-17 04:41:55 +00:00
|
|
|
if (cpus == 0)
|
2021-08-09 02:42:45 +00:00
|
|
|
cpus = pl->activeCPUs;
|
|
|
|
if (cpus <= 1)
|
|
|
|
cpus = pl->activeCPUs = 1;
|
2021-06-12 16:17:28 +00:00
|
|
|
pl->existingCPUs = cpus;
|
|
|
|
|
Add a platform for Performance Co-Pilot (PCP) metrics
This introduces an initial platform for extracting metrics
using the PCP performance metrics API - PMAPI(3). It can
be used via the --enable-pcp=yes configure option.
So far I've added support for live localhost metrics only,
and only using pre-defined metrics already found in htop.
If available, all sampling is performed by pmcd(1) - else,
we fallback to htop doing the metric sampling itself (all
below the PMAPI). When pmcd is used, it may be configured
to run children with elevated privileges, so htop does not
need to be setuid (authentication with pmcd is available).
Additionally, the PMAPI allows us to support archives (for
historical analysis and for automated regression tests in
htop). We'll need platform-specific command line argument
additions, which isn't yet feasible in htop (not difficult
to add though).
The goal of this first version is minimal impact in terms
of modifying the htop codebase, to introduce key ideas in
PCP (metric namespace, metadata, APIs and so on) and give
us something to discuss, experiment with and build on.
2021-02-17 03:43:56 +00:00
|
|
|
free(this->percpu);
|
|
|
|
free(this->values);
|
|
|
|
|
|
|
|
this->percpu = xCalloc(cpus, sizeof(pmAtomValue *));
|
2021-03-25 06:24:14 +00:00
|
|
|
for (unsigned int i = 0; i < cpus; i++)
|
Add a platform for Performance Co-Pilot (PCP) metrics
This introduces an initial platform for extracting metrics
using the PCP performance metrics API - PMAPI(3). It can
be used via the --enable-pcp=yes configure option.
So far I've added support for live localhost metrics only,
and only using pre-defined metrics already found in htop.
If available, all sampling is performed by pmcd(1) - else,
we fallback to htop doing the metric sampling itself (all
below the PMAPI). When pmcd is used, it may be configured
to run children with elevated privileges, so htop does not
need to be setuid (authentication with pmcd is available).
Additionally, the PMAPI allows us to support archives (for
historical analysis and for automated regression tests in
htop). We'll need platform-specific command line argument
additions, which isn't yet feasible in htop (not difficult
to add though).
The goal of this first version is minimal impact in terms
of modifying the htop codebase, to introduce key ideas in
PCP (metric namespace, metadata, APIs and so on) and give
us something to discuss, experiment with and build on.
2021-02-17 03:43:56 +00:00
|
|
|
this->percpu[i] = xCalloc(CPU_METRIC_COUNT, sizeof(pmAtomValue));
|
|
|
|
this->values = xCalloc(cpus, sizeof(pmAtomValue));
|
|
|
|
}
|
|
|
|
|
|
|
|
static char* setUser(UsersTable* this, unsigned int uid, int pid, int offset) {
|
|
|
|
char* name = Hashtable_get(this->users, uid);
|
|
|
|
if (name)
|
|
|
|
return name;
|
|
|
|
|
|
|
|
pmAtomValue value;
|
2021-08-14 21:30:19 +00:00
|
|
|
if (PCPMetric_instance(PCP_PROC_ID_USER, pid, offset, &value, PM_TYPE_STRING)) {
|
Add a platform for Performance Co-Pilot (PCP) metrics
This introduces an initial platform for extracting metrics
using the PCP performance metrics API - PMAPI(3). It can
be used via the --enable-pcp=yes configure option.
So far I've added support for live localhost metrics only,
and only using pre-defined metrics already found in htop.
If available, all sampling is performed by pmcd(1) - else,
we fallback to htop doing the metric sampling itself (all
below the PMAPI). When pmcd is used, it may be configured
to run children with elevated privileges, so htop does not
need to be setuid (authentication with pmcd is available).
Additionally, the PMAPI allows us to support archives (for
historical analysis and for automated regression tests in
htop). We'll need platform-specific command line argument
additions, which isn't yet feasible in htop (not difficult
to add though).
The goal of this first version is minimal impact in terms
of modifying the htop codebase, to introduce key ideas in
PCP (metric namespace, metadata, APIs and so on) and give
us something to discuss, experiment with and build on.
2021-02-17 03:43:56 +00:00
|
|
|
Hashtable_put(this->users, uid, value.cp);
|
|
|
|
name = value.cp;
|
|
|
|
}
|
|
|
|
return name;
|
|
|
|
}
|
|
|
|
|
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) {
|
Add a platform for Performance Co-Pilot (PCP) metrics
This introduces an initial platform for extracting metrics
using the PCP performance metrics API - PMAPI(3). It can
be used via the --enable-pcp=yes configure option.
So far I've added support for live localhost metrics only,
and only using pre-defined metrics already found in htop.
If available, all sampling is performed by pmcd(1) - else,
we fallback to htop doing the metric sampling itself (all
below the PMAPI). When pmcd is used, it may be configured
to run children with elevated privileges, so htop does not
need to be setuid (authentication with pmcd is available).
Additionally, the PMAPI allows us to support archives (for
historical analysis and for automated regression tests in
htop). We'll need platform-specific command line argument
additions, which isn't yet feasible in htop (not difficult
to add though).
The goal of this first version is minimal impact in terms
of modifying the htop codebase, to introduce key ideas in
PCP (metric namespace, metadata, APIs and so on) and give
us something to discuss, experiment with and build on.
2021-02-17 03:43:56 +00:00
|
|
|
PCPProcessList* this = xCalloc(1, sizeof(PCPProcessList));
|
|
|
|
ProcessList* super = &(this->super);
|
|
|
|
|
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(super, Class(PCPProcess), usersTable, dynamicMeters, dynamicColumns, pidMatchList, userId);
|
Add a platform for Performance Co-Pilot (PCP) metrics
This introduces an initial platform for extracting metrics
using the PCP performance metrics API - PMAPI(3). It can
be used via the --enable-pcp=yes configure option.
So far I've added support for live localhost metrics only,
and only using pre-defined metrics already found in htop.
If available, all sampling is performed by pmcd(1) - else,
we fallback to htop doing the metric sampling itself (all
below the PMAPI). When pmcd is used, it may be configured
to run children with elevated privileges, so htop does not
need to be setuid (authentication with pmcd is available).
Additionally, the PMAPI allows us to support archives (for
historical analysis and for automated regression tests in
htop). We'll need platform-specific command line argument
additions, which isn't yet feasible in htop (not difficult
to add though).
The goal of this first version is minimal impact in terms
of modifying the htop codebase, to introduce key ideas in
PCP (metric namespace, metadata, APIs and so on) and give
us something to discuss, experiment with and build on.
2021-02-17 03:43:56 +00:00
|
|
|
|
|
|
|
struct timeval timestamp;
|
|
|
|
gettimeofday(×tamp, NULL);
|
|
|
|
this->timestamp = pmtimevalToReal(×tamp);
|
|
|
|
|
|
|
|
this->cpu = xCalloc(CPU_METRIC_COUNT, sizeof(pmAtomValue));
|
|
|
|
PCPProcessList_updateCPUcount(this);
|
|
|
|
|
|
|
|
return super;
|
|
|
|
}
|
|
|
|
|
|
|
|
void ProcessList_delete(ProcessList* pl) {
|
|
|
|
PCPProcessList* this = (PCPProcessList*) pl;
|
|
|
|
ProcessList_done(pl);
|
|
|
|
free(this->values);
|
2021-06-12 16:17:28 +00:00
|
|
|
for (unsigned int i = 0; i < pl->existingCPUs; i++)
|
Add a platform for Performance Co-Pilot (PCP) metrics
This introduces an initial platform for extracting metrics
using the PCP performance metrics API - PMAPI(3). It can
be used via the --enable-pcp=yes configure option.
So far I've added support for live localhost metrics only,
and only using pre-defined metrics already found in htop.
If available, all sampling is performed by pmcd(1) - else,
we fallback to htop doing the metric sampling itself (all
below the PMAPI). When pmcd is used, it may be configured
to run children with elevated privileges, so htop does not
need to be setuid (authentication with pmcd is available).
Additionally, the PMAPI allows us to support archives (for
historical analysis and for automated regression tests in
htop). We'll need platform-specific command line argument
additions, which isn't yet feasible in htop (not difficult
to add though).
The goal of this first version is minimal impact in terms
of modifying the htop codebase, to introduce key ideas in
PCP (metric namespace, metadata, APIs and so on) and give
us something to discuss, experiment with and build on.
2021-02-17 03:43:56 +00:00
|
|
|
free(this->percpu[i]);
|
|
|
|
free(this->percpu);
|
|
|
|
free(this->cpu);
|
|
|
|
free(this);
|
|
|
|
}
|
|
|
|
|
2021-08-06 06:45:30 +00:00
|
|
|
static inline long Metric_instance_s32(int metric, int pid, int offset, long fallback) {
|
2021-06-07 23:46:02 +00:00
|
|
|
pmAtomValue value;
|
2021-08-14 21:30:19 +00:00
|
|
|
if (PCPMetric_instance(metric, pid, offset, &value, PM_TYPE_32))
|
2021-06-07 23:46:02 +00:00
|
|
|
return value.l;
|
|
|
|
return fallback;
|
Add a platform for Performance Co-Pilot (PCP) metrics
This introduces an initial platform for extracting metrics
using the PCP performance metrics API - PMAPI(3). It can
be used via the --enable-pcp=yes configure option.
So far I've added support for live localhost metrics only,
and only using pre-defined metrics already found in htop.
If available, all sampling is performed by pmcd(1) - else,
we fallback to htop doing the metric sampling itself (all
below the PMAPI). When pmcd is used, it may be configured
to run children with elevated privileges, so htop does not
need to be setuid (authentication with pmcd is available).
Additionally, the PMAPI allows us to support archives (for
historical analysis and for automated regression tests in
htop). We'll need platform-specific command line argument
additions, which isn't yet feasible in htop (not difficult
to add though).
The goal of this first version is minimal impact in terms
of modifying the htop codebase, to introduce key ideas in
PCP (metric namespace, metadata, APIs and so on) and give
us something to discuss, experiment with and build on.
2021-02-17 03:43:56 +00:00
|
|
|
}
|
|
|
|
|
2021-08-06 06:45:30 +00:00
|
|
|
static inline long long Metric_instance_s64(int metric, int pid, int offset, long long fallback) {
|
|
|
|
pmAtomValue value;
|
2021-08-14 21:30:19 +00:00
|
|
|
if (PCPMetric_instance(metric, pid, offset, &value, PM_TYPE_64))
|
2021-08-06 06:45:30 +00:00
|
|
|
return value.l;
|
|
|
|
return fallback;
|
|
|
|
}
|
|
|
|
|
2021-06-07 23:46:02 +00:00
|
|
|
static inline unsigned long Metric_instance_u32(int metric, int pid, int offset, unsigned long fallback) {
|
Add a platform for Performance Co-Pilot (PCP) metrics
This introduces an initial platform for extracting metrics
using the PCP performance metrics API - PMAPI(3). It can
be used via the --enable-pcp=yes configure option.
So far I've added support for live localhost metrics only,
and only using pre-defined metrics already found in htop.
If available, all sampling is performed by pmcd(1) - else,
we fallback to htop doing the metric sampling itself (all
below the PMAPI). When pmcd is used, it may be configured
to run children with elevated privileges, so htop does not
need to be setuid (authentication with pmcd is available).
Additionally, the PMAPI allows us to support archives (for
historical analysis and for automated regression tests in
htop). We'll need platform-specific command line argument
additions, which isn't yet feasible in htop (not difficult
to add though).
The goal of this first version is minimal impact in terms
of modifying the htop codebase, to introduce key ideas in
PCP (metric namespace, metadata, APIs and so on) and give
us something to discuss, experiment with and build on.
2021-02-17 03:43:56 +00:00
|
|
|
pmAtomValue value;
|
2021-08-14 21:30:19 +00:00
|
|
|
if (PCPMetric_instance(metric, pid, offset, &value, PM_TYPE_U32))
|
2021-06-07 23:46:02 +00:00
|
|
|
return value.ul;
|
|
|
|
return fallback;
|
|
|
|
}
|
Add a platform for Performance Co-Pilot (PCP) metrics
This introduces an initial platform for extracting metrics
using the PCP performance metrics API - PMAPI(3). It can
be used via the --enable-pcp=yes configure option.
So far I've added support for live localhost metrics only,
and only using pre-defined metrics already found in htop.
If available, all sampling is performed by pmcd(1) - else,
we fallback to htop doing the metric sampling itself (all
below the PMAPI). When pmcd is used, it may be configured
to run children with elevated privileges, so htop does not
need to be setuid (authentication with pmcd is available).
Additionally, the PMAPI allows us to support archives (for
historical analysis and for automated regression tests in
htop). We'll need platform-specific command line argument
additions, which isn't yet feasible in htop (not difficult
to add though).
The goal of this first version is minimal impact in terms
of modifying the htop codebase, to introduce key ideas in
PCP (metric namespace, metadata, APIs and so on) and give
us something to discuss, experiment with and build on.
2021-02-17 03:43:56 +00:00
|
|
|
|
2021-06-07 23:46:02 +00:00
|
|
|
static inline unsigned long long Metric_instance_u64(int metric, int pid, int offset, unsigned long long fallback) {
|
|
|
|
pmAtomValue value;
|
2021-08-14 21:30:19 +00:00
|
|
|
if (PCPMetric_instance(metric, pid, offset, &value, PM_TYPE_U64))
|
2021-06-07 23:46:02 +00:00
|
|
|
return value.ull;
|
|
|
|
return fallback;
|
|
|
|
}
|
Add a platform for Performance Co-Pilot (PCP) metrics
This introduces an initial platform for extracting metrics
using the PCP performance metrics API - PMAPI(3). It can
be used via the --enable-pcp=yes configure option.
So far I've added support for live localhost metrics only,
and only using pre-defined metrics already found in htop.
If available, all sampling is performed by pmcd(1) - else,
we fallback to htop doing the metric sampling itself (all
below the PMAPI). When pmcd is used, it may be configured
to run children with elevated privileges, so htop does not
need to be setuid (authentication with pmcd is available).
Additionally, the PMAPI allows us to support archives (for
historical analysis and for automated regression tests in
htop). We'll need platform-specific command line argument
additions, which isn't yet feasible in htop (not difficult
to add though).
The goal of this first version is minimal impact in terms
of modifying the htop codebase, to introduce key ideas in
PCP (metric namespace, metadata, APIs and so on) and give
us something to discuss, experiment with and build on.
2021-02-17 03:43:56 +00:00
|
|
|
|
2021-06-07 23:46:02 +00:00
|
|
|
static inline unsigned long long Metric_instance_time(int metric, int pid, int offset) {
|
|
|
|
pmAtomValue value;
|
2021-08-14 21:30:19 +00:00
|
|
|
if (PCPMetric_instance(metric, pid, offset, &value, PM_TYPE_U64))
|
2021-06-07 23:46:02 +00:00
|
|
|
return value.ull / 10;
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
static inline unsigned long long Metric_instance_ONE_K(int metric, int pid, int offset) {
|
|
|
|
pmAtomValue value;
|
2021-08-14 21:30:19 +00:00
|
|
|
if (PCPMetric_instance(metric, pid, offset, &value, PM_TYPE_U64))
|
2021-06-07 23:46:02 +00:00
|
|
|
return value.ull / ONE_K;
|
|
|
|
return ULLONG_MAX;
|
|
|
|
}
|
Add a platform for Performance Co-Pilot (PCP) metrics
This introduces an initial platform for extracting metrics
using the PCP performance metrics API - PMAPI(3). It can
be used via the --enable-pcp=yes configure option.
So far I've added support for live localhost metrics only,
and only using pre-defined metrics already found in htop.
If available, all sampling is performed by pmcd(1) - else,
we fallback to htop doing the metric sampling itself (all
below the PMAPI). When pmcd is used, it may be configured
to run children with elevated privileges, so htop does not
need to be setuid (authentication with pmcd is available).
Additionally, the PMAPI allows us to support archives (for
historical analysis and for automated regression tests in
htop). We'll need platform-specific command line argument
additions, which isn't yet feasible in htop (not difficult
to add though).
The goal of this first version is minimal impact in terms
of modifying the htop codebase, to introduce key ideas in
PCP (metric namespace, metadata, APIs and so on) and give
us something to discuss, experiment with and build on.
2021-02-17 03:43:56 +00:00
|
|
|
|
2021-06-07 23:46:02 +00:00
|
|
|
static inline char Metric_instance_char(int metric, int pid, int offset, char fallback) {
|
|
|
|
pmAtomValue value;
|
2021-08-14 21:30:19 +00:00
|
|
|
if (PCPMetric_instance(metric, pid, offset, &value, PM_TYPE_STRING)) {
|
2021-06-07 23:46:02 +00:00
|
|
|
char uchar = value.cp[0];
|
Add a platform for Performance Co-Pilot (PCP) metrics
This introduces an initial platform for extracting metrics
using the PCP performance metrics API - PMAPI(3). It can
be used via the --enable-pcp=yes configure option.
So far I've added support for live localhost metrics only,
and only using pre-defined metrics already found in htop.
If available, all sampling is performed by pmcd(1) - else,
we fallback to htop doing the metric sampling itself (all
below the PMAPI). When pmcd is used, it may be configured
to run children with elevated privileges, so htop does not
need to be setuid (authentication with pmcd is available).
Additionally, the PMAPI allows us to support archives (for
historical analysis and for automated regression tests in
htop). We'll need platform-specific command line argument
additions, which isn't yet feasible in htop (not difficult
to add though).
The goal of this first version is minimal impact in terms
of modifying the htop codebase, to introduce key ideas in
PCP (metric namespace, metadata, APIs and so on) and give
us something to discuss, experiment with and build on.
2021-02-17 03:43:56 +00:00
|
|
|
free(value.cp);
|
2021-06-07 23:46:02 +00:00
|
|
|
return uchar;
|
Add a platform for Performance Co-Pilot (PCP) metrics
This introduces an initial platform for extracting metrics
using the PCP performance metrics API - PMAPI(3). It can
be used via the --enable-pcp=yes configure option.
So far I've added support for live localhost metrics only,
and only using pre-defined metrics already found in htop.
If available, all sampling is performed by pmcd(1) - else,
we fallback to htop doing the metric sampling itself (all
below the PMAPI). When pmcd is used, it may be configured
to run children with elevated privileges, so htop does not
need to be setuid (authentication with pmcd is available).
Additionally, the PMAPI allows us to support archives (for
historical analysis and for automated regression tests in
htop). We'll need platform-specific command line argument
additions, which isn't yet feasible in htop (not difficult
to add though).
The goal of this first version is minimal impact in terms
of modifying the htop codebase, to introduce key ideas in
PCP (metric namespace, metadata, APIs and so on) and give
us something to discuss, experiment with and build on.
2021-02-17 03:43:56 +00:00
|
|
|
}
|
2021-06-07 23:46:02 +00:00
|
|
|
return fallback;
|
|
|
|
}
|
|
|
|
|
|
|
|
static void PCPProcessList_updateID(Process* process, int pid, int offset) {
|
|
|
|
process->tgid = Metric_instance_u32(PCP_PROC_TGID, pid, offset, 1);
|
|
|
|
process->ppid = Metric_instance_u32(PCP_PROC_PPID, pid, offset, 1);
|
|
|
|
process->state = Metric_instance_char(PCP_PROC_STATE, pid, offset, '?');
|
Add a platform for Performance Co-Pilot (PCP) metrics
This introduces an initial platform for extracting metrics
using the PCP performance metrics API - PMAPI(3). It can
be used via the --enable-pcp=yes configure option.
So far I've added support for live localhost metrics only,
and only using pre-defined metrics already found in htop.
If available, all sampling is performed by pmcd(1) - else,
we fallback to htop doing the metric sampling itself (all
below the PMAPI). When pmcd is used, it may be configured
to run children with elevated privileges, so htop does not
need to be setuid (authentication with pmcd is available).
Additionally, the PMAPI allows us to support archives (for
historical analysis and for automated regression tests in
htop). We'll need platform-specific command line argument
additions, which isn't yet feasible in htop (not difficult
to add though).
The goal of this first version is minimal impact in terms
of modifying the htop codebase, to introduce key ideas in
PCP (metric namespace, metadata, APIs and so on) and give
us something to discuss, experiment with and build on.
2021-02-17 03:43:56 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static void PCPProcessList_updateInfo(Process* process, int pid, int offset, char* command, size_t commLen) {
|
|
|
|
PCPProcess* pp = (PCPProcess*) process;
|
|
|
|
pmAtomValue value;
|
|
|
|
|
2021-08-14 21:30:19 +00:00
|
|
|
if (!PCPMetric_instance(PCP_PROC_CMD, pid, offset, &value, PM_TYPE_STRING))
|
Add a platform for Performance Co-Pilot (PCP) metrics
This introduces an initial platform for extracting metrics
using the PCP performance metrics API - PMAPI(3). It can
be used via the --enable-pcp=yes configure option.
So far I've added support for live localhost metrics only,
and only using pre-defined metrics already found in htop.
If available, all sampling is performed by pmcd(1) - else,
we fallback to htop doing the metric sampling itself (all
below the PMAPI). When pmcd is used, it may be configured
to run children with elevated privileges, so htop does not
need to be setuid (authentication with pmcd is available).
Additionally, the PMAPI allows us to support archives (for
historical analysis and for automated regression tests in
htop). We'll need platform-specific command line argument
additions, which isn't yet feasible in htop (not difficult
to add though).
The goal of this first version is minimal impact in terms
of modifying the htop codebase, to introduce key ideas in
PCP (metric namespace, metadata, APIs and so on) and give
us something to discuss, experiment with and build on.
2021-02-17 03:43:56 +00:00
|
|
|
value.cp = xStrdup("<unknown>");
|
|
|
|
String_safeStrncpy(command, value.cp, commLen);
|
|
|
|
free(value.cp);
|
|
|
|
|
2021-06-07 23:46:02 +00:00
|
|
|
process->pgrp = Metric_instance_u32(PCP_PROC_PGRP, pid, offset, 0);
|
|
|
|
process->session = Metric_instance_u32(PCP_PROC_SESSION, pid, offset, 0);
|
|
|
|
process->tty_nr = Metric_instance_u32(PCP_PROC_TTY, pid, offset, 0);
|
|
|
|
process->tpgid = Metric_instance_u32(PCP_PROC_TTYPGRP, pid, offset, 0);
|
|
|
|
process->minflt = Metric_instance_u32(PCP_PROC_MINFLT, pid, offset, 0);
|
|
|
|
pp->cminflt = Metric_instance_u32(PCP_PROC_CMINFLT, pid, offset, 0);
|
|
|
|
process->majflt = Metric_instance_u32(PCP_PROC_MAJFLT, pid, offset, 0);
|
|
|
|
pp->cmajflt = Metric_instance_u32(PCP_PROC_CMAJFLT, pid, offset, 0);
|
2021-07-28 23:41:41 +00:00
|
|
|
pp->utime = Metric_instance_time(PCP_PROC_UTIME, pid, offset);
|
|
|
|
pp->stime = Metric_instance_time(PCP_PROC_STIME, pid, offset);
|
2021-06-07 23:46:02 +00:00
|
|
|
pp->cutime = Metric_instance_time(PCP_PROC_CUTIME, pid, offset);
|
|
|
|
pp->cstime = Metric_instance_time(PCP_PROC_CSTIME, pid, offset);
|
|
|
|
process->priority = Metric_instance_u32(PCP_PROC_PRIORITY, pid, offset, 0);
|
|
|
|
process->nice = Metric_instance_s32(PCP_PROC_NICE, pid, offset, 0);
|
|
|
|
process->nlwp = Metric_instance_u32(PCP_PROC_THREADS, pid, offset, 0);
|
|
|
|
process->starttime_ctime = Metric_instance_time(PCP_PROC_STARTTIME, pid, offset);
|
|
|
|
process->processor = Metric_instance_u32(PCP_PROC_PROCESSOR, pid, offset, 0);
|
Add a platform for Performance Co-Pilot (PCP) metrics
This introduces an initial platform for extracting metrics
using the PCP performance metrics API - PMAPI(3). It can
be used via the --enable-pcp=yes configure option.
So far I've added support for live localhost metrics only,
and only using pre-defined metrics already found in htop.
If available, all sampling is performed by pmcd(1) - else,
we fallback to htop doing the metric sampling itself (all
below the PMAPI). When pmcd is used, it may be configured
to run children with elevated privileges, so htop does not
need to be setuid (authentication with pmcd is available).
Additionally, the PMAPI allows us to support archives (for
historical analysis and for automated regression tests in
htop). We'll need platform-specific command line argument
additions, which isn't yet feasible in htop (not difficult
to add though).
The goal of this first version is minimal impact in terms
of modifying the htop codebase, to introduce key ideas in
PCP (metric namespace, metadata, APIs and so on) and give
us something to discuss, experiment with and build on.
2021-02-17 03:43:56 +00:00
|
|
|
|
|
|
|
process->time = pp->utime + pp->stime;
|
|
|
|
}
|
|
|
|
|
2021-06-07 23:46:02 +00:00
|
|
|
static void PCPProcessList_updateIO(PCPProcess* pp, int pid, int offset, unsigned long long now) {
|
Add a platform for Performance Co-Pilot (PCP) metrics
This introduces an initial platform for extracting metrics
using the PCP performance metrics API - PMAPI(3). It can
be used via the --enable-pcp=yes configure option.
So far I've added support for live localhost metrics only,
and only using pre-defined metrics already found in htop.
If available, all sampling is performed by pmcd(1) - else,
we fallback to htop doing the metric sampling itself (all
below the PMAPI). When pmcd is used, it may be configured
to run children with elevated privileges, so htop does not
need to be setuid (authentication with pmcd is available).
Additionally, the PMAPI allows us to support archives (for
historical analysis and for automated regression tests in
htop). We'll need platform-specific command line argument
additions, which isn't yet feasible in htop (not difficult
to add though).
The goal of this first version is minimal impact in terms
of modifying the htop codebase, to introduce key ideas in
PCP (metric namespace, metadata, APIs and so on) and give
us something to discuss, experiment with and build on.
2021-02-17 03:43:56 +00:00
|
|
|
pmAtomValue value;
|
|
|
|
|
2021-06-07 23:46:02 +00:00
|
|
|
pp->io_rchar = Metric_instance_ONE_K(PCP_PROC_IO_RCHAR, pid, offset);
|
|
|
|
pp->io_wchar = Metric_instance_ONE_K(PCP_PROC_IO_WCHAR, pid, offset);
|
|
|
|
pp->io_syscr = Metric_instance_u64(PCP_PROC_IO_SYSCR, pid, offset, ULLONG_MAX);
|
|
|
|
pp->io_syscw = Metric_instance_u64(PCP_PROC_IO_SYSCW, pid, offset, ULLONG_MAX);
|
|
|
|
pp->io_cancelled_write_bytes = Metric_instance_ONE_K(PCP_PROC_IO_CANCELLED, pid, offset);
|
Add a platform for Performance Co-Pilot (PCP) metrics
This introduces an initial platform for extracting metrics
using the PCP performance metrics API - PMAPI(3). It can
be used via the --enable-pcp=yes configure option.
So far I've added support for live localhost metrics only,
and only using pre-defined metrics already found in htop.
If available, all sampling is performed by pmcd(1) - else,
we fallback to htop doing the metric sampling itself (all
below the PMAPI). When pmcd is used, it may be configured
to run children with elevated privileges, so htop does not
need to be setuid (authentication with pmcd is available).
Additionally, the PMAPI allows us to support archives (for
historical analysis and for automated regression tests in
htop). We'll need platform-specific command line argument
additions, which isn't yet feasible in htop (not difficult
to add though).
The goal of this first version is minimal impact in terms
of modifying the htop codebase, to introduce key ideas in
PCP (metric namespace, metadata, APIs and so on) and give
us something to discuss, experiment with and build on.
2021-02-17 03:43:56 +00:00
|
|
|
|
2021-08-14 21:30:19 +00:00
|
|
|
if (PCPMetric_instance(PCP_PROC_IO_READB, pid, offset, &value, PM_TYPE_U64)) {
|
2021-06-07 23:46:02 +00:00
|
|
|
unsigned long long last_read = pp->io_read_bytes;
|
|
|
|
pp->io_read_bytes = value.ull / ONE_K;
|
|
|
|
pp->io_rate_read_bps = ONE_K * (pp->io_read_bytes - last_read) /
|
|
|
|
(now - pp->io_last_scan_time);
|
Add a platform for Performance Co-Pilot (PCP) metrics
This introduces an initial platform for extracting metrics
using the PCP performance metrics API - PMAPI(3). It can
be used via the --enable-pcp=yes configure option.
So far I've added support for live localhost metrics only,
and only using pre-defined metrics already found in htop.
If available, all sampling is performed by pmcd(1) - else,
we fallback to htop doing the metric sampling itself (all
below the PMAPI). When pmcd is used, it may be configured
to run children with elevated privileges, so htop does not
need to be setuid (authentication with pmcd is available).
Additionally, the PMAPI allows us to support archives (for
historical analysis and for automated regression tests in
htop). We'll need platform-specific command line argument
additions, which isn't yet feasible in htop (not difficult
to add though).
The goal of this first version is minimal impact in terms
of modifying the htop codebase, to introduce key ideas in
PCP (metric namespace, metadata, APIs and so on) and give
us something to discuss, experiment with and build on.
2021-02-17 03:43:56 +00:00
|
|
|
} else {
|
2021-06-07 23:46:02 +00:00
|
|
|
pp->io_read_bytes = ULLONG_MAX;
|
|
|
|
pp->io_rate_read_bps = NAN;
|
Add a platform for Performance Co-Pilot (PCP) metrics
This introduces an initial platform for extracting metrics
using the PCP performance metrics API - PMAPI(3). It can
be used via the --enable-pcp=yes configure option.
So far I've added support for live localhost metrics only,
and only using pre-defined metrics already found in htop.
If available, all sampling is performed by pmcd(1) - else,
we fallback to htop doing the metric sampling itself (all
below the PMAPI). When pmcd is used, it may be configured
to run children with elevated privileges, so htop does not
need to be setuid (authentication with pmcd is available).
Additionally, the PMAPI allows us to support archives (for
historical analysis and for automated regression tests in
htop). We'll need platform-specific command line argument
additions, which isn't yet feasible in htop (not difficult
to add though).
The goal of this first version is minimal impact in terms
of modifying the htop codebase, to introduce key ideas in
PCP (metric namespace, metadata, APIs and so on) and give
us something to discuss, experiment with and build on.
2021-02-17 03:43:56 +00:00
|
|
|
}
|
|
|
|
|
2021-08-14 21:30:19 +00:00
|
|
|
if (PCPMetric_instance(PCP_PROC_IO_WRITEB, pid, offset, &value, PM_TYPE_U64)) {
|
2021-06-07 23:46:02 +00:00
|
|
|
unsigned long long last_write = pp->io_write_bytes;
|
|
|
|
pp->io_write_bytes = value.ull;
|
|
|
|
pp->io_rate_write_bps = ONE_K * (pp->io_write_bytes - last_write) /
|
|
|
|
(now - pp->io_last_scan_time);
|
Add a platform for Performance Co-Pilot (PCP) metrics
This introduces an initial platform for extracting metrics
using the PCP performance metrics API - PMAPI(3). It can
be used via the --enable-pcp=yes configure option.
So far I've added support for live localhost metrics only,
and only using pre-defined metrics already found in htop.
If available, all sampling is performed by pmcd(1) - else,
we fallback to htop doing the metric sampling itself (all
below the PMAPI). When pmcd is used, it may be configured
to run children with elevated privileges, so htop does not
need to be setuid (authentication with pmcd is available).
Additionally, the PMAPI allows us to support archives (for
historical analysis and for automated regression tests in
htop). We'll need platform-specific command line argument
additions, which isn't yet feasible in htop (not difficult
to add though).
The goal of this first version is minimal impact in terms
of modifying the htop codebase, to introduce key ideas in
PCP (metric namespace, metadata, APIs and so on) and give
us something to discuss, experiment with and build on.
2021-02-17 03:43:56 +00:00
|
|
|
} else {
|
2021-06-07 23:46:02 +00:00
|
|
|
pp->io_write_bytes = ULLONG_MAX;
|
|
|
|
pp->io_rate_write_bps = NAN;
|
Add a platform for Performance Co-Pilot (PCP) metrics
This introduces an initial platform for extracting metrics
using the PCP performance metrics API - PMAPI(3). It can
be used via the --enable-pcp=yes configure option.
So far I've added support for live localhost metrics only,
and only using pre-defined metrics already found in htop.
If available, all sampling is performed by pmcd(1) - else,
we fallback to htop doing the metric sampling itself (all
below the PMAPI). When pmcd is used, it may be configured
to run children with elevated privileges, so htop does not
need to be setuid (authentication with pmcd is available).
Additionally, the PMAPI allows us to support archives (for
historical analysis and for automated regression tests in
htop). We'll need platform-specific command line argument
additions, which isn't yet feasible in htop (not difficult
to add though).
The goal of this first version is minimal impact in terms
of modifying the htop codebase, to introduce key ideas in
PCP (metric namespace, metadata, APIs and so on) and give
us something to discuss, experiment with and build on.
2021-02-17 03:43:56 +00:00
|
|
|
}
|
|
|
|
|
2021-06-07 23:46:02 +00:00
|
|
|
pp->io_last_scan_time = now;
|
Add a platform for Performance Co-Pilot (PCP) metrics
This introduces an initial platform for extracting metrics
using the PCP performance metrics API - PMAPI(3). It can
be used via the --enable-pcp=yes configure option.
So far I've added support for live localhost metrics only,
and only using pre-defined metrics already found in htop.
If available, all sampling is performed by pmcd(1) - else,
we fallback to htop doing the metric sampling itself (all
below the PMAPI). When pmcd is used, it may be configured
to run children with elevated privileges, so htop does not
need to be setuid (authentication with pmcd is available).
Additionally, the PMAPI allows us to support archives (for
historical analysis and for automated regression tests in
htop). We'll need platform-specific command line argument
additions, which isn't yet feasible in htop (not difficult
to add though).
The goal of this first version is minimal impact in terms
of modifying the htop codebase, to introduce key ideas in
PCP (metric namespace, metadata, APIs and so on) and give
us something to discuss, experiment with and build on.
2021-02-17 03:43:56 +00:00
|
|
|
}
|
|
|
|
|
2021-06-07 23:46:02 +00:00
|
|
|
static void PCPProcessList_updateMemory(PCPProcess* pp, int pid, int offset) {
|
|
|
|
pp->super.m_virt = Metric_instance_u32(PCP_PROC_MEM_SIZE, pid, offset, 0);
|
|
|
|
pp->super.m_resident = Metric_instance_u32(PCP_PROC_MEM_RSS, pid, offset, 0);
|
|
|
|
pp->m_share = Metric_instance_u32(PCP_PROC_MEM_SHARE, pid, offset, 0);
|
|
|
|
pp->m_trs = Metric_instance_u32(PCP_PROC_MEM_TEXTRS, pid, offset, 0);
|
|
|
|
pp->m_lrs = Metric_instance_u32(PCP_PROC_MEM_LIBRS, pid, offset, 0);
|
|
|
|
pp->m_drs = Metric_instance_u32(PCP_PROC_MEM_DATRS, pid, offset, 0);
|
|
|
|
pp->m_dt = Metric_instance_u32(PCP_PROC_MEM_DIRTY, pid, offset, 0);
|
Add a platform for Performance Co-Pilot (PCP) metrics
This introduces an initial platform for extracting metrics
using the PCP performance metrics API - PMAPI(3). It can
be used via the --enable-pcp=yes configure option.
So far I've added support for live localhost metrics only,
and only using pre-defined metrics already found in htop.
If available, all sampling is performed by pmcd(1) - else,
we fallback to htop doing the metric sampling itself (all
below the PMAPI). When pmcd is used, it may be configured
to run children with elevated privileges, so htop does not
need to be setuid (authentication with pmcd is available).
Additionally, the PMAPI allows us to support archives (for
historical analysis and for automated regression tests in
htop). We'll need platform-specific command line argument
additions, which isn't yet feasible in htop (not difficult
to add though).
The goal of this first version is minimal impact in terms
of modifying the htop codebase, to introduce key ideas in
PCP (metric namespace, metadata, APIs and so on) and give
us something to discuss, experiment with and build on.
2021-02-17 03:43:56 +00:00
|
|
|
}
|
|
|
|
|
2021-06-07 23:46:02 +00:00
|
|
|
static void PCPProcessList_updateSmaps(PCPProcess* pp, pid_t pid, int offset) {
|
|
|
|
pp->m_pss = Metric_instance_u64(PCP_PROC_SMAPS_PSS, pid, offset, 0);
|
|
|
|
pp->m_swap = Metric_instance_u64(PCP_PROC_SMAPS_SWAP, pid, offset, 0);
|
|
|
|
pp->m_psswp = Metric_instance_u64(PCP_PROC_SMAPS_SWAPPSS, pid, offset, 0);
|
Add a platform for Performance Co-Pilot (PCP) metrics
This introduces an initial platform for extracting metrics
using the PCP performance metrics API - PMAPI(3). It can
be used via the --enable-pcp=yes configure option.
So far I've added support for live localhost metrics only,
and only using pre-defined metrics already found in htop.
If available, all sampling is performed by pmcd(1) - else,
we fallback to htop doing the metric sampling itself (all
below the PMAPI). When pmcd is used, it may be configured
to run children with elevated privileges, so htop does not
need to be setuid (authentication with pmcd is available).
Additionally, the PMAPI allows us to support archives (for
historical analysis and for automated regression tests in
htop). We'll need platform-specific command line argument
additions, which isn't yet feasible in htop (not difficult
to add though).
The goal of this first version is minimal impact in terms
of modifying the htop codebase, to introduce key ideas in
PCP (metric namespace, metadata, APIs and so on) and give
us something to discuss, experiment with and build on.
2021-02-17 03:43:56 +00:00
|
|
|
}
|
|
|
|
|
2021-06-07 23:46:02 +00:00
|
|
|
static void PCPProcessList_readOomData(PCPProcess* pp, int pid, int offset) {
|
|
|
|
pp->oom = Metric_instance_u32(PCP_PROC_OOMSCORE, pid, offset, 0);
|
Add a platform for Performance Co-Pilot (PCP) metrics
This introduces an initial platform for extracting metrics
using the PCP performance metrics API - PMAPI(3). It can
be used via the --enable-pcp=yes configure option.
So far I've added support for live localhost metrics only,
and only using pre-defined metrics already found in htop.
If available, all sampling is performed by pmcd(1) - else,
we fallback to htop doing the metric sampling itself (all
below the PMAPI). When pmcd is used, it may be configured
to run children with elevated privileges, so htop does not
need to be setuid (authentication with pmcd is available).
Additionally, the PMAPI allows us to support archives (for
historical analysis and for automated regression tests in
htop). We'll need platform-specific command line argument
additions, which isn't yet feasible in htop (not difficult
to add though).
The goal of this first version is minimal impact in terms
of modifying the htop codebase, to introduce key ideas in
PCP (metric namespace, metadata, APIs and so on) and give
us something to discuss, experiment with and build on.
2021-02-17 03:43:56 +00:00
|
|
|
}
|
|
|
|
|
2021-08-06 06:45:30 +00:00
|
|
|
static void PCPProcessList_readAutogroup(PCPProcess* pp, int pid, int offset) {
|
|
|
|
pp->autogroup_id = Metric_instance_s64(PCP_PROC_AUTOGROUP_ID, pid, offset, -1);
|
|
|
|
pp->autogroup_nice = Metric_instance_s32(PCP_PROC_AUTOGROUP_NICE, pid, offset, 0);
|
|
|
|
}
|
|
|
|
|
2021-06-07 23:46:02 +00:00
|
|
|
static void PCPProcessList_readCtxtData(PCPProcess* pp, int pid, int offset) {
|
Add a platform for Performance Co-Pilot (PCP) metrics
This introduces an initial platform for extracting metrics
using the PCP performance metrics API - PMAPI(3). It can
be used via the --enable-pcp=yes configure option.
So far I've added support for live localhost metrics only,
and only using pre-defined metrics already found in htop.
If available, all sampling is performed by pmcd(1) - else,
we fallback to htop doing the metric sampling itself (all
below the PMAPI). When pmcd is used, it may be configured
to run children with elevated privileges, so htop does not
need to be setuid (authentication with pmcd is available).
Additionally, the PMAPI allows us to support archives (for
historical analysis and for automated regression tests in
htop). We'll need platform-specific command line argument
additions, which isn't yet feasible in htop (not difficult
to add though).
The goal of this first version is minimal impact in terms
of modifying the htop codebase, to introduce key ideas in
PCP (metric namespace, metadata, APIs and so on) and give
us something to discuss, experiment with and build on.
2021-02-17 03:43:56 +00:00
|
|
|
pmAtomValue value;
|
|
|
|
unsigned long ctxt = 0;
|
|
|
|
|
2021-08-14 21:30:19 +00:00
|
|
|
if (PCPMetric_instance(PCP_PROC_VCTXSW, pid, offset, &value, PM_TYPE_U32))
|
Add a platform for Performance Co-Pilot (PCP) metrics
This introduces an initial platform for extracting metrics
using the PCP performance metrics API - PMAPI(3). It can
be used via the --enable-pcp=yes configure option.
So far I've added support for live localhost metrics only,
and only using pre-defined metrics already found in htop.
If available, all sampling is performed by pmcd(1) - else,
we fallback to htop doing the metric sampling itself (all
below the PMAPI). When pmcd is used, it may be configured
to run children with elevated privileges, so htop does not
need to be setuid (authentication with pmcd is available).
Additionally, the PMAPI allows us to support archives (for
historical analysis and for automated regression tests in
htop). We'll need platform-specific command line argument
additions, which isn't yet feasible in htop (not difficult
to add though).
The goal of this first version is minimal impact in terms
of modifying the htop codebase, to introduce key ideas in
PCP (metric namespace, metadata, APIs and so on) and give
us something to discuss, experiment with and build on.
2021-02-17 03:43:56 +00:00
|
|
|
ctxt += value.ul;
|
2021-08-14 21:30:19 +00:00
|
|
|
if (PCPMetric_instance(PCP_PROC_NVCTXSW, pid, offset, &value, PM_TYPE_U32))
|
Add a platform for Performance Co-Pilot (PCP) metrics
This introduces an initial platform for extracting metrics
using the PCP performance metrics API - PMAPI(3). It can
be used via the --enable-pcp=yes configure option.
So far I've added support for live localhost metrics only,
and only using pre-defined metrics already found in htop.
If available, all sampling is performed by pmcd(1) - else,
we fallback to htop doing the metric sampling itself (all
below the PMAPI). When pmcd is used, it may be configured
to run children with elevated privileges, so htop does not
need to be setuid (authentication with pmcd is available).
Additionally, the PMAPI allows us to support archives (for
historical analysis and for automated regression tests in
htop). We'll need platform-specific command line argument
additions, which isn't yet feasible in htop (not difficult
to add though).
The goal of this first version is minimal impact in terms
of modifying the htop codebase, to introduce key ideas in
PCP (metric namespace, metadata, APIs and so on) and give
us something to discuss, experiment with and build on.
2021-02-17 03:43:56 +00:00
|
|
|
ctxt += value.ul;
|
2021-06-07 23:46:02 +00:00
|
|
|
|
|
|
|
pp->ctxt_diff = ctxt > pp->ctxt_total ? ctxt - pp->ctxt_total : 0;
|
|
|
|
pp->ctxt_total = ctxt;
|
Add a platform for Performance Co-Pilot (PCP) metrics
This introduces an initial platform for extracting metrics
using the PCP performance metrics API - PMAPI(3). It can
be used via the --enable-pcp=yes configure option.
So far I've added support for live localhost metrics only,
and only using pre-defined metrics already found in htop.
If available, all sampling is performed by pmcd(1) - else,
we fallback to htop doing the metric sampling itself (all
below the PMAPI). When pmcd is used, it may be configured
to run children with elevated privileges, so htop does not
need to be setuid (authentication with pmcd is available).
Additionally, the PMAPI allows us to support archives (for
historical analysis and for automated regression tests in
htop). We'll need platform-specific command line argument
additions, which isn't yet feasible in htop (not difficult
to add though).
The goal of this first version is minimal impact in terms
of modifying the htop codebase, to introduce key ideas in
PCP (metric namespace, metadata, APIs and so on) and give
us something to discuss, experiment with and build on.
2021-02-17 03:43:56 +00:00
|
|
|
}
|
|
|
|
|
2021-08-14 21:30:19 +00:00
|
|
|
static char* setString(PCPMetric metric, int pid, int offset, char* string) {
|
Add a platform for Performance Co-Pilot (PCP) metrics
This introduces an initial platform for extracting metrics
using the PCP performance metrics API - PMAPI(3). It can
be used via the --enable-pcp=yes configure option.
So far I've added support for live localhost metrics only,
and only using pre-defined metrics already found in htop.
If available, all sampling is performed by pmcd(1) - else,
we fallback to htop doing the metric sampling itself (all
below the PMAPI). When pmcd is used, it may be configured
to run children with elevated privileges, so htop does not
need to be setuid (authentication with pmcd is available).
Additionally, the PMAPI allows us to support archives (for
historical analysis and for automated regression tests in
htop). We'll need platform-specific command line argument
additions, which isn't yet feasible in htop (not difficult
to add though).
The goal of this first version is minimal impact in terms
of modifying the htop codebase, to introduce key ideas in
PCP (metric namespace, metadata, APIs and so on) and give
us something to discuss, experiment with and build on.
2021-02-17 03:43:56 +00:00
|
|
|
if (string)
|
|
|
|
free(string);
|
|
|
|
pmAtomValue value;
|
2021-08-14 21:30:19 +00:00
|
|
|
if (PCPMetric_instance(metric, pid, offset, &value, PM_TYPE_STRING))
|
Add a platform for Performance Co-Pilot (PCP) metrics
This introduces an initial platform for extracting metrics
using the PCP performance metrics API - PMAPI(3). It can
be used via the --enable-pcp=yes configure option.
So far I've added support for live localhost metrics only,
and only using pre-defined metrics already found in htop.
If available, all sampling is performed by pmcd(1) - else,
we fallback to htop doing the metric sampling itself (all
below the PMAPI). When pmcd is used, it may be configured
to run children with elevated privileges, so htop does not
need to be setuid (authentication with pmcd is available).
Additionally, the PMAPI allows us to support archives (for
historical analysis and for automated regression tests in
htop). We'll need platform-specific command line argument
additions, which isn't yet feasible in htop (not difficult
to add though).
The goal of this first version is minimal impact in terms
of modifying the htop codebase, to introduce key ideas in
PCP (metric namespace, metadata, APIs and so on) and give
us something to discuss, experiment with and build on.
2021-02-17 03:43:56 +00:00
|
|
|
string = value.cp;
|
|
|
|
else
|
|
|
|
string = NULL;
|
|
|
|
return string;
|
|
|
|
}
|
|
|
|
|
2021-04-14 23:03:12 +00:00
|
|
|
static void PCPProcessList_updateTTY(Process* process, int pid, int offset) {
|
|
|
|
process->tty_name = setString(PCP_PROC_TTYNAME, pid, offset, process->tty_name);
|
Add a platform for Performance Co-Pilot (PCP) metrics
This introduces an initial platform for extracting metrics
using the PCP performance metrics API - PMAPI(3). It can
be used via the --enable-pcp=yes configure option.
So far I've added support for live localhost metrics only,
and only using pre-defined metrics already found in htop.
If available, all sampling is performed by pmcd(1) - else,
we fallback to htop doing the metric sampling itself (all
below the PMAPI). When pmcd is used, it may be configured
to run children with elevated privileges, so htop does not
need to be setuid (authentication with pmcd is available).
Additionally, the PMAPI allows us to support archives (for
historical analysis and for automated regression tests in
htop). We'll need platform-specific command line argument
additions, which isn't yet feasible in htop (not difficult
to add though).
The goal of this first version is minimal impact in terms
of modifying the htop codebase, to introduce key ideas in
PCP (metric namespace, metadata, APIs and so on) and give
us something to discuss, experiment with and build on.
2021-02-17 03:43:56 +00:00
|
|
|
}
|
|
|
|
|
2021-06-07 23:46:02 +00:00
|
|
|
static void PCPProcessList_readCGroups(PCPProcess* pp, int pid, int offset) {
|
|
|
|
pp->cgroup = setString(PCP_PROC_CGROUPS, pid, offset, pp->cgroup);
|
Add a platform for Performance Co-Pilot (PCP) metrics
This introduces an initial platform for extracting metrics
using the PCP performance metrics API - PMAPI(3). It can
be used via the --enable-pcp=yes configure option.
So far I've added support for live localhost metrics only,
and only using pre-defined metrics already found in htop.
If available, all sampling is performed by pmcd(1) - else,
we fallback to htop doing the metric sampling itself (all
below the PMAPI). When pmcd is used, it may be configured
to run children with elevated privileges, so htop does not
need to be setuid (authentication with pmcd is available).
Additionally, the PMAPI allows us to support archives (for
historical analysis and for automated regression tests in
htop). We'll need platform-specific command line argument
additions, which isn't yet feasible in htop (not difficult
to add though).
The goal of this first version is minimal impact in terms
of modifying the htop codebase, to introduce key ideas in
PCP (metric namespace, metadata, APIs and so on) and give
us something to discuss, experiment with and build on.
2021-02-17 03:43:56 +00:00
|
|
|
}
|
|
|
|
|
2021-06-07 23:46:02 +00:00
|
|
|
static void PCPProcessList_readSecattrData(PCPProcess* pp, int pid, int offset) {
|
|
|
|
pp->secattr = setString(PCP_PROC_LABELS, pid, offset, pp->secattr);
|
Add a platform for Performance Co-Pilot (PCP) metrics
This introduces an initial platform for extracting metrics
using the PCP performance metrics API - PMAPI(3). It can
be used via the --enable-pcp=yes configure option.
So far I've added support for live localhost metrics only,
and only using pre-defined metrics already found in htop.
If available, all sampling is performed by pmcd(1) - else,
we fallback to htop doing the metric sampling itself (all
below the PMAPI). When pmcd is used, it may be configured
to run children with elevated privileges, so htop does not
need to be setuid (authentication with pmcd is available).
Additionally, the PMAPI allows us to support archives (for
historical analysis and for automated regression tests in
htop). We'll need platform-specific command line argument
additions, which isn't yet feasible in htop (not difficult
to add though).
The goal of this first version is minimal impact in terms
of modifying the htop codebase, to introduce key ideas in
PCP (metric namespace, metadata, APIs and so on) and give
us something to discuss, experiment with and build on.
2021-02-17 03:43:56 +00:00
|
|
|
}
|
|
|
|
|
2021-06-07 23:46:02 +00:00
|
|
|
static void PCPProcessList_readCwd(PCPProcess* pp, int pid, int offset) {
|
|
|
|
pp->super.procCwd = setString(PCP_PROC_CWD, pid, offset, pp->super.procCwd);
|
2021-05-27 06:05:48 +00:00
|
|
|
}
|
|
|
|
|
Add a platform for Performance Co-Pilot (PCP) metrics
This introduces an initial platform for extracting metrics
using the PCP performance metrics API - PMAPI(3). It can
be used via the --enable-pcp=yes configure option.
So far I've added support for live localhost metrics only,
and only using pre-defined metrics already found in htop.
If available, all sampling is performed by pmcd(1) - else,
we fallback to htop doing the metric sampling itself (all
below the PMAPI). When pmcd is used, it may be configured
to run children with elevated privileges, so htop does not
need to be setuid (authentication with pmcd is available).
Additionally, the PMAPI allows us to support archives (for
historical analysis and for automated regression tests in
htop). We'll need platform-specific command line argument
additions, which isn't yet feasible in htop (not difficult
to add though).
The goal of this first version is minimal impact in terms
of modifying the htop codebase, to introduce key ideas in
PCP (metric namespace, metadata, APIs and so on) and give
us something to discuss, experiment with and build on.
2021-02-17 03:43:56 +00:00
|
|
|
static void PCPProcessList_updateUsername(Process* process, int pid, int offset, UsersTable* users) {
|
2021-06-07 23:46:02 +00:00
|
|
|
process->st_uid = Metric_instance_u32(PCP_PROC_ID_UID, pid, offset, 0);
|
|
|
|
process->user = setUser(users, process->st_uid, pid, offset);
|
Add a platform for Performance Co-Pilot (PCP) metrics
This introduces an initial platform for extracting metrics
using the PCP performance metrics API - PMAPI(3). It can
be used via the --enable-pcp=yes configure option.
So far I've added support for live localhost metrics only,
and only using pre-defined metrics already found in htop.
If available, all sampling is performed by pmcd(1) - else,
we fallback to htop doing the metric sampling itself (all
below the PMAPI). When pmcd is used, it may be configured
to run children with elevated privileges, so htop does not
need to be setuid (authentication with pmcd is available).
Additionally, the PMAPI allows us to support archives (for
historical analysis and for automated regression tests in
htop). We'll need platform-specific command line argument
additions, which isn't yet feasible in htop (not difficult
to add though).
The goal of this first version is minimal impact in terms
of modifying the htop codebase, to introduce key ideas in
PCP (metric namespace, metadata, APIs and so on) and give
us something to discuss, experiment with and build on.
2021-02-17 03:43:56 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static void PCPProcessList_updateCmdline(Process* process, int pid, int offset, const char* comm) {
|
|
|
|
pmAtomValue value;
|
2021-08-14 21:30:19 +00:00
|
|
|
if (!PCPMetric_instance(PCP_PROC_PSARGS, pid, offset, &value, PM_TYPE_STRING)) {
|
Add a platform for Performance Co-Pilot (PCP) metrics
This introduces an initial platform for extracting metrics
using the PCP performance metrics API - PMAPI(3). It can
be used via the --enable-pcp=yes configure option.
So far I've added support for live localhost metrics only,
and only using pre-defined metrics already found in htop.
If available, all sampling is performed by pmcd(1) - else,
we fallback to htop doing the metric sampling itself (all
below the PMAPI). When pmcd is used, it may be configured
to run children with elevated privileges, so htop does not
need to be setuid (authentication with pmcd is available).
Additionally, the PMAPI allows us to support archives (for
historical analysis and for automated regression tests in
htop). We'll need platform-specific command line argument
additions, which isn't yet feasible in htop (not difficult
to add though).
The goal of this first version is minimal impact in terms
of modifying the htop codebase, to introduce key ideas in
PCP (metric namespace, metadata, APIs and so on) and give
us something to discuss, experiment with and build on.
2021-02-17 03:43:56 +00:00
|
|
|
if (process->state != 'Z')
|
2021-05-27 06:05:48 +00:00
|
|
|
process->isKernelThread = true;
|
|
|
|
Process_updateCmdline(process, NULL, 0, 0);
|
Add a platform for Performance Co-Pilot (PCP) metrics
This introduces an initial platform for extracting metrics
using the PCP performance metrics API - PMAPI(3). It can
be used via the --enable-pcp=yes configure option.
So far I've added support for live localhost metrics only,
and only using pre-defined metrics already found in htop.
If available, all sampling is performed by pmcd(1) - else,
we fallback to htop doing the metric sampling itself (all
below the PMAPI). When pmcd is used, it may be configured
to run children with elevated privileges, so htop does not
need to be setuid (authentication with pmcd is available).
Additionally, the PMAPI allows us to support archives (for
historical analysis and for automated regression tests in
htop). We'll need platform-specific command line argument
additions, which isn't yet feasible in htop (not difficult
to add though).
The goal of this first version is minimal impact in terms
of modifying the htop codebase, to introduce key ideas in
PCP (metric namespace, metadata, APIs and so on) and give
us something to discuss, experiment with and build on.
2021-02-17 03:43:56 +00:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2021-07-14 17:24:18 +00:00
|
|
|
char* command = value.cp;
|
Add a platform for Performance Co-Pilot (PCP) metrics
This introduces an initial platform for extracting metrics
using the PCP performance metrics API - PMAPI(3). It can
be used via the --enable-pcp=yes configure option.
So far I've added support for live localhost metrics only,
and only using pre-defined metrics already found in htop.
If available, all sampling is performed by pmcd(1) - else,
we fallback to htop doing the metric sampling itself (all
below the PMAPI). When pmcd is used, it may be configured
to run children with elevated privileges, so htop does not
need to be setuid (authentication with pmcd is available).
Additionally, the PMAPI allows us to support archives (for
historical analysis and for automated regression tests in
htop). We'll need platform-specific command line argument
additions, which isn't yet feasible in htop (not difficult
to add though).
The goal of this first version is minimal impact in terms
of modifying the htop codebase, to introduce key ideas in
PCP (metric namespace, metadata, APIs and so on) and give
us something to discuss, experiment with and build on.
2021-02-17 03:43:56 +00:00
|
|
|
int length = strlen(command);
|
|
|
|
if (command[0] != '(') {
|
2021-05-27 06:05:48 +00:00
|
|
|
process->isKernelThread = false;
|
Add a platform for Performance Co-Pilot (PCP) metrics
This introduces an initial platform for extracting metrics
using the PCP performance metrics API - PMAPI(3). It can
be used via the --enable-pcp=yes configure option.
So far I've added support for live localhost metrics only,
and only using pre-defined metrics already found in htop.
If available, all sampling is performed by pmcd(1) - else,
we fallback to htop doing the metric sampling itself (all
below the PMAPI). When pmcd is used, it may be configured
to run children with elevated privileges, so htop does not
need to be setuid (authentication with pmcd is available).
Additionally, the PMAPI allows us to support archives (for
historical analysis and for automated regression tests in
htop). We'll need platform-specific command line argument
additions, which isn't yet feasible in htop (not difficult
to add though).
The goal of this first version is minimal impact in terms
of modifying the htop codebase, to introduce key ideas in
PCP (metric namespace, metadata, APIs and so on) and give
us something to discuss, experiment with and build on.
2021-02-17 03:43:56 +00:00
|
|
|
} else {
|
|
|
|
++command;
|
|
|
|
--length;
|
2021-07-14 17:18:27 +00:00
|
|
|
if (command[length - 1] == ')')
|
2021-06-23 07:20:55 +00:00
|
|
|
command[--length] = '\0';
|
2021-05-27 06:05:48 +00:00
|
|
|
process->isKernelThread = true;
|
Add a platform for Performance Co-Pilot (PCP) metrics
This introduces an initial platform for extracting metrics
using the PCP performance metrics API - PMAPI(3). It can
be used via the --enable-pcp=yes configure option.
So far I've added support for live localhost metrics only,
and only using pre-defined metrics already found in htop.
If available, all sampling is performed by pmcd(1) - else,
we fallback to htop doing the metric sampling itself (all
below the PMAPI). When pmcd is used, it may be configured
to run children with elevated privileges, so htop does not
need to be setuid (authentication with pmcd is available).
Additionally, the PMAPI allows us to support archives (for
historical analysis and for automated regression tests in
htop). We'll need platform-specific command line argument
additions, which isn't yet feasible in htop (not difficult
to add though).
The goal of this first version is minimal impact in terms
of modifying the htop codebase, to introduce key ideas in
PCP (metric namespace, metadata, APIs and so on) and give
us something to discuss, experiment with and build on.
2021-02-17 03:43:56 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
int tokenStart = 0;
|
|
|
|
for (int i = 0; i < length; i++) {
|
|
|
|
/* htop considers the next character after the last / that is before
|
|
|
|
* basenameOffset, as the start of the basename in cmdline - see
|
|
|
|
* Process_writeCommand */
|
|
|
|
if (command[i] == '/')
|
|
|
|
tokenStart = i + 1;
|
|
|
|
}
|
2021-05-27 06:05:48 +00:00
|
|
|
int tokenEnd = length;
|
Add a platform for Performance Co-Pilot (PCP) metrics
This introduces an initial platform for extracting metrics
using the PCP performance metrics API - PMAPI(3). It can
be used via the --enable-pcp=yes configure option.
So far I've added support for live localhost metrics only,
and only using pre-defined metrics already found in htop.
If available, all sampling is performed by pmcd(1) - else,
we fallback to htop doing the metric sampling itself (all
below the PMAPI). When pmcd is used, it may be configured
to run children with elevated privileges, so htop does not
need to be setuid (authentication with pmcd is available).
Additionally, the PMAPI allows us to support archives (for
historical analysis and for automated regression tests in
htop). We'll need platform-specific command line argument
additions, which isn't yet feasible in htop (not difficult
to add though).
The goal of this first version is minimal impact in terms
of modifying the htop codebase, to introduce key ideas in
PCP (metric namespace, metadata, APIs and so on) and give
us something to discuss, experiment with and build on.
2021-02-17 03:43:56 +00:00
|
|
|
|
2021-05-27 06:05:48 +00:00
|
|
|
Process_updateCmdline(process, command, tokenStart, tokenEnd);
|
Add a platform for Performance Co-Pilot (PCP) metrics
This introduces an initial platform for extracting metrics
using the PCP performance metrics API - PMAPI(3). It can
be used via the --enable-pcp=yes configure option.
So far I've added support for live localhost metrics only,
and only using pre-defined metrics already found in htop.
If available, all sampling is performed by pmcd(1) - else,
we fallback to htop doing the metric sampling itself (all
below the PMAPI). When pmcd is used, it may be configured
to run children with elevated privileges, so htop does not
need to be setuid (authentication with pmcd is available).
Additionally, the PMAPI allows us to support archives (for
historical analysis and for automated regression tests in
htop). We'll need platform-specific command line argument
additions, which isn't yet feasible in htop (not difficult
to add though).
The goal of this first version is minimal impact in terms
of modifying the htop codebase, to introduce key ideas in
PCP (metric namespace, metadata, APIs and so on) and give
us something to discuss, experiment with and build on.
2021-02-17 03:43:56 +00:00
|
|
|
free(value.cp);
|
2021-05-27 06:05:48 +00:00
|
|
|
|
|
|
|
Process_updateComm(process, comm);
|
|
|
|
|
2021-08-14 21:30:19 +00:00
|
|
|
if (PCPMetric_instance(PCP_PROC_EXE, pid, offset, &value, PM_TYPE_STRING)) {
|
2021-09-02 21:37:53 +00:00
|
|
|
Process_updateExe(process, value.cp[0] ? value.cp : NULL);
|
2021-05-27 06:05:48 +00:00
|
|
|
free(value.cp);
|
|
|
|
}
|
Add a platform for Performance Co-Pilot (PCP) metrics
This introduces an initial platform for extracting metrics
using the PCP performance metrics API - PMAPI(3). It can
be used via the --enable-pcp=yes configure option.
So far I've added support for live localhost metrics only,
and only using pre-defined metrics already found in htop.
If available, all sampling is performed by pmcd(1) - else,
we fallback to htop doing the metric sampling itself (all
below the PMAPI). When pmcd is used, it may be configured
to run children with elevated privileges, so htop does not
need to be setuid (authentication with pmcd is available).
Additionally, the PMAPI allows us to support archives (for
historical analysis and for automated regression tests in
htop). We'll need platform-specific command line argument
additions, which isn't yet feasible in htop (not difficult
to add though).
The goal of this first version is minimal impact in terms
of modifying the htop codebase, to introduce key ideas in
PCP (metric namespace, metadata, APIs and so on) and give
us something to discuss, experiment with and build on.
2021-02-17 03:43:56 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static bool PCPProcessList_updateProcesses(PCPProcessList* this, double period, struct timeval* tv) {
|
|
|
|
ProcessList* pl = (ProcessList*) this;
|
|
|
|
const Settings* settings = pl->settings;
|
|
|
|
|
|
|
|
bool hideKernelThreads = settings->hideKernelThreads;
|
|
|
|
bool hideUserlandThreads = settings->hideUserlandThreads;
|
|
|
|
|
|
|
|
unsigned long long now = tv->tv_sec * 1000LL + tv->tv_usec / 1000LL;
|
|
|
|
int pid = -1, offset = -1;
|
|
|
|
|
|
|
|
/* for every process ... */
|
2021-08-14 21:30:19 +00:00
|
|
|
while (PCPMetric_iterate(PCP_PROC_PID, &pid, &offset)) {
|
Add a platform for Performance Co-Pilot (PCP) metrics
This introduces an initial platform for extracting metrics
using the PCP performance metrics API - PMAPI(3). It can
be used via the --enable-pcp=yes configure option.
So far I've added support for live localhost metrics only,
and only using pre-defined metrics already found in htop.
If available, all sampling is performed by pmcd(1) - else,
we fallback to htop doing the metric sampling itself (all
below the PMAPI). When pmcd is used, it may be configured
to run children with elevated privileges, so htop does not
need to be setuid (authentication with pmcd is available).
Additionally, the PMAPI allows us to support archives (for
historical analysis and for automated regression tests in
htop). We'll need platform-specific command line argument
additions, which isn't yet feasible in htop (not difficult
to add though).
The goal of this first version is minimal impact in terms
of modifying the htop codebase, to introduce key ideas in
PCP (metric namespace, metadata, APIs and so on) and give
us something to discuss, experiment with and build on.
2021-02-17 03:43:56 +00:00
|
|
|
|
|
|
|
bool preExisting;
|
|
|
|
Process* proc = ProcessList_getProcess(pl, pid, &preExisting, PCPProcess_new);
|
|
|
|
PCPProcess* pp = (PCPProcess*) proc;
|
|
|
|
PCPProcessList_updateID(proc, pid, offset);
|
2021-07-18 08:00:59 +00:00
|
|
|
proc->isUserlandThread = proc->pid != proc->tgid;
|
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
|
|
|
pp->offset = offset >= 0 ? offset : 0;
|
Add a platform for Performance Co-Pilot (PCP) metrics
This introduces an initial platform for extracting metrics
using the PCP performance metrics API - PMAPI(3). It can
be used via the --enable-pcp=yes configure option.
So far I've added support for live localhost metrics only,
and only using pre-defined metrics already found in htop.
If available, all sampling is performed by pmcd(1) - else,
we fallback to htop doing the metric sampling itself (all
below the PMAPI). When pmcd is used, it may be configured
to run children with elevated privileges, so htop does not
need to be setuid (authentication with pmcd is available).
Additionally, the PMAPI allows us to support archives (for
historical analysis and for automated regression tests in
htop). We'll need platform-specific command line argument
additions, which isn't yet feasible in htop (not difficult
to add though).
The goal of this first version is minimal impact in terms
of modifying the htop codebase, to introduce key ideas in
PCP (metric namespace, metadata, APIs and so on) and give
us something to discuss, experiment with and build on.
2021-02-17 03:43:56 +00:00
|
|
|
|
|
|
|
/*
|
|
|
|
* These conditions will not trigger on first occurrence, cause we need to
|
|
|
|
* add the process to the ProcessList and do all one time scans
|
|
|
|
* (e.g. parsing the cmdline to detect a kernel thread)
|
|
|
|
* But it will short-circuit subsequent scans.
|
|
|
|
*/
|
|
|
|
if (preExisting && hideKernelThreads && Process_isKernelThread(proc)) {
|
|
|
|
proc->updated = true;
|
|
|
|
proc->show = false;
|
|
|
|
if (proc->state == 'R')
|
|
|
|
pl->runningTasks++;
|
|
|
|
pl->kernelThreads++;
|
|
|
|
pl->totalTasks++;
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
if (preExisting && hideUserlandThreads && Process_isUserlandThread(proc)) {
|
|
|
|
proc->updated = true;
|
|
|
|
proc->show = false;
|
|
|
|
if (proc->state == 'R')
|
|
|
|
pl->runningTasks++;
|
|
|
|
pl->userlandThreads++;
|
|
|
|
pl->totalTasks++;
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (settings->flags & PROCESS_FLAG_IO)
|
|
|
|
PCPProcessList_updateIO(pp, pid, offset, now);
|
|
|
|
|
|
|
|
PCPProcessList_updateMemory(pp, pid, offset);
|
|
|
|
|
|
|
|
if ((settings->flags & PROCESS_FLAG_LINUX_SMAPS) &&
|
|
|
|
(Process_isKernelThread(proc) == false)) {
|
2021-08-14 21:30:19 +00:00
|
|
|
if (PCPMetric_enabled(PCP_PROC_SMAPS_PSS))
|
Add a platform for Performance Co-Pilot (PCP) metrics
This introduces an initial platform for extracting metrics
using the PCP performance metrics API - PMAPI(3). It can
be used via the --enable-pcp=yes configure option.
So far I've added support for live localhost metrics only,
and only using pre-defined metrics already found in htop.
If available, all sampling is performed by pmcd(1) - else,
we fallback to htop doing the metric sampling itself (all
below the PMAPI). When pmcd is used, it may be configured
to run children with elevated privileges, so htop does not
need to be setuid (authentication with pmcd is available).
Additionally, the PMAPI allows us to support archives (for
historical analysis and for automated regression tests in
htop). We'll need platform-specific command line argument
additions, which isn't yet feasible in htop (not difficult
to add though).
The goal of this first version is minimal impact in terms
of modifying the htop codebase, to introduce key ideas in
PCP (metric namespace, metadata, APIs and so on) and give
us something to discuss, experiment with and build on.
2021-02-17 03:43:56 +00:00
|
|
|
PCPProcessList_updateSmaps(pp, pid, offset);
|
|
|
|
}
|
|
|
|
|
|
|
|
char command[MAX_NAME + 1];
|
|
|
|
unsigned int tty_nr = proc->tty_nr;
|
|
|
|
unsigned long long int lasttimes = pp->utime + pp->stime;
|
|
|
|
|
|
|
|
PCPProcessList_updateInfo(proc, pid, offset, command, sizeof(command));
|
|
|
|
proc->starttime_ctime += Platform_getBootTime();
|
|
|
|
if (tty_nr != proc->tty_nr)
|
2021-04-14 23:03:12 +00:00
|
|
|
PCPProcessList_updateTTY(proc, pid, offset);
|
Add a platform for Performance Co-Pilot (PCP) metrics
This introduces an initial platform for extracting metrics
using the PCP performance metrics API - PMAPI(3). It can
be used via the --enable-pcp=yes configure option.
So far I've added support for live localhost metrics only,
and only using pre-defined metrics already found in htop.
If available, all sampling is performed by pmcd(1) - else,
we fallback to htop doing the metric sampling itself (all
below the PMAPI). When pmcd is used, it may be configured
to run children with elevated privileges, so htop does not
need to be setuid (authentication with pmcd is available).
Additionally, the PMAPI allows us to support archives (for
historical analysis and for automated regression tests in
htop). We'll need platform-specific command line argument
additions, which isn't yet feasible in htop (not difficult
to add though).
The goal of this first version is minimal impact in terms
of modifying the htop codebase, to introduce key ideas in
PCP (metric namespace, metadata, APIs and so on) and give
us something to discuss, experiment with and build on.
2021-02-17 03:43:56 +00:00
|
|
|
|
|
|
|
float percent_cpu = (pp->utime + pp->stime - lasttimes) / period * 100.0;
|
|
|
|
proc->percent_cpu = isnan(percent_cpu) ?
|
2021-06-12 16:17:28 +00:00
|
|
|
0.0 : CLAMP(percent_cpu, 0.0, pl->activeCPUs * 100.0);
|
Add a platform for Performance Co-Pilot (PCP) metrics
This introduces an initial platform for extracting metrics
using the PCP performance metrics API - PMAPI(3). It can
be used via the --enable-pcp=yes configure option.
So far I've added support for live localhost metrics only,
and only using pre-defined metrics already found in htop.
If available, all sampling is performed by pmcd(1) - else,
we fallback to htop doing the metric sampling itself (all
below the PMAPI). When pmcd is used, it may be configured
to run children with elevated privileges, so htop does not
need to be setuid (authentication with pmcd is available).
Additionally, the PMAPI allows us to support archives (for
historical analysis and for automated regression tests in
htop). We'll need platform-specific command line argument
additions, which isn't yet feasible in htop (not difficult
to add though).
The goal of this first version is minimal impact in terms
of modifying the htop codebase, to introduce key ideas in
PCP (metric namespace, metadata, APIs and so on) and give
us something to discuss, experiment with and build on.
2021-02-17 03:43:56 +00:00
|
|
|
proc->percent_mem = proc->m_resident / (double)pl->totalMem * 100.0;
|
|
|
|
|
2021-06-18 18:42:54 +00:00
|
|
|
PCPProcessList_updateUsername(proc, pid, offset, pl->usersTable);
|
|
|
|
|
Add a platform for Performance Co-Pilot (PCP) metrics
This introduces an initial platform for extracting metrics
using the PCP performance metrics API - PMAPI(3). It can
be used via the --enable-pcp=yes configure option.
So far I've added support for live localhost metrics only,
and only using pre-defined metrics already found in htop.
If available, all sampling is performed by pmcd(1) - else,
we fallback to htop doing the metric sampling itself (all
below the PMAPI). When pmcd is used, it may be configured
to run children with elevated privileges, so htop does not
need to be setuid (authentication with pmcd is available).
Additionally, the PMAPI allows us to support archives (for
historical analysis and for automated regression tests in
htop). We'll need platform-specific command line argument
additions, which isn't yet feasible in htop (not difficult
to add though).
The goal of this first version is minimal impact in terms
of modifying the htop codebase, to introduce key ideas in
PCP (metric namespace, metadata, APIs and so on) and give
us something to discuss, experiment with and build on.
2021-02-17 03:43:56 +00:00
|
|
|
if (!preExisting) {
|
|
|
|
PCPProcessList_updateCmdline(proc, pid, offset, command);
|
|
|
|
Process_fillStarttimeBuffer(proc);
|
|
|
|
ProcessList_add(pl, proc);
|
|
|
|
} else if (settings->updateProcessNames && proc->state != 'Z') {
|
|
|
|
PCPProcessList_updateCmdline(proc, pid, offset, command);
|
|
|
|
}
|
|
|
|
|
|
|
|
if (settings->flags & PROCESS_FLAG_LINUX_CGROUP)
|
|
|
|
PCPProcessList_readCGroups(pp, pid, offset);
|
|
|
|
|
|
|
|
if (settings->flags & PROCESS_FLAG_LINUX_OOM)
|
|
|
|
PCPProcessList_readOomData(pp, pid, offset);
|
|
|
|
|
|
|
|
if (settings->flags & PROCESS_FLAG_LINUX_CTXT)
|
|
|
|
PCPProcessList_readCtxtData(pp, pid, offset);
|
|
|
|
|
|
|
|
if (settings->flags & PROCESS_FLAG_LINUX_SECATTR)
|
|
|
|
PCPProcessList_readSecattrData(pp, pid, offset);
|
|
|
|
|
2021-05-27 06:05:48 +00:00
|
|
|
if (settings->flags & PROCESS_FLAG_CWD)
|
|
|
|
PCPProcessList_readCwd(pp, pid, offset);
|
|
|
|
|
2021-08-06 06:45:30 +00:00
|
|
|
if (settings->flags & PROCESS_FLAG_LINUX_AUTOGROUP)
|
|
|
|
PCPProcessList_readAutogroup(pp, pid, offset);
|
|
|
|
|
2021-05-27 06:05:48 +00:00
|
|
|
if (proc->state == 'Z' && !proc->cmdline && command[0]) {
|
|
|
|
Process_updateCmdline(proc, command, 0, strlen(command));
|
Add a platform for Performance Co-Pilot (PCP) metrics
This introduces an initial platform for extracting metrics
using the PCP performance metrics API - PMAPI(3). It can
be used via the --enable-pcp=yes configure option.
So far I've added support for live localhost metrics only,
and only using pre-defined metrics already found in htop.
If available, all sampling is performed by pmcd(1) - else,
we fallback to htop doing the metric sampling itself (all
below the PMAPI). When pmcd is used, it may be configured
to run children with elevated privileges, so htop does not
need to be setuid (authentication with pmcd is available).
Additionally, the PMAPI allows us to support archives (for
historical analysis and for automated regression tests in
htop). We'll need platform-specific command line argument
additions, which isn't yet feasible in htop (not difficult
to add though).
The goal of this first version is minimal impact in terms
of modifying the htop codebase, to introduce key ideas in
PCP (metric namespace, metadata, APIs and so on) and give
us something to discuss, experiment with and build on.
2021-02-17 03:43:56 +00:00
|
|
|
} else if (Process_isThread(proc)) {
|
2021-05-27 06:05:48 +00:00
|
|
|
if ((settings->showThreadNames || Process_isKernelThread(proc)) && command[0]) {
|
|
|
|
Process_updateCmdline(proc, command, 0, strlen(command));
|
Add a platform for Performance Co-Pilot (PCP) metrics
This introduces an initial platform for extracting metrics
using the PCP performance metrics API - PMAPI(3). It can
be used via the --enable-pcp=yes configure option.
So far I've added support for live localhost metrics only,
and only using pre-defined metrics already found in htop.
If available, all sampling is performed by pmcd(1) - else,
we fallback to htop doing the metric sampling itself (all
below the PMAPI). When pmcd is used, it may be configured
to run children with elevated privileges, so htop does not
need to be setuid (authentication with pmcd is available).
Additionally, the PMAPI allows us to support archives (for
historical analysis and for automated regression tests in
htop). We'll need platform-specific command line argument
additions, which isn't yet feasible in htop (not difficult
to add though).
The goal of this first version is minimal impact in terms
of modifying the htop codebase, to introduce key ideas in
PCP (metric namespace, metadata, APIs and so on) and give
us something to discuss, experiment with and build on.
2021-02-17 03:43:56 +00:00
|
|
|
}
|
2021-05-27 06:05:48 +00:00
|
|
|
|
Add a platform for Performance Co-Pilot (PCP) metrics
This introduces an initial platform for extracting metrics
using the PCP performance metrics API - PMAPI(3). It can
be used via the --enable-pcp=yes configure option.
So far I've added support for live localhost metrics only,
and only using pre-defined metrics already found in htop.
If available, all sampling is performed by pmcd(1) - else,
we fallback to htop doing the metric sampling itself (all
below the PMAPI). When pmcd is used, it may be configured
to run children with elevated privileges, so htop does not
need to be setuid (authentication with pmcd is available).
Additionally, the PMAPI allows us to support archives (for
historical analysis and for automated regression tests in
htop). We'll need platform-specific command line argument
additions, which isn't yet feasible in htop (not difficult
to add though).
The goal of this first version is minimal impact in terms
of modifying the htop codebase, to introduce key ideas in
PCP (metric namespace, metadata, APIs and so on) and give
us something to discuss, experiment with and build on.
2021-02-17 03:43:56 +00:00
|
|
|
if (Process_isKernelThread(proc)) {
|
|
|
|
pl->kernelThreads++;
|
|
|
|
} else {
|
|
|
|
pl->userlandThreads++;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Set at the end when we know if a new entry is a thread */
|
|
|
|
proc->show = ! ((hideKernelThreads && Process_isKernelThread(proc)) ||
|
|
|
|
(hideUserlandThreads && Process_isUserlandThread(proc)));
|
|
|
|
|
|
|
|
pl->totalTasks++;
|
|
|
|
if (proc->state == 'R')
|
|
|
|
pl->runningTasks++;
|
|
|
|
proc->updated = true;
|
|
|
|
}
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
static void PCPProcessList_updateMemoryInfo(ProcessList* super) {
|
|
|
|
unsigned long long int freeMem = 0;
|
|
|
|
unsigned long long int swapFreeMem = 0;
|
|
|
|
unsigned long long int sreclaimableMem = 0;
|
|
|
|
super->totalMem = super->usedMem = super->cachedMem = 0;
|
2021-07-28 23:44:03 +00:00
|
|
|
super->usedSwap = super->totalSwap = super->sharedMem = 0;
|
Add a platform for Performance Co-Pilot (PCP) metrics
This introduces an initial platform for extracting metrics
using the PCP performance metrics API - PMAPI(3). It can
be used via the --enable-pcp=yes configure option.
So far I've added support for live localhost metrics only,
and only using pre-defined metrics already found in htop.
If available, all sampling is performed by pmcd(1) - else,
we fallback to htop doing the metric sampling itself (all
below the PMAPI). When pmcd is used, it may be configured
to run children with elevated privileges, so htop does not
need to be setuid (authentication with pmcd is available).
Additionally, the PMAPI allows us to support archives (for
historical analysis and for automated regression tests in
htop). We'll need platform-specific command line argument
additions, which isn't yet feasible in htop (not difficult
to add though).
The goal of this first version is minimal impact in terms
of modifying the htop codebase, to introduce key ideas in
PCP (metric namespace, metadata, APIs and so on) and give
us something to discuss, experiment with and build on.
2021-02-17 03:43:56 +00:00
|
|
|
|
|
|
|
pmAtomValue value;
|
2021-08-14 21:30:19 +00:00
|
|
|
if (PCPMetric_values(PCP_MEM_TOTAL, &value, 1, PM_TYPE_U64) != NULL)
|
Add a platform for Performance Co-Pilot (PCP) metrics
This introduces an initial platform for extracting metrics
using the PCP performance metrics API - PMAPI(3). It can
be used via the --enable-pcp=yes configure option.
So far I've added support for live localhost metrics only,
and only using pre-defined metrics already found in htop.
If available, all sampling is performed by pmcd(1) - else,
we fallback to htop doing the metric sampling itself (all
below the PMAPI). When pmcd is used, it may be configured
to run children with elevated privileges, so htop does not
need to be setuid (authentication with pmcd is available).
Additionally, the PMAPI allows us to support archives (for
historical analysis and for automated regression tests in
htop). We'll need platform-specific command line argument
additions, which isn't yet feasible in htop (not difficult
to add though).
The goal of this first version is minimal impact in terms
of modifying the htop codebase, to introduce key ideas in
PCP (metric namespace, metadata, APIs and so on) and give
us something to discuss, experiment with and build on.
2021-02-17 03:43:56 +00:00
|
|
|
super->totalMem = value.ull;
|
2021-08-14 21:30:19 +00:00
|
|
|
if (PCPMetric_values(PCP_MEM_FREE, &value, 1, PM_TYPE_U64) != NULL)
|
Add a platform for Performance Co-Pilot (PCP) metrics
This introduces an initial platform for extracting metrics
using the PCP performance metrics API - PMAPI(3). It can
be used via the --enable-pcp=yes configure option.
So far I've added support for live localhost metrics only,
and only using pre-defined metrics already found in htop.
If available, all sampling is performed by pmcd(1) - else,
we fallback to htop doing the metric sampling itself (all
below the PMAPI). When pmcd is used, it may be configured
to run children with elevated privileges, so htop does not
need to be setuid (authentication with pmcd is available).
Additionally, the PMAPI allows us to support archives (for
historical analysis and for automated regression tests in
htop). We'll need platform-specific command line argument
additions, which isn't yet feasible in htop (not difficult
to add though).
The goal of this first version is minimal impact in terms
of modifying the htop codebase, to introduce key ideas in
PCP (metric namespace, metadata, APIs and so on) and give
us something to discuss, experiment with and build on.
2021-02-17 03:43:56 +00:00
|
|
|
freeMem = value.ull;
|
2021-08-14 21:30:19 +00:00
|
|
|
if (PCPMetric_values(PCP_MEM_BUFFERS, &value, 1, PM_TYPE_U64) != NULL)
|
Add a platform for Performance Co-Pilot (PCP) metrics
This introduces an initial platform for extracting metrics
using the PCP performance metrics API - PMAPI(3). It can
be used via the --enable-pcp=yes configure option.
So far I've added support for live localhost metrics only,
and only using pre-defined metrics already found in htop.
If available, all sampling is performed by pmcd(1) - else,
we fallback to htop doing the metric sampling itself (all
below the PMAPI). When pmcd is used, it may be configured
to run children with elevated privileges, so htop does not
need to be setuid (authentication with pmcd is available).
Additionally, the PMAPI allows us to support archives (for
historical analysis and for automated regression tests in
htop). We'll need platform-specific command line argument
additions, which isn't yet feasible in htop (not difficult
to add though).
The goal of this first version is minimal impact in terms
of modifying the htop codebase, to introduce key ideas in
PCP (metric namespace, metadata, APIs and so on) and give
us something to discuss, experiment with and build on.
2021-02-17 03:43:56 +00:00
|
|
|
super->buffersMem = value.ull;
|
2021-08-14 21:30:19 +00:00
|
|
|
if (PCPMetric_values(PCP_MEM_SRECLAIM, &value, 1, PM_TYPE_U64) != NULL)
|
Add a platform for Performance Co-Pilot (PCP) metrics
This introduces an initial platform for extracting metrics
using the PCP performance metrics API - PMAPI(3). It can
be used via the --enable-pcp=yes configure option.
So far I've added support for live localhost metrics only,
and only using pre-defined metrics already found in htop.
If available, all sampling is performed by pmcd(1) - else,
we fallback to htop doing the metric sampling itself (all
below the PMAPI). When pmcd is used, it may be configured
to run children with elevated privileges, so htop does not
need to be setuid (authentication with pmcd is available).
Additionally, the PMAPI allows us to support archives (for
historical analysis and for automated regression tests in
htop). We'll need platform-specific command line argument
additions, which isn't yet feasible in htop (not difficult
to add though).
The goal of this first version is minimal impact in terms
of modifying the htop codebase, to introduce key ideas in
PCP (metric namespace, metadata, APIs and so on) and give
us something to discuss, experiment with and build on.
2021-02-17 03:43:56 +00:00
|
|
|
sreclaimableMem = value.ull;
|
2021-08-14 21:30:19 +00:00
|
|
|
if (PCPMetric_values(PCP_MEM_SHARED, &value, 1, PM_TYPE_U64) != NULL)
|
2021-03-16 22:54:15 +00:00
|
|
|
super->sharedMem = value.ull;
|
2021-08-14 21:30:19 +00:00
|
|
|
if (PCPMetric_values(PCP_MEM_CACHED, &value, 1, PM_TYPE_U64) != NULL)
|
2021-07-28 23:44:03 +00:00
|
|
|
super->cachedMem = value.ull + sreclaimableMem - super->sharedMem;
|
|
|
|
const memory_t usedDiff = freeMem + super->cachedMem + sreclaimableMem + super->buffersMem;
|
Add a platform for Performance Co-Pilot (PCP) metrics
This introduces an initial platform for extracting metrics
using the PCP performance metrics API - PMAPI(3). It can
be used via the --enable-pcp=yes configure option.
So far I've added support for live localhost metrics only,
and only using pre-defined metrics already found in htop.
If available, all sampling is performed by pmcd(1) - else,
we fallback to htop doing the metric sampling itself (all
below the PMAPI). When pmcd is used, it may be configured
to run children with elevated privileges, so htop does not
need to be setuid (authentication with pmcd is available).
Additionally, the PMAPI allows us to support archives (for
historical analysis and for automated regression tests in
htop). We'll need platform-specific command line argument
additions, which isn't yet feasible in htop (not difficult
to add though).
The goal of this first version is minimal impact in terms
of modifying the htop codebase, to introduce key ideas in
PCP (metric namespace, metadata, APIs and so on) and give
us something to discuss, experiment with and build on.
2021-02-17 03:43:56 +00:00
|
|
|
super->usedMem = (super->totalMem >= usedDiff) ?
|
|
|
|
super->totalMem - usedDiff : super->totalMem - freeMem;
|
2021-08-14 21:30:19 +00:00
|
|
|
if (PCPMetric_values(PCP_MEM_AVAILABLE, &value, 1, PM_TYPE_U64) != NULL)
|
Add a platform for Performance Co-Pilot (PCP) metrics
This introduces an initial platform for extracting metrics
using the PCP performance metrics API - PMAPI(3). It can
be used via the --enable-pcp=yes configure option.
So far I've added support for live localhost metrics only,
and only using pre-defined metrics already found in htop.
If available, all sampling is performed by pmcd(1) - else,
we fallback to htop doing the metric sampling itself (all
below the PMAPI). When pmcd is used, it may be configured
to run children with elevated privileges, so htop does not
need to be setuid (authentication with pmcd is available).
Additionally, the PMAPI allows us to support archives (for
historical analysis and for automated regression tests in
htop). We'll need platform-specific command line argument
additions, which isn't yet feasible in htop (not difficult
to add though).
The goal of this first version is minimal impact in terms
of modifying the htop codebase, to introduce key ideas in
PCP (metric namespace, metadata, APIs and so on) and give
us something to discuss, experiment with and build on.
2021-02-17 03:43:56 +00:00
|
|
|
super->availableMem = MINIMUM(value.ull, super->totalMem);
|
|
|
|
else
|
|
|
|
super->availableMem = freeMem;
|
2021-08-14 21:30:19 +00:00
|
|
|
if (PCPMetric_values(PCP_MEM_SWAPFREE, &value, 1, PM_TYPE_U64) != NULL)
|
Add a platform for Performance Co-Pilot (PCP) metrics
This introduces an initial platform for extracting metrics
using the PCP performance metrics API - PMAPI(3). It can
be used via the --enable-pcp=yes configure option.
So far I've added support for live localhost metrics only,
and only using pre-defined metrics already found in htop.
If available, all sampling is performed by pmcd(1) - else,
we fallback to htop doing the metric sampling itself (all
below the PMAPI). When pmcd is used, it may be configured
to run children with elevated privileges, so htop does not
need to be setuid (authentication with pmcd is available).
Additionally, the PMAPI allows us to support archives (for
historical analysis and for automated regression tests in
htop). We'll need platform-specific command line argument
additions, which isn't yet feasible in htop (not difficult
to add though).
The goal of this first version is minimal impact in terms
of modifying the htop codebase, to introduce key ideas in
PCP (metric namespace, metadata, APIs and so on) and give
us something to discuss, experiment with and build on.
2021-02-17 03:43:56 +00:00
|
|
|
swapFreeMem = value.ull;
|
2021-08-14 21:30:19 +00:00
|
|
|
if (PCPMetric_values(PCP_MEM_SWAPTOTAL, &value, 1, PM_TYPE_U64) != NULL)
|
Add a platform for Performance Co-Pilot (PCP) metrics
This introduces an initial platform for extracting metrics
using the PCP performance metrics API - PMAPI(3). It can
be used via the --enable-pcp=yes configure option.
So far I've added support for live localhost metrics only,
and only using pre-defined metrics already found in htop.
If available, all sampling is performed by pmcd(1) - else,
we fallback to htop doing the metric sampling itself (all
below the PMAPI). When pmcd is used, it may be configured
to run children with elevated privileges, so htop does not
need to be setuid (authentication with pmcd is available).
Additionally, the PMAPI allows us to support archives (for
historical analysis and for automated regression tests in
htop). We'll need platform-specific command line argument
additions, which isn't yet feasible in htop (not difficult
to add though).
The goal of this first version is minimal impact in terms
of modifying the htop codebase, to introduce key ideas in
PCP (metric namespace, metadata, APIs and so on) and give
us something to discuss, experiment with and build on.
2021-02-17 03:43:56 +00:00
|
|
|
super->totalSwap = value.ull;
|
2021-08-14 21:30:19 +00:00
|
|
|
if (PCPMetric_values(PCP_MEM_SWAPCACHED, &value, 1, PM_TYPE_U64) != NULL)
|
Add a platform for Performance Co-Pilot (PCP) metrics
This introduces an initial platform for extracting metrics
using the PCP performance metrics API - PMAPI(3). It can
be used via the --enable-pcp=yes configure option.
So far I've added support for live localhost metrics only,
and only using pre-defined metrics already found in htop.
If available, all sampling is performed by pmcd(1) - else,
we fallback to htop doing the metric sampling itself (all
below the PMAPI). When pmcd is used, it may be configured
to run children with elevated privileges, so htop does not
need to be setuid (authentication with pmcd is available).
Additionally, the PMAPI allows us to support archives (for
historical analysis and for automated regression tests in
htop). We'll need platform-specific command line argument
additions, which isn't yet feasible in htop (not difficult
to add though).
The goal of this first version is minimal impact in terms
of modifying the htop codebase, to introduce key ideas in
PCP (metric namespace, metadata, APIs and so on) and give
us something to discuss, experiment with and build on.
2021-02-17 03:43:56 +00:00
|
|
|
super->cachedSwap = value.ull;
|
2021-07-14 17:15:09 +00:00
|
|
|
super->usedSwap = super->totalSwap - swapFreeMem - super->cachedSwap;
|
Add a platform for Performance Co-Pilot (PCP) metrics
This introduces an initial platform for extracting metrics
using the PCP performance metrics API - PMAPI(3). It can
be used via the --enable-pcp=yes configure option.
So far I've added support for live localhost metrics only,
and only using pre-defined metrics already found in htop.
If available, all sampling is performed by pmcd(1) - else,
we fallback to htop doing the metric sampling itself (all
below the PMAPI). When pmcd is used, it may be configured
to run children with elevated privileges, so htop does not
need to be setuid (authentication with pmcd is available).
Additionally, the PMAPI allows us to support archives (for
historical analysis and for automated regression tests in
htop). We'll need platform-specific command line argument
additions, which isn't yet feasible in htop (not difficult
to add though).
The goal of this first version is minimal impact in terms
of modifying the htop codebase, to introduce key ideas in
PCP (metric namespace, metadata, APIs and so on) and give
us something to discuss, experiment with and build on.
2021-02-17 03:43:56 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/* make copies of previously sampled values to avoid overwrite */
|
|
|
|
static inline void PCPProcessList_backupCPUTime(pmAtomValue* values) {
|
|
|
|
/* the PERIOD fields (must) mirror the TIME fields */
|
|
|
|
for (int metric = CPU_TOTAL_TIME; metric < CPU_TOTAL_PERIOD; metric++) {
|
|
|
|
values[metric + CPU_TOTAL_PERIOD] = values[metric];
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
static inline void PCPProcessList_saveCPUTimePeriod(pmAtomValue* values, CPUMetric previous, pmAtomValue* latest) {
|
2021-07-14 17:24:18 +00:00
|
|
|
pmAtomValue* value;
|
Add a platform for Performance Co-Pilot (PCP) metrics
This introduces an initial platform for extracting metrics
using the PCP performance metrics API - PMAPI(3). It can
be used via the --enable-pcp=yes configure option.
So far I've added support for live localhost metrics only,
and only using pre-defined metrics already found in htop.
If available, all sampling is performed by pmcd(1) - else,
we fallback to htop doing the metric sampling itself (all
below the PMAPI). When pmcd is used, it may be configured
to run children with elevated privileges, so htop does not
need to be setuid (authentication with pmcd is available).
Additionally, the PMAPI allows us to support archives (for
historical analysis and for automated regression tests in
htop). We'll need platform-specific command line argument
additions, which isn't yet feasible in htop (not difficult
to add though).
The goal of this first version is minimal impact in terms
of modifying the htop codebase, to introduce key ideas in
PCP (metric namespace, metadata, APIs and so on) and give
us something to discuss, experiment with and build on.
2021-02-17 03:43:56 +00:00
|
|
|
|
|
|
|
/* new value for period */
|
|
|
|
value = &values[previous];
|
|
|
|
if (latest->ull > value->ull)
|
|
|
|
value->ull = latest->ull - value->ull;
|
|
|
|
else
|
|
|
|
value->ull = 0;
|
|
|
|
|
|
|
|
/* new value for time */
|
|
|
|
value = &values[previous - CPU_TOTAL_PERIOD];
|
|
|
|
value->ull = latest->ull;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* using copied sampled values and new values, calculate derivations */
|
|
|
|
static void PCPProcessList_deriveCPUTime(pmAtomValue* values) {
|
|
|
|
|
|
|
|
pmAtomValue* usertime = &values[CPU_USER_TIME];
|
|
|
|
pmAtomValue* guesttime = &values[CPU_GUEST_TIME];
|
|
|
|
usertime->ull -= guesttime->ull;
|
|
|
|
|
|
|
|
pmAtomValue* nicetime = &values[CPU_NICE_TIME];
|
|
|
|
pmAtomValue* guestnicetime = &values[CPU_GUESTNICE_TIME];
|
|
|
|
nicetime->ull -= guestnicetime->ull;
|
|
|
|
|
|
|
|
pmAtomValue* idletime = &values[CPU_IDLE_TIME];
|
|
|
|
pmAtomValue* iowaittime = &values[CPU_IOWAIT_TIME];
|
|
|
|
pmAtomValue* idlealltime = &values[CPU_IDLE_ALL_TIME];
|
|
|
|
idlealltime->ull = idletime->ull + iowaittime->ull;
|
|
|
|
|
|
|
|
pmAtomValue* systemtime = &values[CPU_SYSTEM_TIME];
|
|
|
|
pmAtomValue* irqtime = &values[CPU_IRQ_TIME];
|
|
|
|
pmAtomValue* softirqtime = &values[CPU_SOFTIRQ_TIME];
|
|
|
|
pmAtomValue* systalltime = &values[CPU_SYSTEM_ALL_TIME];
|
|
|
|
systalltime->ull = systemtime->ull + irqtime->ull + softirqtime->ull;
|
|
|
|
|
|
|
|
pmAtomValue* virtalltime = &values[CPU_GUEST_TIME];
|
|
|
|
virtalltime->ull = guesttime->ull + guestnicetime->ull;
|
|
|
|
|
|
|
|
pmAtomValue* stealtime = &values[CPU_STEAL_TIME];
|
|
|
|
pmAtomValue* totaltime = &values[CPU_TOTAL_TIME];
|
|
|
|
totaltime->ull = usertime->ull + nicetime->ull + systalltime->ull +
|
|
|
|
idlealltime->ull + stealtime->ull + virtalltime->ull;
|
|
|
|
|
|
|
|
PCPProcessList_saveCPUTimePeriod(values, CPU_USER_PERIOD, usertime);
|
|
|
|
PCPProcessList_saveCPUTimePeriod(values, CPU_NICE_PERIOD, nicetime);
|
|
|
|
PCPProcessList_saveCPUTimePeriod(values, CPU_SYSTEM_PERIOD, systemtime);
|
|
|
|
PCPProcessList_saveCPUTimePeriod(values, CPU_SYSTEM_ALL_PERIOD, systalltime);
|
|
|
|
PCPProcessList_saveCPUTimePeriod(values, CPU_IDLE_ALL_PERIOD, idlealltime);
|
|
|
|
PCPProcessList_saveCPUTimePeriod(values, CPU_IDLE_PERIOD, idletime);
|
|
|
|
PCPProcessList_saveCPUTimePeriod(values, CPU_IOWAIT_PERIOD, iowaittime);
|
|
|
|
PCPProcessList_saveCPUTimePeriod(values, CPU_IRQ_PERIOD, irqtime);
|
|
|
|
PCPProcessList_saveCPUTimePeriod(values, CPU_SOFTIRQ_PERIOD, softirqtime);
|
|
|
|
PCPProcessList_saveCPUTimePeriod(values, CPU_STEAL_PERIOD, stealtime);
|
|
|
|
PCPProcessList_saveCPUTimePeriod(values, CPU_GUEST_PERIOD, virtalltime);
|
|
|
|
PCPProcessList_saveCPUTimePeriod(values, CPU_TOTAL_PERIOD, totaltime);
|
|
|
|
}
|
|
|
|
|
2021-08-14 21:30:19 +00:00
|
|
|
static void PCPProcessList_updateAllCPUTime(PCPProcessList* this, PCPMetric metric, CPUMetric cpumetric)
|
Add a platform for Performance Co-Pilot (PCP) metrics
This introduces an initial platform for extracting metrics
using the PCP performance metrics API - PMAPI(3). It can
be used via the --enable-pcp=yes configure option.
So far I've added support for live localhost metrics only,
and only using pre-defined metrics already found in htop.
If available, all sampling is performed by pmcd(1) - else,
we fallback to htop doing the metric sampling itself (all
below the PMAPI). When pmcd is used, it may be configured
to run children with elevated privileges, so htop does not
need to be setuid (authentication with pmcd is available).
Additionally, the PMAPI allows us to support archives (for
historical analysis and for automated regression tests in
htop). We'll need platform-specific command line argument
additions, which isn't yet feasible in htop (not difficult
to add though).
The goal of this first version is minimal impact in terms
of modifying the htop codebase, to introduce key ideas in
PCP (metric namespace, metadata, APIs and so on) and give
us something to discuss, experiment with and build on.
2021-02-17 03:43:56 +00:00
|
|
|
{
|
|
|
|
pmAtomValue* value = &this->cpu[cpumetric];
|
2021-08-14 21:30:19 +00:00
|
|
|
if (PCPMetric_values(metric, value, 1, PM_TYPE_U64) == NULL)
|
Add a platform for Performance Co-Pilot (PCP) metrics
This introduces an initial platform for extracting metrics
using the PCP performance metrics API - PMAPI(3). It can
be used via the --enable-pcp=yes configure option.
So far I've added support for live localhost metrics only,
and only using pre-defined metrics already found in htop.
If available, all sampling is performed by pmcd(1) - else,
we fallback to htop doing the metric sampling itself (all
below the PMAPI). When pmcd is used, it may be configured
to run children with elevated privileges, so htop does not
need to be setuid (authentication with pmcd is available).
Additionally, the PMAPI allows us to support archives (for
historical analysis and for automated regression tests in
htop). We'll need platform-specific command line argument
additions, which isn't yet feasible in htop (not difficult
to add though).
The goal of this first version is minimal impact in terms
of modifying the htop codebase, to introduce key ideas in
PCP (metric namespace, metadata, APIs and so on) and give
us something to discuss, experiment with and build on.
2021-02-17 03:43:56 +00:00
|
|
|
memset(&value, 0, sizeof(pmAtomValue));
|
|
|
|
}
|
|
|
|
|
2021-08-14 21:30:19 +00:00
|
|
|
static void PCPProcessList_updatePerCPUTime(PCPProcessList* this, PCPMetric metric, CPUMetric cpumetric)
|
Add a platform for Performance Co-Pilot (PCP) metrics
This introduces an initial platform for extracting metrics
using the PCP performance metrics API - PMAPI(3). It can
be used via the --enable-pcp=yes configure option.
So far I've added support for live localhost metrics only,
and only using pre-defined metrics already found in htop.
If available, all sampling is performed by pmcd(1) - else,
we fallback to htop doing the metric sampling itself (all
below the PMAPI). When pmcd is used, it may be configured
to run children with elevated privileges, so htop does not
need to be setuid (authentication with pmcd is available).
Additionally, the PMAPI allows us to support archives (for
historical analysis and for automated regression tests in
htop). We'll need platform-specific command line argument
additions, which isn't yet feasible in htop (not difficult
to add though).
The goal of this first version is minimal impact in terms
of modifying the htop codebase, to introduce key ideas in
PCP (metric namespace, metadata, APIs and so on) and give
us something to discuss, experiment with and build on.
2021-02-17 03:43:56 +00:00
|
|
|
{
|
2021-06-12 16:17:28 +00:00
|
|
|
int cpus = this->super.existingCPUs;
|
2021-08-14 21:30:19 +00:00
|
|
|
if (PCPMetric_values(metric, this->values, cpus, PM_TYPE_U64) == NULL)
|
Add a platform for Performance Co-Pilot (PCP) metrics
This introduces an initial platform for extracting metrics
using the PCP performance metrics API - PMAPI(3). It can
be used via the --enable-pcp=yes configure option.
So far I've added support for live localhost metrics only,
and only using pre-defined metrics already found in htop.
If available, all sampling is performed by pmcd(1) - else,
we fallback to htop doing the metric sampling itself (all
below the PMAPI). When pmcd is used, it may be configured
to run children with elevated privileges, so htop does not
need to be setuid (authentication with pmcd is available).
Additionally, the PMAPI allows us to support archives (for
historical analysis and for automated regression tests in
htop). We'll need platform-specific command line argument
additions, which isn't yet feasible in htop (not difficult
to add though).
The goal of this first version is minimal impact in terms
of modifying the htop codebase, to introduce key ideas in
PCP (metric namespace, metadata, APIs and so on) and give
us something to discuss, experiment with and build on.
2021-02-17 03:43:56 +00:00
|
|
|
memset(this->values, 0, cpus * sizeof(pmAtomValue));
|
|
|
|
for (int i = 0; i < cpus; i++)
|
|
|
|
this->percpu[i][cpumetric].ull = this->values[i].ull;
|
|
|
|
}
|
|
|
|
|
2021-08-14 21:30:19 +00:00
|
|
|
static void PCPProcessList_updatePerCPUReal(PCPProcessList* this, PCPMetric metric, CPUMetric cpumetric)
|
Add a platform for Performance Co-Pilot (PCP) metrics
This introduces an initial platform for extracting metrics
using the PCP performance metrics API - PMAPI(3). It can
be used via the --enable-pcp=yes configure option.
So far I've added support for live localhost metrics only,
and only using pre-defined metrics already found in htop.
If available, all sampling is performed by pmcd(1) - else,
we fallback to htop doing the metric sampling itself (all
below the PMAPI). When pmcd is used, it may be configured
to run children with elevated privileges, so htop does not
need to be setuid (authentication with pmcd is available).
Additionally, the PMAPI allows us to support archives (for
historical analysis and for automated regression tests in
htop). We'll need platform-specific command line argument
additions, which isn't yet feasible in htop (not difficult
to add though).
The goal of this first version is minimal impact in terms
of modifying the htop codebase, to introduce key ideas in
PCP (metric namespace, metadata, APIs and so on) and give
us something to discuss, experiment with and build on.
2021-02-17 03:43:56 +00:00
|
|
|
{
|
2021-06-12 16:17:28 +00:00
|
|
|
int cpus = this->super.existingCPUs;
|
2021-08-14 21:30:19 +00:00
|
|
|
if (PCPMetric_values(metric, this->values, cpus, PM_TYPE_DOUBLE) == NULL)
|
Add a platform for Performance Co-Pilot (PCP) metrics
This introduces an initial platform for extracting metrics
using the PCP performance metrics API - PMAPI(3). It can
be used via the --enable-pcp=yes configure option.
So far I've added support for live localhost metrics only,
and only using pre-defined metrics already found in htop.
If available, all sampling is performed by pmcd(1) - else,
we fallback to htop doing the metric sampling itself (all
below the PMAPI). When pmcd is used, it may be configured
to run children with elevated privileges, so htop does not
need to be setuid (authentication with pmcd is available).
Additionally, the PMAPI allows us to support archives (for
historical analysis and for automated regression tests in
htop). We'll need platform-specific command line argument
additions, which isn't yet feasible in htop (not difficult
to add though).
The goal of this first version is minimal impact in terms
of modifying the htop codebase, to introduce key ideas in
PCP (metric namespace, metadata, APIs and so on) and give
us something to discuss, experiment with and build on.
2021-02-17 03:43:56 +00:00
|
|
|
memset(this->values, 0, cpus * sizeof(pmAtomValue));
|
|
|
|
for (int i = 0; i < cpus; i++)
|
|
|
|
this->percpu[i][cpumetric].d = this->values[i].d;
|
|
|
|
}
|
|
|
|
|
2021-07-15 01:22:05 +00:00
|
|
|
static inline void PCPProcessList_scanZfsArcstats(PCPProcessList* this) {
|
|
|
|
unsigned long long int dbufSize = 0;
|
|
|
|
unsigned long long int dnodeSize = 0;
|
|
|
|
unsigned long long int bonusSize = 0;
|
|
|
|
pmAtomValue value;
|
|
|
|
|
|
|
|
memset(&this->zfs, 0, sizeof(ZfsArcStats));
|
2021-08-14 21:30:19 +00:00
|
|
|
if (PCPMetric_values(PCP_ZFS_ARC_ANON_SIZE, &value, 1, PM_TYPE_U64))
|
2021-07-15 01:22:05 +00:00
|
|
|
this->zfs.anon = value.ull / ONE_K;
|
2021-08-14 21:30:19 +00:00
|
|
|
if (PCPMetric_values(PCP_ZFS_ARC_C_MAX, &value, 1, PM_TYPE_U64))
|
2021-07-15 01:22:05 +00:00
|
|
|
this->zfs.max = value.ull / ONE_K;
|
2021-08-14 21:30:19 +00:00
|
|
|
if (PCPMetric_values(PCP_ZFS_ARC_BONUS_SIZE, &value, 1, PM_TYPE_U64))
|
2021-07-15 01:22:05 +00:00
|
|
|
bonusSize = value.ull / ONE_K;
|
2021-08-14 21:30:19 +00:00
|
|
|
if (PCPMetric_values(PCP_ZFS_ARC_DBUF_SIZE, &value, 1, PM_TYPE_U64))
|
2021-07-15 01:22:05 +00:00
|
|
|
dbufSize = value.ull / ONE_K;
|
2021-08-14 21:30:19 +00:00
|
|
|
if (PCPMetric_values(PCP_ZFS_ARC_DNODE_SIZE, &value, 1, PM_TYPE_U64))
|
2021-07-15 01:22:05 +00:00
|
|
|
dnodeSize = value.ull / ONE_K;
|
2021-08-14 21:30:19 +00:00
|
|
|
if (PCPMetric_values(PCP_ZFS_ARC_COMPRESSED_SIZE, &value, 1, PM_TYPE_U64))
|
2021-07-15 01:22:05 +00:00
|
|
|
this->zfs.compressed = value.ull / ONE_K;
|
2021-08-14 21:30:19 +00:00
|
|
|
if (PCPMetric_values(PCP_ZFS_ARC_UNCOMPRESSED_SIZE, &value, 1, PM_TYPE_U64))
|
2021-07-15 01:22:05 +00:00
|
|
|
this->zfs.uncompressed = value.ull / ONE_K;
|
2021-08-14 21:30:19 +00:00
|
|
|
if (PCPMetric_values(PCP_ZFS_ARC_HDR_SIZE, &value, 1, PM_TYPE_U64))
|
2021-07-15 01:22:05 +00:00
|
|
|
this->zfs.header = value.ull / ONE_K;
|
2021-08-14 21:30:19 +00:00
|
|
|
if (PCPMetric_values(PCP_ZFS_ARC_MFU_SIZE, &value, 1, PM_TYPE_U64))
|
2021-07-15 01:22:05 +00:00
|
|
|
this->zfs.MFU = value.ull / ONE_K;
|
2021-08-14 21:30:19 +00:00
|
|
|
if (PCPMetric_values(PCP_ZFS_ARC_MRU_SIZE, &value, 1, PM_TYPE_U64))
|
2021-07-15 01:22:05 +00:00
|
|
|
this->zfs.MRU = value.ull / ONE_K;
|
2021-08-14 21:30:19 +00:00
|
|
|
if (PCPMetric_values(PCP_ZFS_ARC_SIZE, &value, 1, PM_TYPE_U64))
|
2021-07-15 01:22:05 +00:00
|
|
|
this->zfs.size = value.ull / ONE_K;
|
|
|
|
|
|
|
|
this->zfs.other = (dbufSize + dnodeSize + bonusSize) / ONE_K;
|
|
|
|
this->zfs.enabled = (this->zfs.size > 0);
|
|
|
|
this->zfs.isCompressed = (this->zfs.compressed > 0);
|
|
|
|
}
|
|
|
|
|
Add a platform for Performance Co-Pilot (PCP) metrics
This introduces an initial platform for extracting metrics
using the PCP performance metrics API - PMAPI(3). It can
be used via the --enable-pcp=yes configure option.
So far I've added support for live localhost metrics only,
and only using pre-defined metrics already found in htop.
If available, all sampling is performed by pmcd(1) - else,
we fallback to htop doing the metric sampling itself (all
below the PMAPI). When pmcd is used, it may be configured
to run children with elevated privileges, so htop does not
need to be setuid (authentication with pmcd is available).
Additionally, the PMAPI allows us to support archives (for
historical analysis and for automated regression tests in
htop). We'll need platform-specific command line argument
additions, which isn't yet feasible in htop (not difficult
to add though).
The goal of this first version is minimal impact in terms
of modifying the htop codebase, to introduce key ideas in
PCP (metric namespace, metadata, APIs and so on) and give
us something to discuss, experiment with and build on.
2021-02-17 03:43:56 +00:00
|
|
|
static void PCPProcessList_updateHeader(ProcessList* super, const Settings* settings) {
|
|
|
|
PCPProcessList_updateMemoryInfo(super);
|
|
|
|
|
|
|
|
PCPProcessList* this = (PCPProcessList*) super;
|
|
|
|
PCPProcessList_updateCPUcount(this);
|
|
|
|
|
|
|
|
PCPProcessList_backupCPUTime(this->cpu);
|
|
|
|
PCPProcessList_updateAllCPUTime(this, PCP_CPU_USER, CPU_USER_TIME);
|
|
|
|
PCPProcessList_updateAllCPUTime(this, PCP_CPU_NICE, CPU_NICE_TIME);
|
|
|
|
PCPProcessList_updateAllCPUTime(this, PCP_CPU_SYSTEM, CPU_SYSTEM_TIME);
|
|
|
|
PCPProcessList_updateAllCPUTime(this, PCP_CPU_IDLE, CPU_IDLE_TIME);
|
|
|
|
PCPProcessList_updateAllCPUTime(this, PCP_CPU_IOWAIT, CPU_IOWAIT_TIME);
|
|
|
|
PCPProcessList_updateAllCPUTime(this, PCP_CPU_IRQ, CPU_IRQ_TIME);
|
|
|
|
PCPProcessList_updateAllCPUTime(this, PCP_CPU_SOFTIRQ, CPU_SOFTIRQ_TIME);
|
|
|
|
PCPProcessList_updateAllCPUTime(this, PCP_CPU_STEAL, CPU_STEAL_TIME);
|
|
|
|
PCPProcessList_updateAllCPUTime(this, PCP_CPU_GUEST, CPU_GUEST_TIME);
|
|
|
|
PCPProcessList_deriveCPUTime(this->cpu);
|
|
|
|
|
2021-06-12 16:17:28 +00:00
|
|
|
for (unsigned int i = 0; i < super->existingCPUs; i++)
|
Add a platform for Performance Co-Pilot (PCP) metrics
This introduces an initial platform for extracting metrics
using the PCP performance metrics API - PMAPI(3). It can
be used via the --enable-pcp=yes configure option.
So far I've added support for live localhost metrics only,
and only using pre-defined metrics already found in htop.
If available, all sampling is performed by pmcd(1) - else,
we fallback to htop doing the metric sampling itself (all
below the PMAPI). When pmcd is used, it may be configured
to run children with elevated privileges, so htop does not
need to be setuid (authentication with pmcd is available).
Additionally, the PMAPI allows us to support archives (for
historical analysis and for automated regression tests in
htop). We'll need platform-specific command line argument
additions, which isn't yet feasible in htop (not difficult
to add though).
The goal of this first version is minimal impact in terms
of modifying the htop codebase, to introduce key ideas in
PCP (metric namespace, metadata, APIs and so on) and give
us something to discuss, experiment with and build on.
2021-02-17 03:43:56 +00:00
|
|
|
PCPProcessList_backupCPUTime(this->percpu[i]);
|
|
|
|
PCPProcessList_updatePerCPUTime(this, PCP_PERCPU_USER, CPU_USER_TIME);
|
|
|
|
PCPProcessList_updatePerCPUTime(this, PCP_PERCPU_NICE, CPU_NICE_TIME);
|
|
|
|
PCPProcessList_updatePerCPUTime(this, PCP_PERCPU_SYSTEM, CPU_SYSTEM_TIME);
|
|
|
|
PCPProcessList_updatePerCPUTime(this, PCP_PERCPU_IDLE, CPU_IDLE_TIME);
|
|
|
|
PCPProcessList_updatePerCPUTime(this, PCP_PERCPU_IOWAIT, CPU_IOWAIT_TIME);
|
|
|
|
PCPProcessList_updatePerCPUTime(this, PCP_PERCPU_IRQ, CPU_IRQ_TIME);
|
|
|
|
PCPProcessList_updatePerCPUTime(this, PCP_PERCPU_SOFTIRQ, CPU_SOFTIRQ_TIME);
|
|
|
|
PCPProcessList_updatePerCPUTime(this, PCP_PERCPU_STEAL, CPU_STEAL_TIME);
|
|
|
|
PCPProcessList_updatePerCPUTime(this, PCP_PERCPU_GUEST, CPU_GUEST_TIME);
|
2021-06-12 16:17:28 +00:00
|
|
|
for (unsigned int i = 0; i < super->existingCPUs; i++)
|
Add a platform for Performance Co-Pilot (PCP) metrics
This introduces an initial platform for extracting metrics
using the PCP performance metrics API - PMAPI(3). It can
be used via the --enable-pcp=yes configure option.
So far I've added support for live localhost metrics only,
and only using pre-defined metrics already found in htop.
If available, all sampling is performed by pmcd(1) - else,
we fallback to htop doing the metric sampling itself (all
below the PMAPI). When pmcd is used, it may be configured
to run children with elevated privileges, so htop does not
need to be setuid (authentication with pmcd is available).
Additionally, the PMAPI allows us to support archives (for
historical analysis and for automated regression tests in
htop). We'll need platform-specific command line argument
additions, which isn't yet feasible in htop (not difficult
to add though).
The goal of this first version is minimal impact in terms
of modifying the htop codebase, to introduce key ideas in
PCP (metric namespace, metadata, APIs and so on) and give
us something to discuss, experiment with and build on.
2021-02-17 03:43:56 +00:00
|
|
|
PCPProcessList_deriveCPUTime(this->percpu[i]);
|
|
|
|
|
|
|
|
if (settings->showCPUFrequency)
|
|
|
|
PCPProcessList_updatePerCPUReal(this, PCP_HINV_CPUCLOCK, CPU_FREQUENCY);
|
|
|
|
|
2021-07-15 01:22:05 +00:00
|
|
|
PCPProcessList_scanZfsArcstats(this);
|
2021-02-22 05:45:44 +00:00
|
|
|
}
|
|
|
|
|
Add a platform for Performance Co-Pilot (PCP) metrics
This introduces an initial platform for extracting metrics
using the PCP performance metrics API - PMAPI(3). It can
be used via the --enable-pcp=yes configure option.
So far I've added support for live localhost metrics only,
and only using pre-defined metrics already found in htop.
If available, all sampling is performed by pmcd(1) - else,
we fallback to htop doing the metric sampling itself (all
below the PMAPI). When pmcd is used, it may be configured
to run children with elevated privileges, so htop does not
need to be setuid (authentication with pmcd is available).
Additionally, the PMAPI allows us to support archives (for
historical analysis and for automated regression tests in
htop). We'll need platform-specific command line argument
additions, which isn't yet feasible in htop (not difficult
to add though).
The goal of this first version is minimal impact in terms
of modifying the htop codebase, to introduce key ideas in
PCP (metric namespace, metadata, APIs and so on) and give
us something to discuss, experiment with and build on.
2021-02-17 03:43:56 +00:00
|
|
|
void ProcessList_goThroughEntries(ProcessList* super, bool pauseProcessUpdate) {
|
|
|
|
PCPProcessList* this = (PCPProcessList*) super;
|
|
|
|
const Settings* settings = super->settings;
|
|
|
|
bool enabled = !pauseProcessUpdate;
|
|
|
|
|
|
|
|
bool flagged = settings->showCPUFrequency;
|
2021-08-14 21:30:19 +00:00
|
|
|
PCPMetric_enable(PCP_HINV_CPUCLOCK, flagged);
|
Add a platform for Performance Co-Pilot (PCP) metrics
This introduces an initial platform for extracting metrics
using the PCP performance metrics API - PMAPI(3). It can
be used via the --enable-pcp=yes configure option.
So far I've added support for live localhost metrics only,
and only using pre-defined metrics already found in htop.
If available, all sampling is performed by pmcd(1) - else,
we fallback to htop doing the metric sampling itself (all
below the PMAPI). When pmcd is used, it may be configured
to run children with elevated privileges, so htop does not
need to be setuid (authentication with pmcd is available).
Additionally, the PMAPI allows us to support archives (for
historical analysis and for automated regression tests in
htop). We'll need platform-specific command line argument
additions, which isn't yet feasible in htop (not difficult
to add though).
The goal of this first version is minimal impact in terms
of modifying the htop codebase, to introduce key ideas in
PCP (metric namespace, metadata, APIs and so on) and give
us something to discuss, experiment with and build on.
2021-02-17 03:43:56 +00:00
|
|
|
|
|
|
|
/* In pause mode do not sample per-process metric values at all */
|
|
|
|
for (int metric = PCP_PROC_PID; metric < PCP_METRIC_COUNT; metric++)
|
2021-08-14 21:30:19 +00:00
|
|
|
PCPMetric_enable(metric, enabled);
|
Add a platform for Performance Co-Pilot (PCP) metrics
This introduces an initial platform for extracting metrics
using the PCP performance metrics API - PMAPI(3). It can
be used via the --enable-pcp=yes configure option.
So far I've added support for live localhost metrics only,
and only using pre-defined metrics already found in htop.
If available, all sampling is performed by pmcd(1) - else,
we fallback to htop doing the metric sampling itself (all
below the PMAPI). When pmcd is used, it may be configured
to run children with elevated privileges, so htop does not
need to be setuid (authentication with pmcd is available).
Additionally, the PMAPI allows us to support archives (for
historical analysis and for automated regression tests in
htop). We'll need platform-specific command line argument
additions, which isn't yet feasible in htop (not difficult
to add though).
The goal of this first version is minimal impact in terms
of modifying the htop codebase, to introduce key ideas in
PCP (metric namespace, metadata, APIs and so on) and give
us something to discuss, experiment with and build on.
2021-02-17 03:43:56 +00:00
|
|
|
|
|
|
|
flagged = settings->flags & PROCESS_FLAG_LINUX_CGROUP;
|
2021-08-14 21:30:19 +00:00
|
|
|
PCPMetric_enable(PCP_PROC_CGROUPS, flagged && enabled);
|
Add a platform for Performance Co-Pilot (PCP) metrics
This introduces an initial platform for extracting metrics
using the PCP performance metrics API - PMAPI(3). It can
be used via the --enable-pcp=yes configure option.
So far I've added support for live localhost metrics only,
and only using pre-defined metrics already found in htop.
If available, all sampling is performed by pmcd(1) - else,
we fallback to htop doing the metric sampling itself (all
below the PMAPI). When pmcd is used, it may be configured
to run children with elevated privileges, so htop does not
need to be setuid (authentication with pmcd is available).
Additionally, the PMAPI allows us to support archives (for
historical analysis and for automated regression tests in
htop). We'll need platform-specific command line argument
additions, which isn't yet feasible in htop (not difficult
to add though).
The goal of this first version is minimal impact in terms
of modifying the htop codebase, to introduce key ideas in
PCP (metric namespace, metadata, APIs and so on) and give
us something to discuss, experiment with and build on.
2021-02-17 03:43:56 +00:00
|
|
|
flagged = settings->flags & PROCESS_FLAG_LINUX_OOM;
|
2021-08-14 21:30:19 +00:00
|
|
|
PCPMetric_enable(PCP_PROC_OOMSCORE, flagged && enabled);
|
Add a platform for Performance Co-Pilot (PCP) metrics
This introduces an initial platform for extracting metrics
using the PCP performance metrics API - PMAPI(3). It can
be used via the --enable-pcp=yes configure option.
So far I've added support for live localhost metrics only,
and only using pre-defined metrics already found in htop.
If available, all sampling is performed by pmcd(1) - else,
we fallback to htop doing the metric sampling itself (all
below the PMAPI). When pmcd is used, it may be configured
to run children with elevated privileges, so htop does not
need to be setuid (authentication with pmcd is available).
Additionally, the PMAPI allows us to support archives (for
historical analysis and for automated regression tests in
htop). We'll need platform-specific command line argument
additions, which isn't yet feasible in htop (not difficult
to add though).
The goal of this first version is minimal impact in terms
of modifying the htop codebase, to introduce key ideas in
PCP (metric namespace, metadata, APIs and so on) and give
us something to discuss, experiment with and build on.
2021-02-17 03:43:56 +00:00
|
|
|
flagged = settings->flags & PROCESS_FLAG_LINUX_CTXT;
|
2021-08-14 21:30:19 +00:00
|
|
|
PCPMetric_enable(PCP_PROC_VCTXSW, flagged && enabled);
|
|
|
|
PCPMetric_enable(PCP_PROC_NVCTXSW, flagged && enabled);
|
Add a platform for Performance Co-Pilot (PCP) metrics
This introduces an initial platform for extracting metrics
using the PCP performance metrics API - PMAPI(3). It can
be used via the --enable-pcp=yes configure option.
So far I've added support for live localhost metrics only,
and only using pre-defined metrics already found in htop.
If available, all sampling is performed by pmcd(1) - else,
we fallback to htop doing the metric sampling itself (all
below the PMAPI). When pmcd is used, it may be configured
to run children with elevated privileges, so htop does not
need to be setuid (authentication with pmcd is available).
Additionally, the PMAPI allows us to support archives (for
historical analysis and for automated regression tests in
htop). We'll need platform-specific command line argument
additions, which isn't yet feasible in htop (not difficult
to add though).
The goal of this first version is minimal impact in terms
of modifying the htop codebase, to introduce key ideas in
PCP (metric namespace, metadata, APIs and so on) and give
us something to discuss, experiment with and build on.
2021-02-17 03:43:56 +00:00
|
|
|
flagged = settings->flags & PROCESS_FLAG_LINUX_SECATTR;
|
2021-08-14 21:30:19 +00:00
|
|
|
PCPMetric_enable(PCP_PROC_LABELS, flagged && enabled);
|
2021-08-06 06:45:30 +00:00
|
|
|
flagged = settings->flags & PROCESS_FLAG_LINUX_AUTOGROUP;
|
2021-08-14 21:30:19 +00:00
|
|
|
PCPMetric_enable(PCP_PROC_AUTOGROUP_ID, flagged && enabled);
|
|
|
|
PCPMetric_enable(PCP_PROC_AUTOGROUP_NICE, flagged && enabled);
|
Add a platform for Performance Co-Pilot (PCP) metrics
This introduces an initial platform for extracting metrics
using the PCP performance metrics API - PMAPI(3). It can
be used via the --enable-pcp=yes configure option.
So far I've added support for live localhost metrics only,
and only using pre-defined metrics already found in htop.
If available, all sampling is performed by pmcd(1) - else,
we fallback to htop doing the metric sampling itself (all
below the PMAPI). When pmcd is used, it may be configured
to run children with elevated privileges, so htop does not
need to be setuid (authentication with pmcd is available).
Additionally, the PMAPI allows us to support archives (for
historical analysis and for automated regression tests in
htop). We'll need platform-specific command line argument
additions, which isn't yet feasible in htop (not difficult
to add though).
The goal of this first version is minimal impact in terms
of modifying the htop codebase, to introduce key ideas in
PCP (metric namespace, metadata, APIs and so on) and give
us something to discuss, experiment with and build on.
2021-02-17 03:43:56 +00:00
|
|
|
|
|
|
|
/* Sample smaps metrics on every second pass to improve performance */
|
|
|
|
static int smaps_flag;
|
|
|
|
smaps_flag = !!smaps_flag;
|
2021-08-14 21:30:19 +00:00
|
|
|
PCPMetric_enable(PCP_PROC_SMAPS_PSS, smaps_flag && enabled);
|
|
|
|
PCPMetric_enable(PCP_PROC_SMAPS_SWAP, smaps_flag && enabled);
|
|
|
|
PCPMetric_enable(PCP_PROC_SMAPS_SWAPPSS, smaps_flag && enabled);
|
Add a platform for Performance Co-Pilot (PCP) metrics
This introduces an initial platform for extracting metrics
using the PCP performance metrics API - PMAPI(3). It can
be used via the --enable-pcp=yes configure option.
So far I've added support for live localhost metrics only,
and only using pre-defined metrics already found in htop.
If available, all sampling is performed by pmcd(1) - else,
we fallback to htop doing the metric sampling itself (all
below the PMAPI). When pmcd is used, it may be configured
to run children with elevated privileges, so htop does not
need to be setuid (authentication with pmcd is available).
Additionally, the PMAPI allows us to support archives (for
historical analysis and for automated regression tests in
htop). We'll need platform-specific command line argument
additions, which isn't yet feasible in htop (not difficult
to add though).
The goal of this first version is minimal impact in terms
of modifying the htop codebase, to introduce key ideas in
PCP (metric namespace, metadata, APIs and so on) and give
us something to discuss, experiment with and build on.
2021-02-17 03:43:56 +00:00
|
|
|
|
|
|
|
struct timeval timestamp;
|
2021-10-05 02:20:13 +00:00
|
|
|
if (PCPMetric_fetch(×tamp) != true)
|
|
|
|
return;
|
Add a platform for Performance Co-Pilot (PCP) metrics
This introduces an initial platform for extracting metrics
using the PCP performance metrics API - PMAPI(3). It can
be used via the --enable-pcp=yes configure option.
So far I've added support for live localhost metrics only,
and only using pre-defined metrics already found in htop.
If available, all sampling is performed by pmcd(1) - else,
we fallback to htop doing the metric sampling itself (all
below the PMAPI). When pmcd is used, it may be configured
to run children with elevated privileges, so htop does not
need to be setuid (authentication with pmcd is available).
Additionally, the PMAPI allows us to support archives (for
historical analysis and for automated regression tests in
htop). We'll need platform-specific command line argument
additions, which isn't yet feasible in htop (not difficult
to add though).
The goal of this first version is minimal impact in terms
of modifying the htop codebase, to introduce key ideas in
PCP (metric namespace, metadata, APIs and so on) and give
us something to discuss, experiment with and build on.
2021-02-17 03:43:56 +00:00
|
|
|
|
|
|
|
double sample = this->timestamp;
|
|
|
|
this->timestamp = pmtimevalToReal(×tamp);
|
|
|
|
|
|
|
|
PCPProcessList_updateHeader(super, settings);
|
|
|
|
|
|
|
|
/* In pause mode only update global data for meters (CPU, memory, etc) */
|
|
|
|
if (pauseProcessUpdate)
|
|
|
|
return;
|
|
|
|
|
|
|
|
double period = (this->timestamp - sample) * 100;
|
|
|
|
PCPProcessList_updateProcesses(this, period, ×tamp);
|
|
|
|
}
|
2021-06-12 20:04:37 +00:00
|
|
|
|
|
|
|
bool ProcessList_isCPUonline(const ProcessList* super, unsigned int id) {
|
|
|
|
assert(id < super->existingCPUs);
|
2021-08-09 02:42:45 +00:00
|
|
|
(void) super;
|
2021-06-12 20:04:37 +00:00
|
|
|
|
2021-08-09 02:42:45 +00:00
|
|
|
pmAtomValue value;
|
2021-08-14 21:30:19 +00:00
|
|
|
if (PCPMetric_instance(PCP_PERCPU_SYSTEM, id, id, &value, PM_TYPE_U32))
|
2021-08-09 02:42:45 +00:00
|
|
|
return true;
|
|
|
|
return false;
|
2021-06-12 20:04:37 +00:00
|
|
|
}
|