htop/pcp/PCPProcessList.h

75 lines
1.7 KiB
C
Raw Normal View History

#ifndef HEADER_PCPProcessList
#define HEADER_PCPProcessList
/*
htop - PCPProcessList.h
(C) 2014 Hisham H. Muhammad
Released under the GNU GPLv2, see the COPYING file
in the source distribution for its full text.
*/
#include "config.h" // IWYU pragma: keep
#include <stdbool.h>
#include <sys/types.h>
#include "Hashtable.h"
#include "ProcessList.h"
#include "UsersTable.h"
#include "pcp/Platform.h"
#include "zfs/ZfsArcStats.h"
typedef enum CPUMetric_ {
CPU_TOTAL_TIME,
CPU_USER_TIME,
CPU_SYSTEM_TIME,
CPU_SYSTEM_ALL_TIME,
CPU_IDLE_ALL_TIME,
CPU_IDLE_TIME,
CPU_NICE_TIME,
CPU_IOWAIT_TIME,
CPU_IRQ_TIME,
CPU_SOFTIRQ_TIME,
CPU_STEAL_TIME,
CPU_GUEST_TIME,
CPU_GUESTNICE_TIME,
CPU_TOTAL_PERIOD,
CPU_USER_PERIOD,
CPU_SYSTEM_PERIOD,
CPU_SYSTEM_ALL_PERIOD,
CPU_IDLE_ALL_PERIOD,
CPU_IDLE_PERIOD,
CPU_NICE_PERIOD,
CPU_IOWAIT_PERIOD,
CPU_IRQ_PERIOD,
CPU_SOFTIRQ_PERIOD,
CPU_STEAL_PERIOD,
CPU_GUEST_PERIOD,
CPU_GUESTNICE_PERIOD,
CPU_FREQUENCY,
CPU_METRIC_COUNT
} CPUMetric;
typedef struct PCPProcessList_ {
ProcessList super;
double timestamp; /* previous sample timestamp */
pmAtomValue* cpu; /* aggregate values for each metric */
pmAtomValue** percpu; /* per-processor values for each metric */
pmAtomValue* values; /* per-processor buffer for just one metric */
ZfsArcStats zfs;
} PCPProcessList;
Add a new DynamicMeter class for runtime Meter extension This commit is based on exploratory work by Sohaib Mohamed. The end goal is two-fold - to support addition of Meters we build via configuration files for both the PCP platform and for scripts ( https://github.com/htop-dev/htop/issues/526 ) Here, we focus on generic code and the PCP support. A new class DynamicMeter is introduced - it uses the special case 'param' field handling that previously was used only by the CPUMeter, such that every runtime-configured Meter is given a unique identifier. Unlike with the CPUMeter this is used internally only. When reading/writing to htoprc instead of CPU(N) - where N is an integer param (CPU number) - we use the string name for each meter. For example, if we have a configuration for a DynamicMeter for some Redis metrics, we might read and write "Dynamic(redis)". This identifier is subsequently matched (back) up to the configuration file so we're able to re-create arbitrary user configurations. The PCP platform configuration file format is fairly simple. We expand configs from several directories, including the users homedir alongside htoprc (below htop/meters/) and also /etc/pcp/htop/meters. The format will be described via a new pcp-htop(5) man page, but its basically ini-style and each Meter has one or more metric expressions associated, as well as specifications for labels, color and so on via a dot separated notation for individual metrics within the Meter. A few initial sample configuration files are provided below ./pcp/meters that give the general idea. The PCP "derived" metric specification - see pmRegisterDerived(3) - is used as the syntax for specifying metrics in PCP DynamicMeters.
2021-06-23 07:44:56 +00:00
ProcessList* ProcessList_new(UsersTable* usersTable, Hashtable* dynamicMeters, Hashtable* pidMatchList, uid_t userId);
void ProcessList_delete(ProcessList* pl);
void ProcessList_goThroughEntries(ProcessList* super, bool pauseProcessUpdate);
2021-06-12 20:04:37 +00:00
bool ProcessList_isCPUonline(const ProcessList* super, unsigned int id);
#endif