Using a realtime clock is a bad idea: it is affected by any kind of time
change, which can happen when the administrator modifies the system time,
or more simply when a laptop suspends to RAM and then wakes up from sleep.
With the current approach of using a realtime clock:
- if the system time jumps forward (e.g. when resuming after a
suspend-to-RAM), bmon would take 100% CPU and display random graph data
extremely fast, until it "catches up" with the new time.
- if the system time jumps backwards, bmon would freeze until *time*
"catches up" to the point it was before. bmon then (incorrectly)
displays a spike in the graph, because lots of packets have been
sent/received since the last update.
Instead of using gettimeofday(), switch to clock_gettime() with
CLOCK_MONOTONIC on systems that support it. OS X does not provide
clock_gettime(), so this commit also adds a Mach-specific implementation.
This change has been tested on Linux 4.1 with glibc and musl, and on
FreeBSD 10.0-RELEASE-p12.
This commit enables colors in bmon. It adds configuration options to
let the user decide, which colors should be used. Therefor the graph_rx and graph_tx
layouts are introduced and applied respectively.
* Add graph_rx, graph_tx and layout_cfg fields.
* Setting default colors if colorized output is enabled.
* draw_table accept additional layout parameter and apply the given layout for
the table graph.
* Apply layouts for rx, tx graph and header and statusbar.
* Add include/layout.h, which provides functions to parse, color and attribute
strings and set the layout.
* Adding a default layout-config example in examples/bmon.conf.
[Edit: Based on original work by eri!, #PR23]
Press 'r' in curses mode to reset a statistic counter to
start counting from 0 again. This does NOT reset the
counter from the source itself but merely emulates a
counter reset. If you restart bmon, the counter will be
back to its total value.
Signed-off-by: Thomas Graf <tgraf@suug.ch>
Enforces a single registration of a module with a subsystem.
module_register() now returns -EBUSY if module is already
registered.
Adds support for BMON_MODULE_AUTO to flag modules that should
be autoloaded upon the first call to module_set(). Loading
will succeed if the probe() function succeeds.