Commit Graph

2662 Commits

Author SHA1 Message Date
Nathan Scott 2b69f44a9d Fix whitespace oddity in previous DynamicMeter updates
Thanks @BenBE for noticing.
2021-07-14 17:08:36 +10:00
Nathan Scott 0daefbe4b4 Improve the DynamicMeter_search API to make 'key' optional
Thanks to @BenBE for the suggestion.
2021-07-14 11:58:46 +10:00
Nathan Scott 9cbee01877 Additional pointer checks in dynamic meter code for Coverity 2021-07-14 11:58:46 +10:00
Nathan Scott bf853addc3 Ensure PCP dynamic metric configuration definition uniqueness
It can happen that pcp-htop is presented multiple definitions
of the same dynamic meter, e.g. if /etc/pcp/htop/meters has a
definition matching one in ~/.config/htop/meters - instead of
exiting with a duplicate metric error provide more meaningful
diagnostics (on close) and also just skip over such entries.
System files override home directories which overrides those
found below the current working directory.

Also fix the derived metric error diagnostic; because this is
using CRT_fatalError, which is like perror(3), we must give a
meaningful prefix (like program name) at the string end.
2021-07-14 11:58:46 +10:00
Nathan Scott a476490282 Ensure we do not attempt to add a DynamicMeter via the
htoprc that we didn't find during start up.  This just
leaves blank sections of the display as @smalinux found.

Related to https://github.com/htop-dev/htop/pull/682
2021-07-14 11:58:31 +10:00
Benny Baumann bf22a8fb13 Add SIGINT handler
This SIGINT handler is installed on top of an optional
handler that some curses/ncurses implementations provide.

This ensures the curser is properly reset when hitting Ctrl+C.
2021-07-13 20:42:30 +02:00
nia 09c7e3e136 netbsd: Support building with libcurses
Right now Unicode support must be disabled, because htop peeks
into the ncurses cchar_t struct with Unicode enabled. NetBSD's cchar_t
has different contents.

Partially fixes #660

Signed-off-by: Nia Alarie <nia@NetBSD.org>
2021-07-13 20:42:30 +02:00
nia 4865e643ad netbsd: Fix display of in-use and cached memory 2021-07-13 19:06:30 +02:00
nia 67ca214cbe netbsd: Add dyanmicMeters stubs to fix the build
Signed-off-by: Nia Alarie <nia@NetBSD.org>
2021-07-13 19:05:24 +02:00
Eideen 9bba1c6cf7 README updates/formating
Formating add section "prerequisite"
To make it easy to build
Merged  Compiling from source and Github tarball ref: #639
removed tarball downloads #680
2021-07-11 14:10:47 +02:00
Nathan Scott e7aaf79166 Remove unnecessary include files from PCPDynamicMeter.c
Also resolve a few unintended style guide transgressions
in the PCP platform code.
2021-07-09 12:42:36 +10:00
Nathan Scott 9f667f2c74 Remove references to bintray in the README, no longer exists 2021-07-08 16:34:27 +10:00
Nathan Scott 01f5b89278 Pretty-print values in the PCP DynamicMeter code
Several improvements to the way values are displayed in the
PCP platform DynamicMeter implementation:
- handle the initial 'caption' setting as with regular meters,
  this required a new meter callback because we no longer have
  just a single meter caption for the DynamicMeter case
- if no label is provided for a metric in a configuration file
  use the short form metric name as a fallback
- honour the suffix setting in the configuration file
- convert metric values to the canonical units for htop (kbyte
  and seconds), and use Meter_humanUnit when it makes sense to
  do so.

