| Commit message (Collapse) | Author | Age | Files | Lines |
| |
|
|
|
|
|
|
|
|
|
| |
All uses of meter drawing "mode" numbers now have the type
`MeterModeId`, including the uses in structures and arrays.
`MeterModeId` is defined as `unsigned int`, as (currently) it doesn't
save any code size by defining it to any smaller type.
Signed-off-by: Kang-Che Sung <explorer09@gmail.com>
|
|
|
|
|
|
|
|
|
|
|
| |
All client codes that access this global `Meter_modes` array have been
replaced in previous commits, thus it's no longer necessary to keep
this internal information (draw functions, default heights, etc.)
public. It was also a bad idea when the client codes need to avoid
accessing `Meter_modes[0]` (which is reserved and contains null
information) by themselves.
Signed-off-by: Kang-Che Sung <explorer09@gmail.com>
|
|
|
|
|
| |
This section reordering is a prerequisite to privatizing the
`Meter_modes` array.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
The use of CUSTOM_METERMODE value in meter default mode was a bad
design. There are no meter that really has a "custom" mode to work with
and currently that value serves as a useless placeholder that hides the
real default mode for a meter.
Replace CUSTOM_METERMODE in `defaultMode` of all meters with the real
intended default modes. Currently only CPU meters and MemorySwapMeter
used this, and their real defaults are BAR_METERMODE.
In Meter_setMode(), remove the special treatment of `defaultMode ==
CUSTOM_METERMODE`, Meter_setMode() still calls the `updateMode` function
for custom treatment when it's present for a meter class.
As CUSTOM_METERMODE is obsolete from `defaultMode`, the init functions
of CPU meters and MemorySwapMeter need to be adjusted to avoid
incomplete initialization (Meter.draw function bring NULL).
Signed-off-by: Kang-Che Sung <explorer09@gmail.com>
|
|
|
|
| |
Suggested by Benny Baumann (@BenBE). No code changes.
|
| |
|
|
|
|
| |
The bottom line was too short before...
|
| |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
Since Meter_humanUnit() is often called with floating point values in
Meter objects, rewrite the function to let it process `double` type
natively, and save floating point to integer casts.
The rewritten function:
* Allows higher orders of magnitude including 'R' and 'Q', and
addresses infinity. (The previous version has a maximum value of
(2^64 - 1) representing 16 ZiB.)
* Rounds values when they are in intervals (99.9, 100) and (9.99, 10),
and displays them with correct precision (number of fraction digits).
* Produces assertion error on negative and NaN values (undefined
behavior).
Signed-off-by: Kang-Che Sung <explorer09@gmail.com>
|
|
|
|
|
|
|
| |
Reduce code size a little in GraphMeterMode_draw() when compiled in
`-Os` mode.
Signed-off-by: Kang-Che Sung <explorer09@gmail.com>
|
|
|
|
|
|
|
|
|
| |
The number of items of a Meter can exceed the length of
BarMeterMode_characters array. (The CPU Meter is an example.)
Item numbers exceeding the length are unplottable in a bar.
Add an assertion to note the fact.
Signed-off-by: Kang-Che Sung <explorer09@gmail.com>
|
|
|
|
|
|
|
|
|
|
|
| |
The `Meter.total` value may be 0 on BatteryMeter, SwapMeter,
linux/HugePageMeter, linux/ZramMeter and others. In case of a zero
total value, print an empty bar in bar meter mode.
Also change GraphMeterMode_draw() so that it no longer writes back the
`total` value if it is zero.
Signed-off-by: Kang-Che Sung <explorer09@gmail.com>
|
|
|
|
|
|
|
|
|
| |
Fixes a regression caused by 74b28849c4ee7234aa6018667ff6c8c9a6b41273.
When a graph meter is too narrow to draw the graph, but the graph data
buffer is allocated, the meter should keep recording new values.
Signed-off-by: Kang-Che Sung <explorer09@gmail.com>
|
|
|
|
| |
Signed-off-by: Kang-Che Sung <explorer09@gmail.com>
|
|
|
|
|
|
|
|
| |
* Rework the logic of computing `i` (initial index of graph data
records) slightly and remove unreachable code.
* Rename k to `col` and change its data type from ssize_t back to int.
Signed-off-by: Kang-Che Sung <explorer09@gmail.com>
|
|
|
|
|
|
|
|
| |
In particular, move the code for adding a new graph record to before
the GraphMeterMode_dots selection code. (The latter is the drawing part
of the function.)
Signed-off-by: Kang-Che Sung <explorer09@gmail.com>
|
|
|
|
|
|
|
|
|
| |
...to draw even a single record of the graph.
This makes the code more robust by checking (w <= 0) explicitly.
Also avoids unnecessary reallocations of the GraphData buffer.
Signed-off-by: Kang-Che Sung <explorer09@gmail.com>
|
| |
|
|
|
|
| |
Ref: https://github.com/htop-dev/htop/commit/a33cbae28826de4f20930d225e31f3be0db0502b#r129599267 by @Explorer09
|
|
|
|
|
|
|
|
|
| |
On wide screens the previous value of 256 could end up insufficient to
cover the screen space allocated to the graph, leaving it awkwardly
truncated mid-column. We now allocate the buffer dynamically instead,
growing it to accommodate whatever width the graph occupies.
Signed-off-by: Zev Weiss <zev@bewilderbeest.net>
|
| |
|
|
|
|
|
|
|
|
|
|
|
|
| |
The 'comprisedValues' boolean property unnecessarily complicates the
drawing algorithms of Bar meters and Graph meters. Since the only user
of 'comprisedValues' is ZramMeter, it is better to rework the meter so
that it no longer needs 'comprisedValues'.
The 'values[ZRAM_METER_UNCOMPRESSED]' now stores the difference between
uncompressed and compressed data size.
Signed-off-by: Kang-Che Sung <explorer09@gmail.com>
|
|
|
|
|
|
| |
Do not throw FP exceptions if any value in a Meter object is a NaN.
Signed-off-by: Kang-Che Sung <explorer09@gmail.com>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
The standard isnan() function is defined to never throw FP exceptions
even when the argument is a "signaling" NaN. This makes isnan() more
expensive than (x != x) expression unless the compiler flag
'-fno-signaling-nans' is given.
Introduce functions isNaN(), isNonnegative(), isPositive(),
sumPositiveValues() and compareRealNumbers(), and replace isnan() in
htop's codebase with the new functions. These functions utilize
isgreater() and isgreaterequal() comparisons, which do not throw FP
exceptions on "quiet" NaNs, which htop uses extensively.
With isnan() removed, there is no need to suppress the warning
'-Wno-c11-extensions' in FreeBSD. Remove the code from 'configure.ac'.
Signed-off-by: Kang-Che Sung <explorer09@gmail.com>
|
|
|
|
|
|
|
|
|
|
|
| |
First stage in sanitizing the process list structure so that htop
can support other types of lists too (cgroups, filesystems, ...),
in the not-too-distant future.
This introduces struct Machine for system-wide information while
keeping process-list information in ProcessList (now much less).
Next step is to propogate this separation into each platform, to
match these core changes.
|
|
|
|
|
| |
Useful for bar mode if latter values of the meter comprise previous
ones.
|
| |
|
|
|
|
|
|
|
| |
Do not leave empty last column in header meters by refactoring the width
and separator logic.
Closes: #784
|
| |
|
|
|
|
| |
Closes #761
|
|
|
|
|
|
| |
Meter.c:320:71: warning: performing an implicit widening conversion to type '__suseconds_t' (aka 'long') of a multiplication performed in type 'int' [bugprone-implicit- widening-of-multiplication-result]
struct timeval delay = { .tv_sec = globalDelay / 10, .tv_usec = (globalDelay - ((globalDelay / 10) * 10)) * 100000 };
^
|
|
|
|
| |
Stop displaying LED-mode if maximum width is reached.
|
| |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
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.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
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.
|
| |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
Refactor the sample time code to make one call to gettimeofday
(aka the realtime clock in clock_gettime, when available) and
one to the monotonic clock. Stores each in more appropriately
named ProcessList fields for ready access when needed. Every
platform gets the opportunity to provide their own clock code,
and the existing Mac OS X specific code is moved below darwin
instead of in Compat.
A couple of leftover time(2) calls are converted to use these
ProcessList fields as well, instead of yet again sampling the
system clock.
Related to https://github.com/htop-dev/htop/pull/574
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
The end goal is to consolidate all the points in htop that can only work in
live-only mode today, so that will be able to inject PCP archive mode and have
a chance at it working.
The biggest problem we've got at this moment is all the places that are
independently asking the kernel to 'give me the time right now'.
Each of those needs to be audited and ultimately changed to allow platforms to
manage their own idea of time.
So, all the calls to gettimeofday(2) and time(2) are potential problems.
Ultimately I want to get these down to just one or two.
Related to https://github.com/htop-dev/htop/pull/574
|
|
|
|
| |
These parameters were once unused, but not anymore.
|
| |
|
|
|
|
|
|
|
| |
The local stack buffer does not need to be cleaned to zeros when
- just initialized, cause the length is set to 0 and the first
character is set to '\0', so all printing functions will safely stop
- no further used, i.e. the variable goes out of scope
|
|
|
|
| |
Use a temporary local variable
|
|\ |
|
| | |
|
| | |
|
|/ |
|
| |
|
| |
|
|
|
|
|
|
| |
Print wide characters, like degree sign, properly via mvadd_wch().
Ignore attributes when returning value from RichString_getCharVal() in
non-wide ncurses mode to test against raw characters.
|