69 Commits

Author SHA1 Message Date
Alexis Hildebrandt
5677863e61 curses: Add CTRL-N/CTRL-P for next/previous element 2018-01-03 10:35:42 +01:00
Alexis Hildebrandt
ed8528cf9c curses: Fix seperator lines
when section above or below is collapsed
2018-01-03 10:35:29 +01:00
Alexis Hildebrandt
737c642819 Fix typographical errors 2018-01-03 10:35:15 +01:00
Nachiketa Prachanda
3413751795 out_curses: use xcalloc instead of a fixed buffer
In put_line(), replace the fixed onstack buffer with a xcalloc-ed buffer.
This fixes a bmon crash with terminal size larger than 2048 bytes. The crash
be reproduced with
   $ stty cols 2100
   $ bmon ....

Signed-off-by: Nachiketa Prachanda <nchkta@gmail.com>
2017-02-02 20:56:59 +01:00
Tobias Klauser
af8923b779 netlink: Add rx_nohandler link stat counter
Hook up the device rx nohandler stat counter available in the upcoming
libnl 3.2.29, added in libnl commit 5040fc8a4994 ("lib/route: add
rx_nohandler link stats field").

Also add a compatibility define, so older libnl version will still work
fine.

Signed-off-by: Tobias Klauser <tklauser@distanz.ch>
2016-12-13 11:50:49 +01:00
Baptiste Jonglez
a3d894000b Use a monotonic clock instead of a realtime clock
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.
2016-11-12 19:29:39 +01:00
Adam Drescher
a5301347f6 Flushed stdout after every group is printed in an iteration. This allows us to redirect ascii based output to a file. 2016-10-17 18:54:46 -05:00
Adam Drescher
32d8c76b18 Changed the long format string example to be one continuous string. While this is less pretty than it was before, it allows the user to actually paste the format string directly into their bmon command to try it out. Before this change, the way the string was formatted you could not simply paste it in and run it (whether it had single or double quotes). 2016-10-07 11:49:39 -05:00
Adam Drescher
577112870d Replaced format string double quotes with single quotes to prevent the shell from running our provided format placeholders. 2016-10-07 11:42:14 -05:00
blastmaster
702df3c0a1 Fix issue #43
* Remove newline from put_line formatstring while drawing details.
2016-08-04 22:57:33 +02:00
Thomas Graf
7317715e15 Fix item selection after element subgroups have been removed
If the element currently selected is removed due to inactivity, the
selection is fixed up to the previous element in the list. This step
must be done after the entire element subgroup has been removed.

Signed-off-by: Thomas Graf <tgraf@suug.ch>
2016-08-02 12:05:29 +02:00
Thomas Graf
86f6da0703 Use DEFAULT_GROUP instead of hardcoded string
Signed-off-by: Thomas Graf <tgraf@suug.ch>
2016-08-02 11:38:07 +02:00
Thomas Graf
723f6a5b47 dummy: Use default group as first group name
Signed-off-by: Thomas Graf <tgraf@suug.ch>
2016-08-02 11:37:50 +02:00
Thomas Graf
ddcd5e7d24 Derive initial interface selection based on policy
So far, any output module with a selection capability defaulted to
the first interface in the list as first pick. This uses the policy
configuration instead and thus allows to select which interface to
display first:

Examples:
 bmon -p 'em1,*'
 bmon -p 'eth*,lo,*'

The first rule that finds a matching interface is used and will
trigger initial selection.

Note that this is *ONLY* evaluated after the first read of the
statistics so if a more preferred interface appears later, the
selection will not be changed.

Signed-off-by: Thomas Graf <tgraf@suug.ch>
2016-08-02 10:14:24 +02:00
blastmaster
828b5b5368 enabling colors for bmon
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]
2016-07-19 22:57:37 +02:00
Tobias Klauser
f177718f24 format: Add missing braces around 'if' clause
When compiling bmon with gcc 6.1 it complains with the following
warning:

out_format.c: In function ‘get_token’:
out_format.c:134:10: warning: this ‘if’ clause does not guard... [-Wmisleading-indentation]
   } else if (!strncasecmp(token+5, "txrate:", 7))
          ^~
out_format.c:136:4: note: ...this statement, but the latter is misleadingly indented as if it is guarded by the ‘if’
    return buf;
    ^~~~~~

Indeed, the 'return buf' should only be executed if it was snprintf()'ed
to. Otherwise "unknown" should be returned. Fix this by adding braces.
Also use the 'type' variable in strncasecmp() as in the other checks.