Also improves the handling of fatal string error messages in a
couple of places, thanks to BenBE for the review feedback.
2021-07-08 10:56:05 +10:00
Nathan Scott 149774209b Remove Linux-specific cpp conditional in SwapMeter.c
Instead use the common NAN pattern to use of the swap
cached value on platforms that do not support it.
2021-07-07 14:24:32 +10:00
Nathan Scott 15a71f32fe Add more defensive checks to PCP paths if sampling fails 2021-07-07 14:00:36 +10:00
Sohaib Mohamed 93be3211ae PCP: use palette meter text colour for dynamic meter labels 2021-07-07 13:59:33 +10:00
Nathan Scott f0ed0fdafb 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-07-07 10:59:36 +10:00
Nathan Scott 865b85eb2d Fix an assert on kernel process name length on the PCP platform 2021-07-07 10:59:36 +10:00
Nathan Scott a0f758009b Fix bitmask used to extract CPU identifier for CPUMeter
When manipulating CPUMeters in the AvailableMeterPanel we
use the bottom 16 bits to hold the CPU number.  However,
the bitmask used to extract the CPU number only masks the
lower 8 bits (0xff).
2021-07-07 10:59:36 +10:00
Benny Baumann 44d1200ca4 Check for alloc_size attribute in configure.ac 2021-07-06 17:20:32 +02:00
Daniel Lange 3da142b4b6 Merge branch 'solaris-define-fixes' of BenBE/htop
Tested on OmniOS v11 r151036
2021-07-05 07:51:39 +02:00
Daniel Lange a60ff33e52 Merge branch 'check-set-escdelay' of BenBE/htop 2021-07-05 07:51:12 +02:00
Benny Baumann 364e4e692f Reduce visibility of GZONE and UZONE
Fixes #624
2021-07-04 19:34:03 +02:00
Benny Baumann 32414dace7 Remove unused define on Solaris 2021-07-04 19:32:47 +02:00
Benny Baumann 18e3fd5ce7 Check for set_escdelay in ncurses 2021-07-04 16:50:41 +02:00
Benny Baumann 874fb773a7 Fix typo in Generic_gettime_realtime on old Mac
Fixes #673
2021-07-01 23:27:54 +02:00
Sohaib Mohamed ecb6a8da78 PCP: Fix minor cut+paste typo 2021-06-30 07:45:47 +02:00
BenBE 3bed682b1e Always update `proc->st_uid` + `proc->user`
Avoids issue #661.
2021-06-26 12:18:37 +02:00
fraggerfox 686309e34c Redo the memory values based on the other BSD implementations. 2021-06-26 12:18:37 +02:00
fraggerfox 5fe9bcb21c Adds support for counting user and kernel threads. 2021-06-26 12:18:37 +02:00
fraggerfox 336acb0309 Adds support for PROC_EXE and CWD. 2021-06-26 12:18:37 +02:00
fraggerfox 612462e33d Adds the ELAPSED column for NetBSD.
Additional details regarding ELAPSED column can be found in #627.
2021-06-26 12:18:37 +02:00
fraggerfox 58a895e54c Fixes minor whitespace issues and re-arrange headers to conform to style guide. 2021-06-26 12:18:37 +02:00
fraggerfox 9de463e756 Implements the NetBSD specific changes for makeCommandStr refactor.
Refer to #388 PR for more details.
2021-06-26 12:18:37 +02:00
fraggerfox fa65c30976 Sets a non-NULL process state in case of kvm_getlwps(3) returns NULL. Thanks @cgzone. 2021-06-26 12:18:37 +02:00
fraggerfox 3770769ed1 Replaces WRAP_SUBTRACT with saturatingSub inline function to reduce code duplication. 2021-06-26 12:18:37 +02:00
fraggerfox 2f5b3ef733 Refactor saturatingSub() to be part of Macros.h 2021-06-26 12:18:37 +02:00
fraggerfox e42ae55d69 Renames variable from opl to npl for consistency. 2021-06-26 12:18:37 +02:00
fraggerfox 497f468ed0 Fix include paths and minor whitespace issues 2021-06-26 12:18:37 +02:00
fraggerfox 9b6cecfede Replace strlcpy() by safer String_safeStrncpy() 2021-06-26 12:18:37 +02:00
fraggerfox 3414d3b2d4 Replace maximum_PID value with INT32_MAX
Thank you @niacat.
2021-06-26 12:18:37 +02:00
fraggerfox 9e3b7c439c Update README for NetBSD 2021-06-26 12:18:37 +02:00
fraggerfox ddcfb179b4 Remove unwanted code, updates the comments 2021-06-26 12:18:37 +02:00
Benny Baumann b900e70e80 Update copyright notices 2021-06-26 12:18:37 +02:00
fraggerfox 440bb87058 Minor code clean up and corrections. 2021-06-26 12:18:37 +02:00
fraggerfox db98623684 Sync changes from master and fix minor warnings 2021-06-26 12:18:37 +02:00
fraggerfox 4b49de44a8 Add NetBSD platform support without procfs dependency
- TODO, clean up the code base and update comments in code.
2021-06-26 12:18:37 +02:00
Benny Baumann 30dc4a2812 Add a section on PRs for the styleguide 2021-06-26 11:11:13 +02:00
Benny Baumann 07170aee4c Unsupported: Remark on expectation of username field update 2021-06-22 09:32:11 +02:00
Benny Baumann 4dce2db832 Solaris: Always update username 2021-06-22 09:32:11 +02:00