Skip to content

Commit

Permalink
pcp-htop: support for dynamic screen (user-configurable tabs)
Browse files Browse the repository at this point in the history
This implements the concept of 'dynamic screens' in htop, with a
first use-case of pcp-htop displaying things like top-filesystem
and top-cgroups under new screen tabs.

From the pcp-htop side of things, dynamic screens are configured
using text-based configuration files that define the mapping for
PCP metrics to columns (and metric instances to rows).  Metrics
are defined either directly (via metric names) or indirectly via
PCP derived metric specifications.  Value scaling and the units
displayed is automatic based on PCP metric units and data types.

This commit represents a collaborative effort of several months,
primarily between Sohaib, BenBE and myself.
  • Loading branch information
natoscott committed Aug 30, 2023
1 parent 7eb3cd0 commit 9a5da8a
Show file tree
Hide file tree
Showing 5 changed files with 67 additions and 11 deletions.
27 changes: 23 additions & 4 deletions configure
Original file line number Diff line number Diff line change
Expand Up @@ -5289,11 +5289,11 @@ if test x$ac_prog_cxx_stdcxx = xno
then :
{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking for $CXX option to enable C++11 features" >&5
printf %s "checking for $CXX option to enable C++11 features... " >&6; }
if test ${ac_cv_prog_cxx_11+y}
if test ${ac_cv_prog_cxx_cxx11+y}
then :
printf %s "(cached) " >&6
else $as_nop
ac_cv_prog_cxx_11=no
ac_cv_prog_cxx_cxx11=no
ac_save_CXX=$CXX
cat confdefs.h - <<_ACEOF >conftest.$ac_ext
/* end confdefs.h. */
Expand Down Expand Up @@ -5335,11 +5335,11 @@ if test x$ac_prog_cxx_stdcxx = xno
then :
{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking for $CXX option to enable C++98 features" >&5
printf %s "checking for $CXX option to enable C++98 features... " >&6; }
if test ${ac_cv_prog_cxx_98+y}
if test ${ac_cv_prog_cxx_cxx98+y}
then :
printf %s "(cached) " >&6
else $as_nop
ac_cv_prog_cxx_98=no
ac_cv_prog_cxx_cxx98=no
ac_save_CXX=$CXX
cat confdefs.h - <<_ACEOF >conftest.$ac_ext
/* end confdefs.h. */
Expand Down Expand Up @@ -11560,6 +11560,25 @@ if test "x$ac_cv_header_ncursesw_curses_h" = xyes
then :
printf "%s\n" "#define HAVE_NCURSESW_CURSES_H 1" >>confdefs.h

fi
ac_fn_c_check_header_compile "$LINENO" "ncursesw/term.h" "ac_cv_header_ncursesw_term_h" "$ac_includes_default"
if test "x$ac_cv_header_ncursesw_term_h" = xyes
then :
printf "%s\n" "#define HAVE_NCURSESW_TERM_H 1" >>confdefs.h

fi

ac_fn_c_check_header_compile "$LINENO" "ncurses/term.h" "ac_cv_header_ncurses_term_h" "$ac_includes_default"
if test "x$ac_cv_header_ncurses_term_h" = xyes
then :
printf "%s\n" "#define HAVE_NCURSES_TERM_H 1" >>confdefs.h

fi
ac_fn_c_check_header_compile "$LINENO" "term.h" "ac_cv_header_term_h" "$ac_includes_default"
if test "x$ac_cv_header_term_h" = xyes
then :
printf "%s\n" "#define HAVE_TERM_H 1" >>confdefs.h

fi

ac_fn_c_check_header_compile "$LINENO" "linux/perf_event.h" "ac_cv_header_linux_perf_event_h" "$ac_includes_default"
Expand Down
3 changes: 2 additions & 1 deletion configure.ac
Original file line number Diff line number Diff line change
Expand Up @@ -1865,7 +1865,8 @@ AC_CHECK_HEADERS(fts.h libzfs.h)
AC_CHECK_HEADERS(sys/statvfs.h sys/statfs.h sys/mount.h)
AC_CHECK_HEADERS(curses.h ncurses.h)
AC_CHECK_HEADERS(ncurses/curses.h ncurses/ncurses.h)
AC_CHECK_HEADERS(ncursesw/curses.h)
AC_CHECK_HEADERS(ncursesw/curses.h ncursesw/term.h)
AC_CHECK_HEADERS(ncurses/term.h term.h)
AC_CHECK_HEADERS(linux/perf_event.h)

