Skip to content

Commit f65ef79

Browse files
committed
Correctly handling PCP metric units and column widths.
Adds support for new 'format' keyword, updates to screens config files, and some minor cleanup here & there.
1 parent 1e585f3 commit f65ef79

26 files changed

+456
-358
lines changed

AvailableColumnsPanel.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -85,7 +85,7 @@ const PanelClass AvailableColumnsPanel_class = {
8585

8686
static void AvailableColumnsPanel_addDynamicColumn(ht_key_t key, void* value, void* data) {
8787
const DynamicColumn* column = (const DynamicColumn*) value;
88-
if (column->belongToDynamicScreen)
88+
if (column->hasDynamicScreen)
8989
return;
9090

9191
Panel* super = (Panel*) data;

CommandLine.c

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -331,9 +331,11 @@ int CommandLine_run(const char* name, int argc, char** argv) {
331331

332332
ProcessList* pl = ProcessList_new(ut, dm, dc, flags.pidMatchList, flags.userId);
333333
Settings* settings = Settings_new(pl->activeCPUs, dc);
334-
334+
fprintf(stderr, "Settings created\n");
335335
Hashtable* dt = DynamicScreens_new(settings);
336+
fprintf(stderr, "DynamicScreens created\n");
336337
GenericDataList* gl = GenericDataList_new();
338+
fprintf(stderr, "GenericDataList created\n");
337339

338340
pl->settings = settings;
339341
if (gl)

DynamicColumn.h

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -8,17 +8,17 @@
88
#include "RichString.h"
99

1010

11-
#define DYNAMIC_MAX_COLUMN_WIDTH 28
11+
#define DYNAMIC_MAX_COLUMN_WIDTH 64
1212
#define DYNAMIC_DEFAULT_COLUMN_WIDTH -5
1313

1414
typedef struct DynamicColumn_ {
15-
char name[32]; /* unique, internal-only name */
16-
char* heading; /* displayed in main screen */
17-
char* caption; /* displayed in setup menu (short name) */
18-
char* description; /* displayed in setup menu (detail) */
19-
int width; /* display width +/- for value alignment */
20-
bool belongToDynamicScreen; /* belong to DynamicScreen or ProcessList screen? */
21-
bool enabled; /* false == ignore this column */
15+
char name[32]; /* unique, internal-only name */
16+
char* heading; /* displayed in main screen */
17+
char* caption; /* displayed in setup menu (short name) */
18+
char* description; /* displayed in setup menu (detail) */
19+
int width; /* display width +/- for value alignment */
20+
bool hasDynamicScreen; /* from a DynamicScreen or ProcessList screen? */
21+
bool enabled; /* false == ignore this column */
2222
} DynamicColumn;
2323

2424
Hashtable* DynamicColumns_new(void);

GenericDataList.h

Lines changed: 1 addition & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -55,24 +55,16 @@ void GenericDataList_delete(GenericDataList* gl);
5555
/* One GenericData List */
5656
void GenericDataList_addList(void);
5757

58-
//void GenericDataList_removeList(GenericDataList* g);
59-
6058
/* struct GenericData */
6159
GenericData* GenericDataList_getGenericData(GenericDataList* this, GenericData_New constructor);
6260

6361
void GenericDataList_addGenericData(GenericDataList* this, GenericData* g);
6462

6563
void GenericDataList_removeGenericData(GenericDataList* this);
6664

67-
/* helpers functions */
65+
/* helper functions */
6866
void GenericDataList_setPanel(GenericDataList* this, Panel* panel);
6967

70-
void GenericDataList_printHeader(const GenericDataList* this, RichString* header); // TODO
71-
72-
void GenericDataList_expandTree(GenericDataList* this); // TODO
73-
74-
void GenericDataList_collapseAllBranches(GenericDataList* this); // TODO
75-
7668
void GenericDataList_rebuildPanel(GenericDataList* this);
7769

7870
void GenericDataList_scan(GenericDataList* this, bool pauseUpdate);

Makefile.am

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -381,6 +381,7 @@ endif
381381
# --------------------------
382382

383383
pcp_platform_headers = \
384+
linux/CGroupUtils.h \
384385
linux/PressureStallMeter.h \
385386
linux/ZramMeter.h \
386387
linux/ZramStats.h \
@@ -399,6 +400,7 @@ pcp_platform_headers = \
399400
zfs/ZfsCompressedArcMeter.h
400401

401402
pcp_platform_sources = \
403+
linux/CGroupUtils.c \
402404
linux/PressureStallMeter.c \
403405
linux/ZramMeter.c \
404406
pcp/PCPDynamicColumn.c \

ProcessList.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -86,7 +86,7 @@ static const char* alignedDynamicColumnTitle(const ProcessList* this, int key, c
8686
const DynamicColumn* column = Hashtable_get(this->dynamicColumns, key);
8787
if (column == NULL)
8888
return "- ";
89-
if (!column->enabled)
89+
if (column->enabled == false)
9090
return "";
9191
int width = column->width;
9292
if (!width || abs(width) > DYNAMIC_MAX_COLUMN_WIDTH)

ScreenManager.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -140,7 +140,7 @@ static void checkRecalculation(ScreenManager* this, double* oldTime, int* sortTi
140140
// scan processes first - some header values are calculated there
141141
ProcessList_scan(pl, this->state->pauseUpdate);
142142

143-
if (this->settings->ss->generic)
143+
if (this->settings->ss->dynamic)
144144
GenericDataList_scan(gl, this->state->pauseUpdate);
145145

146146
// always update header, especially to avoid gaps in graph meters
@@ -152,7 +152,7 @@ static void checkRecalculation(ScreenManager* this, double* oldTime, int* sortTi
152152
*redraw = true;
153153
}
154154
if (*redraw) {
155-
if (this->settings->ss->generic) {
155+
if (this->settings->ss->dynamic) {
156156
*force_redraw = true;
157157
Vector_prune(pl->panel->items);
158158

ScreensPanel.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -275,7 +275,7 @@ static HandlerResult ScreensPanel_eventHandlerNormal(Panel* super, int ch) {
275275
ScreenListItem* newFocus = (ScreenListItem*) Panel_getSelected(super);
276276
if (newFocus && oldFocus != newFocus) {
277277
ColumnsPanel_fill(this->columns, newFocus->ss, this->settings->dynamicColumns);
278-
if (newFocus->ss->generic) {
278+
if (newFocus->ss->dynamic) {
279279
char* currentScreen = newFocus->ss->name;
280280
DynamicScreen_availableColumns(currentScreen);
281281
} else {

Settings.c

Lines changed: 17 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -285,7 +285,7 @@ ScreenSettings* Settings_newScreen(Settings* this, const ScreenDefaults* default
285285
.treeView = false,
286286
.treeViewAlwaysByPID = false,
287287
.allBranchesCollapsed = false,
288-
.generic = false,
288+
.dynamic = false,
289289
};
290290

291291
ScreenSettings_readFields(ss, this->dynamicColumns, defaults->columns);
@@ -369,9 +369,9 @@ static bool Settings_read(Settings* this, const char* fileName, unsigned int ini
369369
} else if (String_eq(option[0], "tree_view") && this->config_version <= 2) {
370370
screen = Settings_defaultScreens(this);
371371
screen->treeView = atoi(option[1]);
372-
} else if (String_eq(option[0], "generic_screen") && this->config_version <= 2) {
372+
} else if (String_eq(option[0], "dynamic_screen") && this->config_version <= 2) {
373373
screen = Settings_defaultScreens(this);
374-
screen->generic = atoi(option[1]);
374+
screen->dynamic = atoi(option[1]);
375375
} else if (String_eq(option[0], "tree_view_always_by_pid") && this->config_version <= 2) {
376376
// old (no screen) naming also supported for backwards compatibility
377377
screen = Settings_defaultScreens(this);
@@ -502,9 +502,9 @@ static bool Settings_read(Settings* this, const char* fileName, unsigned int ini
502502
} else if (String_eq(option[0], ".tree_view")) {
503503
if (screen)
504504
screen->treeView = atoi(option[1]);
505-
} else if (String_eq(option[0], ".generic_screen")) {
505+
} else if (String_eq(option[0], ".dynamic_screen")) {
506506
if (screen)
507-
screen->generic = atoi(option[1]);
507+
screen->dynamic = atoi(option[1]);
508508
} else if (String_eq(option[0], ".tree_view_always_by_pid")) {
509509
if (screen)
510510
screen->treeViewAlwaysByPID = atoi(option[1]);
@@ -530,7 +530,7 @@ static void writeFields(FILE* fd, const ProcessField* fields, Hashtable* columns
530530
fprintf(fd, "%s%s", sep, pName);
531531
} else if (fields[i] >= LAST_PROCESSFIELD && byName) {
532532
const char* pName = toFieldName(columns, fields[i]);
533-
fprintf(fd, " Dynamic(%s)", pName);
533+
fprintf(fd, "%sDynamic(%s)", sep, pName);
534534
} else {
535535
// This "-1" is for compatibility with the older enum format.
536536
fprintf(fd, "%s%d", sep, (int) fields[i] - 1);
@@ -643,20 +643,21 @@ int Settings_write(const Settings* this, bool onCrash) {
643643
printSettingInteger("tree_view_always_by_pid", this->screens[0]->treeViewAlwaysByPID);
644644
printSettingInteger("all_branches_collapsed", this->screens[0]->allBranchesCollapsed);
645645

646+
fprintf(stderr, "writing %d screens\n", (int)this->nScreens);
646647
for (unsigned int i = 0; i < this->nScreens; i++) {
647-
if (this->screens[i]->generic)
648-
continue;
649648
ScreenSettings* ss = this->screens[i];
650649
fprintf(fd, "screen:%s=", ss->name);
651650
writeFields(fd, ss->fields, this->dynamicColumns, true, separator);
652-
printSettingString(".sort_key", toFieldName(this->dynamicColumns, ss->sortKey));
653-
printSettingString(".tree_sort_key", toFieldName(this->dynamicColumns, ss->treeSortKey));
654-
printSettingInteger(".tree_view", ss->treeView);
655-
printSettingInteger(".tree_view_always_by_pid", ss->treeViewAlwaysByPID);
656-
printSettingInteger(".sort_direction", ss->direction);
657-
printSettingInteger(".tree_sort_direction", ss->treeDirection);
658-
printSettingInteger(".all_branches_collapsed", ss->allBranchesCollapsed);
659-
printSettingInteger(".generic_screen", ss->generic);
651+
if (ss->dynamic == false) {
652+
printSettingString(".sort_key", toFieldName(this->dynamicColumns, ss->sortKey));
653+
printSettingString(".tree_sort_key", toFieldName(this->dynamicColumns, ss->treeSortKey));
654+
printSettingInteger(".tree_view", ss->treeView);
655+
printSettingInteger(".tree_view_always_by_pid", ss->treeViewAlwaysByPID);
656+
printSettingInteger(".sort_direction", ss->direction);
657+
printSettingInteger(".tree_sort_direction", ss->treeDirection);
658+
printSettingInteger(".all_branches_collapsed", ss->allBranchesCollapsed);
659+
}
660+
printSettingInteger(".dynamic_screen", ss->dynamic);
660661
}
661662

662663
#undef printSettingString

Settings.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ typedef struct {
4444
bool treeView;
4545
bool treeViewAlwaysByPID;
4646
bool allBranchesCollapsed;
47-
bool generic;
47+
bool dynamic;
4848
} ScreenSettings;
4949

5050
typedef struct Settings_ {

0 commit comments

Comments
 (0)