Signed-off-by: Tobias Klauser <tklauser@distanz.ch>
2016-04-28 16:11:30 +02:00
Thomas Graf
f78c0e5b98 Add 'info' option to show additional info screen by default
Suggested-by: @Berzerker
Signed-off-by: Thomas Graf <tgraf@suug.ch>
2016-03-29 12:22:56 +02:00
Benny Siegert
74770b8806 Use uintmax_t cast for some printfs.
Some of the BSDs have 32-bit, some 64-bit vars for this.
2016-03-26 21:42:05 +01:00
Benny Siegert
fa6abf3a80 NetBSD does not have send or receive quotas. 2016-03-26 21:40:07 +01:00
Thomas Graf
4efaa8ce9e curses: Add ability to reset statistics
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>
2016-01-29 12:11:44 +01:00
Thomas Graf
a0eea59519 netlink: BUG() if we don't have parent information
This would indicate that we hang a TC object to the tree root.

Signed-off-by: Thomas Graf <tgraf@suug.ch>
2015-12-16 15:40:58 +01:00
Thomas Graf
f9c714fa15 netlink: Use ifindex of parent TC object when searching leaf qdiscs
The qdisc cache is host wide, the parent classid is not unique
so the ifindex of the parent tc object must be set in the filter
otherwise a leaf qdisc with an identical parent id in another
device can be mistaken.

This also converts the class_cache to be passed up through the
stack to make clear it is not system wide but specific to the
ifindex we are currently handling.

Signed-off-by: Thomas Graf <tgraf@suug.ch>
2015-12-16 15:36:03 +01:00
Thomas Graf
892bdac762 bmon: Mark attr_def_free() and __lookup_element() static
Fixes sparse warnings:
attr.c:114:6: warning: symbol 'attr_def_free' was not declared. Should it be static?
element.c:116:16: warning: symbol '__lookup_element' was not declared. Should it be static?

Signed-off-by: Thomas Graf <tgraf@suug.ch>
2015-12-16 14:10:43 +01:00
Thomas Graf
4488cd03f9 bmon: Properly pass NULL pointers instead of 0
Signed-off-by: Thomas Graf <tgraf@suug.ch>
2015-12-16 14:09:35 +01:00
Thomas Graf
753a9e09dd bmon: Remove dead code and make sig_exit() static
Fixes sparse warnings:
bmon.c:36:5: warning: symbol 'do_quit' was not declared. Should it be static?
bmon.c:37:5: warning: symbol 'is_daemon' was not declared. Should it be static?
bmon.c:91:12: warning: symbol 'sig_int' was not declared. Should it be static?
bmon.c:98:6: warning: symbol 'sig_exit' was not declared. Should it be static?

Signed-off-by: Thomas Graf <tgraf@suug.ch>
2015-12-16 14:04:14 +01:00
Thomas Graf
0641291ad5 curses: Pass in proper NULL pointer
Fix sparse warning:
out_curses.c:433:25: warning: Using plain integer as NULL pointer

Signed-off-by: Thomas Graf <tgraf@suug.ch>
2015-12-16 14:01:51 +01:00
Thomas Graf
f666ffd0b7 curses: Make float2str static
Fix sparse message:
out_curses.c:140:6: warning: symbol 'float2str' was not declared. Should it be static?

Signed-off-by: Thomas Graf <tgraf@suug.ch>
2015-12-16 14:00:39 +01:00
Thomas Graf
559e31e62f Merge pull request #30 from tklauser/ip6-link-stats
Add additional IPv6 link stats
2015-11-15 18:09:42 -08:00
Tobias Klauser
665c63d4e7 Add additional IPv6 link stats
Hook up additional IPv6 link statistics counters available since libnl
v3.2.25. Also add compatibility defines, so bmon can still be compiled
against older libnl versions.

Signed-off-by: Tobias Klauser <tklauser@distanz.ch>
2015-08-06 15:20:07 +02:00
Thomas Graf
e31a860af6 Update copyright
Signed-off-by: Thomas Graf <tgraf@suug.ch>
2015-07-25 11:05:01 +02:00
Thomas Graf
2027a634a7 netlink: Only disable TC stats if QoS is not available in kernel
Up to now, the entire Netlink module was disable if QoS statistics were
not available. Merely disable TC stats themselves but continue using
the input module.