dnl Check if we have <sys/endian.h> ... standard way
Expand Down
9 changes: 9 additions & 0 deletions src/include/pcp/config.h.in
Original file line number Diff line number Diff line change
Expand Up @@ -289,6 +289,15 @@
/* Define to 1 if you have the <ncursesw/curses.h> header file. */
#undef HAVE_NCURSESW_CURSES_H

/* Define to 1 if you have the <ncursesw/term.h> header file. */
#undef HAVE_NCURSESW_TERM_H

/* Define to 1 if you have the <ncurses/term.h> header file. */
#undef HAVE_NCURSES_TERM_H

/* Define to 1 if you have the <term.h> header file. */
#undef HAVE_TERM_H

/* Define to 1 if you have the <ndir.h> header file, and it defines `DIR'. */
#undef HAVE_NDIR_H

Expand Down
1 change: 1 addition & 0 deletions src/pcp/htop/.gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ pcp-htop.5
pcp-htop.5.*
pcp/columns
pcp/meters
pcp/screens
AUTHORS
*.h
*.c
38 changes: 32 additions & 6 deletions src/pcp/htop/GNUmakefile
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
#
# Copyright (c) 2020-2021 Red Hat.
# Copyright (c) 2020-2023 Red Hat.
#
# This program is free software; you can redistribute it and/or modify it
# under the terms of the GNU General Public License as published by the
Expand All @@ -15,7 +15,7 @@
TOPDIR = ../../..
include $(TOPDIR)/src/include/builddefs

COPYRIGHT = "(C) 2004-2019 Hisham Muhammad. (C) 2020-2021 htop dev team."
COPYRIGHT = "(C) 2004-2019 Hisham Muhammad. (C) 2020-2023 htop dev team."

CMDTARGET = pcp-htop
DISTARGET = $(PCP_BINADM_DIR)/$(CMDTARGET)
Expand Down Expand Up @@ -47,6 +47,7 @@ TOPCFILES = \
DisplayOptionsPanel.c \
DynamicColumn.c \
DynamicMeter.c \
DynamicScreen.c \
EnvScreen.c \
FileDescriptorMeter.c \
FunctionBar.c \
Expand All @@ -73,13 +74,16 @@ TOPCFILES = \
ProcessList.c \
ProcessLocksScreen.c \
RichString.c \
Row.c \
Scheduling.c \
ScreenManager.c \
ScreensPanel.c \
ScreenTabsPanel.c \
Settings.c \
SignalsPanel.c \
SwapMeter.c \
SysArchMeter.c \
Table.c \
TasksMeter.c \
TraceScreen.c \
UptimeMeter.c \
Expand All @@ -88,14 +92,18 @@ TOPCFILES = \
XUtils.c \

SUBCFILES = \
linux/CGroupUtils.c \
linux/PressureStallMeter.c \
linux/ZramMeter.c \
zfs/ZfsArcMeter.c \
zfs/ZfsCompressedArcMeter.c \
pcp/InDomTable.c \
pcp/Instance.c \
pcp/Metric.c \
pcp/PCPDynamicColumn.c \
pcp/PCPDynamicMeter.c \
pcp/PCPDynamicScreen.c \
pcp/PCPMachine.c \
pcp/PCPMetric.c \
pcp/PCPProcess.c \
pcp/PCPProcessList.c \
pcp/Platform.c \
Expand All @@ -120,6 +128,7 @@ TOPHFILES = \
DisplayOptionsPanel.h \
DynamicColumn.h \
DynamicMeter.h \
DynamicScreen.h \
EnvScreen.h \
FileDescriptorMeter.h \
FunctionBar.h \
Expand Down Expand Up @@ -148,14 +157,19 @@ TOPHFILES = \
ProcessList.h \
ProcessLocksScreen.h \
ProvideCurses.h \
ProvideTerm.h \
RichString.h \
Row.h \
RowField.h \
Scheduling.h \
ScreenManager.h \
ScreensPanel.h \
ScreenTabsPanel.h \
Settings.h \
SignalsPanel.h \
SwapMeter.h \
SysArchMeter.h \
Table.h \
TasksMeter.h \
TraceScreen.h \
UptimeMeter.h \
Expand All @@ -164,16 +178,20 @@ TOPHFILES = \
XUtils.h \

