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.
This commit is contained in:
Sohaib Mohamed
2021-07-11 03:11:29 +02:00
committed by Nathan Scott
parent ed82ce6456
commit 6f2021f3d9
59 changed files with 1065 additions and 176 deletions

View File

@ -11,6 +11,8 @@ in the source distribution for its full text.
#include <ctype.h>
#include <stdbool.h>
#include <stddef.h>
#include <stdint.h>
#include <pcp/pmapi.h>
/* use htop config.h values for these macros, not pcp values */
@ -29,6 +31,7 @@ in the source distribution for its full text.
#include "NetworkIOMeter.h"
#include "Process.h"
#include "ProcessLocksScreen.h"
#include "RichString.h"
#include "SignalsPanel.h"
#include "SysArchMeter.h"
@ -250,13 +253,15 @@ pmAtomValue* Metric_values(Metric metric, pmAtomValue* atom, int count, int type
const pmDesc* Metric_desc(Metric metric);
int Metric_type(Metric metric);
int Metric_instanceCount(Metric metric);
int Metric_instanceOffset(Metric metric, int inst);
pmAtomValue* Metric_instance(Metric metric, int inst, int offset, pmAtomValue* atom, int type);
int Platform_addMetric(Metric id, const char* name);
size_t Platform_addMetric(Metric id, const char* name);
void Platform_gettime_realtime(struct timeval* tv, uint64_t* msec);
@ -270,4 +275,10 @@ void Platform_dynamicMeterUpdateValues(Meter* meter);
void Platform_dynamicMeterDisplay(const Meter* meter, RichString* out);
Hashtable* Platform_dynamicColumns(void);
const char* Platform_dynamicColumnInit(unsigned int key);
bool Platform_dynamicColumnWriteField(const Process* proc, RichString* str, unsigned int key);
#endif