2006-03-04 18:16:49 +00:00
|
|
|
#ifndef HEADER_Settings
|
|
|
|
#define HEADER_Settings
|
|
|
|
/*
|
2006-06-06 20:28:42 +00:00
|
|
|
htop - Settings.h
|
2011-05-26 16:35:07 +00:00
|
|
|
(C) 2004-2011 Hisham H. Muhammad
|
2021-09-22 09:33:00 +00:00
|
|
|
Released under the GNU GPLv2+, see the COPYING file
|
2006-03-04 18:16:49 +00:00
|
|
|
in the source distribution for its full text.
|
|
|
|
*/
|
|
|
|
|
2020-09-19 11:55:23 +00:00
|
|
|
#include "config.h" // IWYU pragma: keep
|
2006-04-10 20:40:38 +00:00
|
|
|
|
2011-12-26 21:35:57 +00:00
|
|
|
#include <stdbool.h>
|
2020-12-06 14:22:41 +00:00
|
|
|
#include <stdint.h>
|
2006-03-04 18:16:49 +00:00
|
|
|
|
PCP: support for 'dynamic columns' added at runtime
Implements support for arbitrary Performance Co-Pilot
metrics with per-process instance domains to form new
htop columns. The column-to-metric mappings are setup
using configuration files which will be documented via
man pages as part of a follow-up commit.
We provide an initial set of column configurations so
as to provide new capabilities to pcp-htop: including
configs for containers, open fd counts, scheduler run
queue time, tcp/udp bytes/calls sent/recv, delay acct,
virtual machine guests, detailed virtual memory, swap.
Note there is a change to the configuration file path
resolution algorithm introduced for 'dynamic meters'.
First, look in any custom PCP_HTOP_DIR location. Then
iterate, in priority order, users home directory, then
local sysadmins files in /etc/pcp/htop, then readonly
configuration files below /usr/share/pcp/htop. This
final location becomes the preferred place for our own
shipped meter and column files.
The Settings file (htoprc) writing code is updated to
not using the numeric identifier for dynamic columns.
The same strategy used for dynamic meters is used here
where we write Dynamic(name) so the name can be setup
once more at start. Regular (static) columns writing
to htoprc - i.e. numerically indexed - is unchanged.
2021-07-11 01:11:29 +00:00
|
|
|
#include "Hashtable.h"
|
2020-12-25 15:42:35 +00:00
|
|
|
#include "HeaderLayout.h"
|
2020-09-18 17:23:04 +00:00
|
|
|
#include "Process.h"
|
|
|
|
|
2020-09-19 11:55:23 +00:00
|
|
|
|
|
|
|
#define DEFAULT_DELAY 15
|
|
|
|
|
2021-08-31 05:38:52 +00:00
|
|
|
#define CONFIG_READER_MIN_VERSION 3
|
|
|
|
|
|
|
|
typedef struct {
|
|
|
|
const char* name;
|
|
|
|
const char* columns;
|
|
|
|
const char* sortKey;
|
|
|
|
} ScreenDefaults;
|
2021-07-16 15:04:23 +00:00
|
|
|
|
2015-01-22 01:27:31 +00:00
|
|
|
typedef struct {
|
2021-09-04 12:15:47 +00:00
|
|
|
size_t len;
|
2015-01-22 01:27:31 +00:00
|
|
|
char** names;
|
|
|
|
int* modes;
|
2020-12-25 15:42:35 +00:00
|
|
|
} MeterColumnSetting;
|
2015-01-23 05:08:21 +00:00
|
|
|
|
2021-08-31 05:38:52 +00:00
|
|
|
typedef struct {
|
|
|
|
char* name;
|
|
|
|
ProcessField* fields;
|
|
|
|
uint32_t flags;
|
|
|
|
int direction;
|
|
|
|
int treeDirection;
|
|
|
|
ProcessField sortKey;
|
|
|
|
ProcessField treeSortKey;
|
|
|
|
bool treeView;
|
|
|
|
bool treeViewAlwaysByPID;
|
|
|
|
bool allBranchesCollapsed;
|
|
|
|
} ScreenSettings;
|
|
|
|
|
2006-03-04 18:16:49 +00:00
|
|
|
typedef struct Settings_ {
|
2015-01-22 01:27:31 +00:00
|
|
|
char* filename;
|
2021-07-16 15:04:23 +00:00
|
|
|
int config_version;
|
2020-12-25 15:42:35 +00:00
|
|
|
HeaderLayout hLayout;
|
|
|
|
MeterColumnSetting* hColumns;
|
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
|
|
|
Hashtable* dynamicColumns;
|
2015-01-22 01:27:31 +00:00
|
|
|
|
2021-08-31 05:38:52 +00:00
|
|
|
ScreenSettings** screens;
|
|
|
|
unsigned int nScreens;
|
|
|
|
unsigned int ssIndex;
|
|
|
|
ScreenSettings* ss;
|
|
|
|
|
2006-03-04 18:16:49 +00:00
|
|
|
int colorScheme;
|
2006-04-10 20:40:38 +00:00
|
|
|
int delay;
|
2015-01-22 01:27:31 +00:00
|
|
|
|
2019-12-19 22:30:45 +00:00
|
|
|
bool countCPUsFromOne;
|
2015-01-22 01:27:31 +00:00
|
|
|
bool detailedCPUTime;
|
2019-08-10 18:20:21 +00:00
|
|
|
bool showCPUUsage;
|
2019-08-10 04:34:48 +00:00
|
|
|
bool showCPUFrequency;
|
2020-12-22 19:02:01 +00:00
|
|
|
#ifdef BUILD_WITH_CPU_TEMP
|
2020-09-10 17:56:33 +00:00
|
|
|
bool showCPUTemperature;
|
|
|
|
bool degreeFahrenheit;
|
|
|
|
#endif
|
2015-07-29 19:14:29 +00:00
|
|
|
bool showProgramPath;
|
2015-01-22 01:27:31 +00:00
|
|
|
bool shadowOtherUsers;
|
|
|
|
bool showThreadNames;
|
|
|
|
bool hideKernelThreads;
|
|
|
|
bool hideUserlandThreads;
|
|
|
|
bool highlightBaseName;
|
2020-12-19 15:46:00 +00:00
|
|
|
bool highlightDeletedExe;
|
2015-01-22 01:27:31 +00:00
|
|
|
bool highlightMegabytes;
|
|
|
|
bool highlightThreads;
|
2020-10-31 01:56:16 +00:00
|
|
|
bool highlightChanges;
|
|
|
|
int highlightDelaySecs;
|
2020-10-17 10:54:45 +00:00
|
|
|
bool findCommInCmdline;
|
|
|
|
bool stripExeFromCmdline;
|
|
|
|
bool showMergedCommand;
|
2015-01-22 01:27:31 +00:00
|
|
|
bool updateProcessNames;
|
|
|
|
bool accountGuestInCPUMeter;
|
|
|
|
bool headerMargin;
|
2021-08-31 05:38:52 +00:00
|
|
|
bool screenTabs;
|
2021-07-14 19:07:43 +00:00
|
|
|
#ifdef HAVE_GETMOUSE
|
2019-07-12 19:41:09 +00:00
|
|
|
bool enableMouse;
|
2021-07-14 19:07:43 +00:00
|
|
|
#endif
|
2020-12-28 22:26:14 +00:00
|
|
|
int hideFunctionBar; // 0 - off, 1 - on ESC until next input, 2 - permanently
|
2020-08-26 00:15:00 +00:00
|
|
|
#ifdef HAVE_LIBHWLOC
|
|
|
|
bool topologyAffinity;
|
|
|
|
#endif
|
2015-01-22 01:27:31 +00:00
|
|
|
|
2014-02-27 19:35:22 +00:00
|
|
|
bool changed;
|
2022-05-29 21:03:56 +00:00
|
|
|
uint64_t lastUpdate;
|
2006-03-04 18:16:49 +00:00
|
|
|
} Settings;
|
|
|
|
|
2019-12-19 22:30:45 +00:00
|
|
|
#define Settings_cpuId(settings, cpu) ((settings)->countCPUsFromOne ? (cpu)+1 : (cpu))
|
2006-03-04 18:16:49 +00:00
|
|
|
|
2021-08-31 05:38:52 +00:00
|
|
|
static inline ProcessField ScreenSettings_getActiveSortKey(const ScreenSettings* this) {
|
2020-12-18 14:03:31 +00:00
|
|
|
return (this->treeView)
|
|
|
|
? (this->treeViewAlwaysByPID ? PID : this->treeSortKey)
|
|
|
|
: this->sortKey;
|
|
|
|
}
|
|
|
|
|
2021-08-31 05:38:52 +00:00
|
|
|
static inline int ScreenSettings_getActiveDirection(const ScreenSettings* this) {
|
2020-12-18 14:03:31 +00:00
|
|
|
return this->treeView ? this->treeDirection : this->direction;
|
|
|
|
}
|
|
|
|
|
2020-09-02 07:38:44 +00:00
|
|
|
void Settings_delete(Settings* this);
|
2006-03-04 18:16:49 +00:00
|
|
|
|
2021-05-16 17:55:31 +00:00
|
|
|
int Settings_write(const Settings* this, bool onCrash);
|
2006-03-04 18:16:49 +00:00
|
|
|
|
PCP: support for 'dynamic columns' added at runtime
Implements support for arbitrary Performance Co-Pilot
metrics with per-process instance domains to form new
htop columns. The column-to-metric mappings are setup
using configuration files which will be documented via
man pages as part of a follow-up commit.
We provide an initial set of column configurations so
as to provide new capabilities to pcp-htop: including
configs for containers, open fd counts, scheduler run
queue time, tcp/udp bytes/calls sent/recv, delay acct,
virtual machine guests, detailed virtual memory, swap.
Note there is a change to the configuration file path
resolution algorithm introduced for 'dynamic meters'.
First, look in any custom PCP_HTOP_DIR location. Then
iterate, in priority order, users home directory, then
local sysadmins files in /etc/pcp/htop, then readonly
configuration files below /usr/share/pcp/htop. This
final location becomes the preferred place for our own
shipped meter and column files.
The Settings file (htoprc) writing code is updated to
not using the numeric identifier for dynamic columns.
The same strategy used for dynamic meters is used here
where we write Dynamic(name) so the name can be setup
once more at start. Regular (static) columns writing
to htoprc - i.e. numerically indexed - is unchanged.
2021-07-11 01:11:29 +00:00
|
|
|
Settings* Settings_new(unsigned int initialCpuCount, Hashtable* dynamicColumns);
|
2015-01-22 01:27:31 +00:00
|
|
|
|
2021-12-16 15:09:32 +00:00
|
|
|
ScreenSettings* Settings_newScreen(Settings* this, const ScreenDefaults* defaults);
|
2021-08-31 05:38:52 +00:00
|
|
|
|
2021-12-08 13:20:54 +00:00
|
|
|
void ScreenSettings_delete(ScreenSettings* this);
|
|
|
|
|
2021-08-31 05:38:52 +00:00
|
|
|
void ScreenSettings_invertSortOrder(ScreenSettings* this);
|
2008-03-09 08:58:38 +00:00
|
|
|
|
2021-08-31 05:38:52 +00:00
|
|
|
void ScreenSettings_setSortKey(ScreenSettings* this, ProcessField sortKey);
|
2020-12-18 14:03:31 +00:00
|
|
|
|
2021-01-21 19:27:37 +00:00
|
|
|
void Settings_enableReadonly(void);
|
|
|
|
|
|
|
|
bool Settings_isReadonly(void);
|
|
|
|
|
2020-12-25 15:42:35 +00:00
|
|
|
void Settings_setHeaderLayout(Settings* this, HeaderLayout hLayout);
|
|
|
|
|
2006-03-04 18:16:49 +00:00
|
|
|
#endif
|