SUBHFILES = \
linux/CGroupUtils.h \
linux/PressureStallMeter.h \
linux/ZramMeter.h \
linux/ZramStats.h \
zfs/ZfsArcMeter.h \
zfs/ZfsArcStats.h \
zfs/ZfsCompressedArcMeter.h \
pcp/InDomTable.h \
pcp/Instance.h \
pcp/Metric.h \
pcp/PCPDynamicColumn.h \
pcp/PCPDynamicMeter.h \
pcp/PCPDynamicScreen.h \
pcp/PCPMachine.h \
pcp/PCPMetric.h \
pcp/PCPProcess.h \
pcp/PCPProcessList.h \
pcp/Platform.h \
Expand All @@ -182,10 +200,13 @@ SUBHFILES = \
DOCFILES = AUTHORS pcp-htop.5.in
COLUMNS = container delayacct fdcount guest memory sched swap tcp udp wchan
METERS = entropy freespace ipc locks memcache mysql postfix redis tcp
SCREENS = cgroups cgroupsio cgroupsmem devices filesystems \
biosnoop execsnoop exitsnoop opensnoop
CFGMETERS = $(patsubst %,pcp/meters/%,$(METERS))
CFGCOLUMNS = $(patsubst %,pcp/columns/%,$(COLUMNS))
CFGSCREENS = $(patsubst %,pcp/screens/%,$(SCREENS))

CFGXFILES = $(CFGMETERS) $(CFGCOLUMNS)
CFGXFILES = $(CFGMETERS) $(CFGCOLUMNS) $(CFGSCREENS)
TOPXFILES = $(TOPCFILES) $(TOPHFILES) $(DOCFILES)
SUBXFILES = $(SUBCFILES) $(SUBHFILES)
CFILES = $(TOPCFILES) $(SUBCFILES)
Expand All @@ -208,15 +229,20 @@ install: default
$(INSTALL) -m 755 -d $(PCP_SYSCONF_DIR)/htop
$(INSTALL) -m 755 -d $(PCP_SYSCONF_DIR)/htop/meters
$(INSTALL) -m 755 -d $(PCP_SYSCONF_DIR)/htop/columns
$(INSTALL) -m 755 -d $(PCP_SYSCONF_DIR)/htop/screens
$(INSTALL) -m 755 -d $(PCP_SHARE_DIR)/htop
$(INSTALL) -m 755 -d $(PCP_SHARE_DIR)/htop/meters
@for m in $(METERS); do \
$(INSTALL) -m 644 pcp/meters/$$m $(PCP_SHARE_DIR)/htop/meters/$$m; \
done
$(INSTALL) -m 755 -d $(PCP_SHARE_DIR)/htop/meters
$(INSTALL) -m 755 -d $(PCP_SHARE_DIR)/htop/columns
@for c in $(COLUMNS); do \
$(INSTALL) -m 644 pcp/columns/$$c $(PCP_SHARE_DIR)/htop/columns/$$c; \
done
$(INSTALL) -m 755 -d $(PCP_SHARE_DIR)/htop/screens
@for c in $(SCREENS); do \
$(INSTALL) -m 644 pcp/screens/$$c $(PCP_SHARE_DIR)/htop/screens/$$c; \
done
else
build-me:
install:
Expand Down

0 comments on commit 9a5da8a

Please sign in to comment.