Reported-by: Wen Chiu <Wen.Chiu@brocade.com>
Signed-off-by: Thomas Graf <tgraf@suug.ch>
2015-07-25 10:51:47 +02:00
Thomas Graf
21ec49ed67 format: Don't print error message for unavailable attributes
Signed-off-by: Thomas Graf <tgraf@suug.ch>
2015-06-30 11:59:48 +02:00
Chocobo1
51a24c315b Fix wrong unit displayed when using "--use-bit" option 2015-05-31 21:27:52 +08:00
Chocobo1
5cecc86856 Fix inconsistency in format module example 2015-05-31 18:53:35 +08:00
Tobias Klauser
c80554be16 Explicitly include linux/if.h to fix cross-compile error
When compiling bmon with the Linaro 2014.01 ARM toolchain
(gcc-linaro-arm-linux-gnueabihf-4.8-2014.01_linux) the following compile error occurs:

  in_netlink.c: In function ‘do_link’:
  in_netlink.c:688:53: error: ‘IFF_UP’ undeclared (first use in this function)

Fix it by explicitly including linux/if.h, where IFF_UP is defined.

Signed-off-by: Tobias Klauser <tklauser@distanz.ch>
2015-04-30 12:00:35 +02:00
Chocobo1
229d58c975 using cfg_setint is triggering an assertion in confuse library, should use cfg_setbool instead 2015-01-19 20:02:14 +08:00
Thomas Graf
0100916a95 BSD: Provide minimal interface information
Including:
 - MTU
 - Metric
 - RX/TX IRQ Quota

Signed-off-by: Thomas Graf <tgraf@suug.ch>
2014-12-16 18:31:27 +01:00
Thomas Graf
4492ab547c build: Enable -Wall
Signed-off-by: Thomas Graf <tgraf@suug.ch>
2014-08-25 01:07:19 +02:00
Thomas Graf
a36136ec4d Annotate unused variables
Signed-off-by: Thomas Graf <tgraf@suug.ch>
2014-08-25 01:07:19 +02:00
Thomas Graf
e3d208905d Initialize t to silence uninit warning
Signed-off-by: Thomas Graf <tgraf@suug.ch>
2014-08-25 01:07:19 +02:00
Thomas Graf
68bd14ffd1 Remove unused write_column() function
Signed-off-by: Thomas Graf <tgraf@suug.ch>
2014-08-25 01:07:19 +02:00
Thomas Graf
e2df502abc Remove unused variables
Signed-off-by: Thomas Graf <tgraf@suug.ch>
2014-08-25 01:07:19 +02:00
Thomas Graf
9d89c5bc8e curses: Handle out of memory return value of of vasprintf()
Signed-off-by: Thomas Graf <tgraf@suug.ch>
2014-08-24 22:11:32 +02:00
Thomas Graf
584ef44252 proc: Silence warning of unhandled fgets() return value
Signed-off-by: Thomas Graf <tgraf@suug.ch>
2014-08-24 22:11:02 +02:00
Thomas Graf
41e36f2a66 element: Remove unneeded condition, element is always member of group
Fixes: CID 49003
Signed-off-by: Thomas Graf <tgraf@suug.ch>
2014-08-24 20:52:53 +02:00
Thomas Graf
ccf33755ad utils: Fix copy_timestamp() accuracy
Fixes: CID 49000
Signed-off-by: Thomas Graf <tgraf@suug.ch>
2014-08-24 20:51:00 +02:00
Thomas Graf
3cff7715ce curses: Check if value is provided for ngraph
Fixes: CID 49001
Signed-off-by: Thomas Graf <tgraf@suug.ch>
2014-08-24 20:48:12 +02:00
Thomas Graf
22c83ceb1a proc: Fix leakage of fd if element lookup failed
Fixes: CID 49002
Signed-off-by: Thomas Graf <tgraf@suug.ch>
2014-08-24 20:44:53 +02:00
Thomas Graf
6eae8530c5 Fix uint64_t printf modifiers
Reported by clang. Repo compiles cleanly with clang at this point.

Signed-off-by: Thomas Graf <tgraf@suug.ch>
2014-08-24 14:55:27 +02:00
Thomas Graf
afb5db14c8 curses: Fix '?' to toggle quick help
Previously, pressing '?' only made the quick help appear but not
disappear again.

Reported-by: Bill [github id "broomdodger"]
Signed-off-by: Thomas Graf <tgraf@suug.ch>
2014-08-24 14:05:42 +02:00