From e2df502abc24b97dba3485f9734a3f48ea7de0f8 Mon Sep 17 00:00:00 2001 From: Thomas Graf Date: Mon, 25 Aug 2014 01:01:40 +0200 Subject: [PATCH 01/76] Remove unused variables Signed-off-by: Thomas Graf --- src/in_netlink.c | 2 +- src/module.c | 1 - src/unit.c | 2 +- 3 files changed, 2 insertions(+), 3 deletions(-) diff --git a/src/in_netlink.c b/src/in_netlink.c index 64021f5..7762592 100644 --- a/src/in_netlink.c +++ b/src/in_netlink.c @@ -774,7 +774,7 @@ static void netlink_shutdown(void) static int netlink_do_init(void) { - int err, i; + int err; if (!(sock = nl_socket_alloc())) { fprintf(stderr, "Unable to allocate netlink socket\n"); diff --git a/src/module.c b/src/module.c index b245f72..9c83fe1 100644 --- a/src/module.c +++ b/src/module.c @@ -130,7 +130,6 @@ static void __auto_load(struct bmon_module *m) int module_set(struct bmon_subsys *ss, const char *name) { struct bmon_module *mod; - struct list_head *list; LIST_HEAD(tmp_list); module_conf_t *m; diff --git a/src/unit.c b/src/unit.c index 38fc468..81f1f63 100644 --- a/src/unit.c +++ b/src/unit.c @@ -28,7 +28,7 @@ #include #include -static struct unit *byte_unit, *bit_unit, *number_unit; +static struct unit *byte_unit, *bit_unit; static LIST_HEAD(units); From 68bd14ffd1ba7ccaa32ebcefa6627be6b53b7063 Mon Sep 17 00:00:00 2001 From: Thomas Graf Date: Mon, 25 Aug 2014 01:02:10 +0200 Subject: [PATCH 02/76] Remove unused write_column() function Signed-off-by: Thomas Graf --- src/graph.c | 20 -------------------- 1 file changed, 20 deletions(-) diff --git a/src/graph.c b/src/graph.c index e223b28..95866bd 100644 --- a/src/graph.c +++ b/src/graph.c @@ -58,26 +58,6 @@ static inline char *tbl_pos(struct graph_cfg *cfg, char *tbl, int nrow, int ncol return at_col(at_row(cfg, tbl, nrow), ncol); } -static void write_column(struct graph_cfg *cfg, struct graph_table *tbl, int ncol, - uint64_t value, double *scale, double half_step) -{ - char *col = at_col(tbl->gt_table, ncol); - int i; - -#if 0 - if (value == UNK_DATA) { - for (i = 0; i < height; i++) - *(at_row(g, col, i)) = unk_char; -#endif - if (value) { - *(at_row(cfg, col, 0)) = ':'; - - for (i = 0; i < cfg->gc_height; i++) - if (value >= (scale[i] - half_step)) - *(at_row(cfg, col, i)) = cfg->gc_foreground; - } -} - static void fill_table(struct graph *g, struct graph_table *tbl, struct history *h, struct history_store *data) { From e3d208905d62253a402f7cb32f96f910e64d8c4f Mon Sep 17 00:00:00 2001 From: Thomas Graf Date: Mon, 25 Aug 2014 01:02:57 +0200 Subject: [PATCH 03/76] Initialize t to silence uninit warning Signed-off-by: Thomas Graf --- src/conf.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/conf.c b/src/conf.c index 48d07c8..d85e9f6 100644 --- a/src/conf.c +++ b/src/conf.c @@ -371,7 +371,7 @@ static void configfile_read_units(void) static void configfile_read_attrs(void) { - int i, nattrs, t; + int i, nattrs, t = 0; nattrs = cfg_size(cfg, "attr"); From a36136ec4d9056a32a9547c3abcc22ee7e1b3c32 Mon Sep 17 00:00:00 2001 From: Thomas Graf Date: Mon, 25 Aug 2014 01:06:01 +0200 Subject: [PATCH 04/76] Annotate unused variables Signed-off-by: Thomas Graf --- include/bmon/bmon.h | 2 ++ src/in_proc.c | 2 +- src/out_curses.c | 2 +- 3 files changed, 4 insertions(+), 2 deletions(-) diff --git a/include/bmon/bmon.h b/include/bmon/bmon.h index e349110..05934ec 100644 --- a/include/bmon/bmon.h +++ b/include/bmon/bmon.h @@ -60,9 +60,11 @@ enum { #if defined __GNUC__ #define __init __attribute__ ((constructor)) #define __exit __attribute__ ((destructor)) +#define __unused__ __attribute__ ((unused)) #else #define __init #define __exit +#define __unused__ #endif #ifdef DEBUG diff --git a/src/in_proc.c b/src/in_proc.c index aead5ce..b14269b 100644 --- a/src/in_proc.c +++ b/src/in_proc.c @@ -101,7 +101,7 @@ static void proc_read(void) { struct element *e; FILE *fd; - char buf[512], *p, *s, *unused; + char buf[512], *p, *s, *unused __unused__; int w; if (!(fd = fopen(c_path, "r"))) diff --git a/src/out_curses.c b/src/out_curses.c index cbd19ae..c973789 100644 --- a/src/out_curses.c +++ b/src/out_curses.c @@ -148,7 +148,7 @@ static void put_line(const char *fmt, ...) { va_list args; char buf[2048]; - int x, y; + int x, y __unused__; memset(buf, 0, sizeof(buf)); getyx(stdscr, y, x); From 4492ab547cca3f94807a75724b960af200434936 Mon Sep 17 00:00:00 2001 From: Thomas Graf Date: Mon, 25 Aug 2014 01:06:26 +0200 Subject: [PATCH 05/76] build: Enable -Wall Signed-off-by: Thomas Graf --- src/Makefile.am | 1 + 1 file changed, 1 insertion(+) diff --git a/src/Makefile.am b/src/Makefile.am index c773410..2e2aeb1 100644 --- a/src/Makefile.am +++ b/src/Makefile.am @@ -7,6 +7,7 @@ bmon_CFLAGS = \ -I${top_builddir}/include \ -DSYSCONFDIR=\"$(sysconfdir)\" \ -D_GNU_SOURCE \ + -Wall \ $(CURSES_CFLAGS) \ $(CONFUSE_CFLAGS) \ $(LIBNL_CFLAGS) \ From 17a4adb0f27f1ce34b5e7b39f636d0d5f23cda49 Mon Sep 17 00:00:00 2001 From: Thomas Graf Date: Mon, 25 Aug 2014 00:19:54 +0200 Subject: [PATCH 06/76] build: fail CI builds if a new warning is introduced Signed-off-by: Thomas Graf --- .travis.yml | 2 +- .travis/run.sh | 9 +++++++++ 2 files changed, 10 insertions(+), 1 deletion(-) create mode 100755 .travis/run.sh diff --git a/.travis.yml b/.travis.yml index e1755fd..de9b0f7 100644 --- a/.travis.yml +++ b/.travis.yml @@ -7,4 +7,4 @@ before_install: - sudo apt-get install libnl-3-dev libnl-route-3-dev - sudo apt-get install libncurses-dev # Change this to your needs -script: ./autogen.sh && ./configure && make +script: ./.travis/run.sh diff --git a/.travis/run.sh b/.travis/run.sh new file mode 100755 index 0000000..e7caf56 --- /dev/null +++ b/.travis/run.sh @@ -0,0 +1,9 @@ +#!/bin/bash + +FLAGS="-Werror" + +if [ $CC = "clang" ]; then + FLAGS="$FLAGS -Wno-error=unused-command-line-argument" +fi + +./autogen.sh && ./configure && make CFLAGS="$FLAGS" From 8b4ce86cc9e493866358fef53c13e549e698eacd Mon Sep 17 00:00:00 2001 From: Thomas Graf Date: Sat, 30 Aug 2014 13:30:30 +0200 Subject: [PATCH 07/76] Makefile: Fix README.md distribution inclusion Signed-off-by: Thomas Graf --- Makefile.am | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Makefile.am b/Makefile.am index d4e5b01..93da670 100644 --- a/Makefile.am +++ b/Makefile.am @@ -4,4 +4,4 @@ ACLOCAL_AMFLAGS = -I m4 SUBDIRS = src man include examples -EXTRA_DIST = ChangeLog LICENSE.BSD LICENSE.MIT NEWS README.adoc +EXTRA_DIST = ChangeLog LICENSE.BSD LICENSE.MIT NEWS README.md From 6920af805ce3146514729153de0062cc84644109 Mon Sep 17 00:00:00 2001 From: Thomas Graf Date: Sat, 30 Aug 2014 13:32:49 +0200 Subject: [PATCH 08/76] travis: Run make distcheck Signed-off-by: Thomas Graf --- .travis/run.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.travis/run.sh b/.travis/run.sh index e7caf56..46ea437 100755 --- a/.travis/run.sh +++ b/.travis/run.sh @@ -6,4 +6,4 @@ if [ $CC = "clang" ]; then FLAGS="$FLAGS -Wno-error=unused-command-line-argument" fi -./autogen.sh && ./configure && make CFLAGS="$FLAGS" +./autogen.sh && ./configure && make CFLAGS="$FLAGS" && make distcheck From 7f8d60f40f17671437a0aecf8f4becc8f3adba85 Mon Sep 17 00:00:00 2001 From: Thomas Graf Date: Sat, 30 Aug 2014 13:36:46 +0200 Subject: [PATCH 09/76] 3.5 release Signed-off-by: Thomas Graf --- NEWS | 7 +++++++ README.md | 17 ++++++----------- configure.ac | 2 +- 3 files changed, 14 insertions(+), 12 deletions(-) diff --git a/NEWS b/NEWS index dd3baff..e96c0ba 100644 --- a/NEWS +++ b/NEWS @@ -1,3 +1,10 @@ +v3.5 - August 30, 2014 +---------------------- + * Fixes for all defects identified by coverity + * Fix accuracy issue on total rate calculation + * Travis-CI support + * Various other small bugfixes + v3.4 - August 24, 2014 ---------------------- * Bugfixes diff --git a/README.md b/README.md index 3c8055d..e4b1d7e 100644 --- a/README.md +++ b/README.md @@ -10,17 +10,12 @@ interface and a programmable text output for scripting. ## Changes -### New in 3.4 - * Bugfixes - * blank screen with config file - * quick-help toggle with '?' in curses - * Better bmon.conf example - -## New in 3.3 - * MacOS X port - * Only initialize curses module if actually used - * Assorted bug and spelling fixes - * Various build fixes + +## New in v3.5 + * Fixes for all defects identified by coverity + * Fix accuracy issue on total rate calculation + * Travis-CI support + * Various other small bugfixes ### Usage diff --git a/configure.ac b/configure.ac index d2040c5..3059e52 100644 --- a/configure.ac +++ b/configure.ac @@ -21,7 +21,7 @@ # FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER # DEALINGS IN THE SOFTWARE. -AC_INIT(bmon, 3.4, [], [], [http://www.infradead.org/~tgr/bmon/]) +AC_INIT(bmon, 3.5, [], [], [http://www.infradead.org/~tgr/bmon/]) AC_CONFIG_HEADERS(include/bmon/defs.h) AC_CONFIG_AUX_DIR([build-aux]) AC_CONFIG_MACRO_DIR([m4]) From c1d0bb41c7fc9ce8a95fa2a40e6f91465fcf4505 Mon Sep 17 00:00:00 2001 From: Thomas Graf Date: Fri, 5 Sep 2014 09:39:24 +0200 Subject: [PATCH 10/76] Fix LICENSE links in README.md Reported-by: Eric Leblond Signed-off-by: Thomas Graf --- README.md | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/README.md b/README.md index e4b1d7e..bcb5b6b 100644 --- a/README.md +++ b/README.md @@ -35,9 +35,10 @@ provided via: ## Copyright -> *Copyright (c) 2001-2014 Thomas Graf -> Copyright (c) 2013 Red Hat, Inc.* +> *Copyright (c) 2001-2014 Thomas Graf * +> *Copyright (c) 2013 Red Hat, Inc.* -Please see the [LICENSE](https://github.com/tgraf/bmon/blob/master/LICENSE) -file for additional details. +Please see the [LICENSE.BSD](https://github.com/tgraf/bmon/blob/master/LICENSE.BSD) +and [LICENSE.MIT](https://github.com/tgraf/bmon/blob/master/LICENSE.MIT) files for +additional details. From c4ed01f27220f748b86968daa43132b8dfe57777 Mon Sep 17 00:00:00 2001 From: Gustavo Zacarias Date: Tue, 11 Nov 2014 20:37:21 -0300 Subject: [PATCH 11/76] build: uclinux is also linux --- configure.ac | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/configure.ac b/configure.ac index 3059e52..10388fd 100644 --- a/configure.ac +++ b/configure.ac @@ -70,7 +70,7 @@ fi PKG_CHECK_MODULES([CONFUSE], [libconfuse], [], AC_MSG_ERROR([requires libconfuse])) case ${target_os} in - linux*) + linux*|uclinux*) PKG_CHECK_MODULES([LIBNL], [libnl-3.0], [], AC_MSG_ERROR([requires libnl3-dev])) PKG_CHECK_MODULES([LIBNL_ROUTE], [libnl-route-3.0], [], AC_MSG_ERROR([requires libnl3-route])) ;; From baabc8b729bd57f73cafc44b9b0f8c161f5833f2 Mon Sep 17 00:00:00 2001 From: Thomas Graf Date: Sat, 22 Nov 2014 13:33:24 +0100 Subject: [PATCH 12/76] 3.6 release Signed-off-by: Thomas Graf --- NEWS | 5 +++++ README.md | 9 ++++----- configure.ac | 2 +- 3 files changed, 10 insertions(+), 6 deletions(-) diff --git a/NEWS b/NEWS index e96c0ba..3fb795e 100644 --- a/NEWS +++ b/NEWS @@ -1,3 +1,8 @@ +v3.6 - November 22, 2014 +---------------------- + * Build fix for uclinux + * Fix LICENSE links + v3.5 - August 30, 2014 ---------------------- * Fixes for all defects identified by coverity diff --git a/README.md b/README.md index bcb5b6b..b41e0bd 100644 --- a/README.md +++ b/README.md @@ -11,11 +11,10 @@ interface and a programmable text output for scripting. ## Changes -## New in v3.5 - * Fixes for all defects identified by coverity - * Fix accuracy issue on total rate calculation - * Travis-CI support - * Various other small bugfixes +## New in 3.6 +------------- + * Build fix for uclinux + * Fix LICENSE links ### Usage diff --git a/configure.ac b/configure.ac index 10388fd..18b8eef 100644 --- a/configure.ac +++ b/configure.ac @@ -21,7 +21,7 @@ # FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER # DEALINGS IN THE SOFTWARE. -AC_INIT(bmon, 3.5, [], [], [http://www.infradead.org/~tgr/bmon/]) +AC_INIT(bmon, 3.6, [], [], [http://www.infradead.org/~tgr/bmon/]) AC_CONFIG_HEADERS(include/bmon/defs.h) AC_CONFIG_AUX_DIR([build-aux]) AC_CONFIG_MACRO_DIR([m4]) From ea065c5619aefa81a17d1225e62c10b20da4632d Mon Sep 17 00:00:00 2001 From: Thomas Graf Date: Sat, 22 Nov 2014 13:40:10 +0100 Subject: [PATCH 13/76] Provide download link in README.md Signed-off-by: Thomas Graf --- README.md | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index b41e0bd..960bda7 100644 --- a/README.md +++ b/README.md @@ -8,14 +8,17 @@ statistics and prepare them visually in a human friendly way. It features various output methods including an interactive curses user interface and a programmable text output for scripting. -## Changes +## Download + * [Latest Release](https://github.com/tgraf/bmon/releases/latest) + * [Older Releases](https://github.com/tgraf/bmon/releases) -## New in 3.6 ------------- +## New in 3.6 * Build fix for uclinux * Fix LICENSE links +------------- ### Usage To run bmon in the default curses mode: From 0100916a952b40828d8d8bfd7aadaffee945c2d1 Mon Sep 17 00:00:00 2001 From: Thomas Graf Date: Tue, 16 Dec 2014 18:30:53 +0100 Subject: [PATCH 14/76] BSD: Provide minimal interface information Including: - MTU - Metric - RX/TX IRQ Quota Signed-off-by: Thomas Graf --- src/in_sysctl.c | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/src/in_sysctl.c b/src/in_sysctl.c index 6583574..ff71b4d 100644 --- a/src/in_sysctl.c +++ b/src/in_sysctl.c @@ -163,6 +163,7 @@ sysctl_read(void) struct element *e, *e_parent = NULL; struct if_msghdr *ifm, *nextifm; struct sockaddr_dl *sdl; + char info_buf[64]; ifm = (struct if_msghdr *) next; if (ifm->ifm_type != RTM_IFINFO) @@ -225,6 +226,18 @@ sysctl_read(void) attr_update(e, m->attrid, rx, tx, flags); } + snprintf(info_buf, sizeof(info_buf), "%u", ifm->ifm_data.ifi_mtu); + element_update_info(e, "MTU", info_buf); + + snprintf(info_buf, sizeof(info_buf), "%u", ifm->ifm_data.ifi_metric); + element_update_info(e, "Metric", info_buf); + + snprintf(info_buf, sizeof(info_buf), "%u", ifm->ifm_data.ifi_recvquota); + element_update_info(e, "RX-Quota", info_buf); + + snprintf(info_buf, sizeof(info_buf), "%u", ifm->ifm_data.ifi_xmitquota); + element_update_info(e, "TX-Quota", info_buf); + element_notify_update(e, NULL); element_lifesign(e, 1); } From 511e0196e100e6a503ca1a6d781e1cceebcb898f Mon Sep 17 00:00:00 2001 From: Halid Altuner Date: Thu, 8 Jan 2015 14:11:38 +0200 Subject: [PATCH 15/76] Update README.md debian installation procedures --- README.md | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/README.md b/README.md index 960bda7..728cef4 100644 --- a/README.md +++ b/README.md @@ -13,6 +13,15 @@ interface and a programmable text output for scripting. * [Latest Release](https://github.com/tgraf/bmon/releases/latest) * [Older Releases](https://github.com/tgraf/bmon/releases) +## Debian Installation + +``` +apt-get install libconfuse-dev libnl-3-dev libnl-route-3-dev +./configure +make +make install +``` + ------------- ## New in 3.6 * Build fix for uclinux From 3ecdad6f56762321e9c9e564b09d71c9492cce73 Mon Sep 17 00:00:00 2001 From: Halid Altuner Date: Thu, 8 Jan 2015 14:14:02 +0200 Subject: [PATCH 16/76] Update README.md make and build-essential package --- README.md | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index 728cef4..bd528b5 100644 --- a/README.md +++ b/README.md @@ -13,13 +13,16 @@ interface and a programmable text output for scripting. * [Latest Release](https://github.com/tgraf/bmon/releases/latest) * [Older Releases](https://github.com/tgraf/bmon/releases) -## Debian Installation +## Debian/Ubuntu Installation ``` -apt-get install libconfuse-dev libnl-3-dev libnl-route-3-dev +git clone https://github.com/tgraf/bmon.git +cd bmon +apt-get install build-essential make libconfuse-dev libnl-3-dev libnl-route-3-dev ./configure make make install +bmon ``` ------------- From 229d58c975950d954c306ee5e5b14991cab234aa Mon Sep 17 00:00:00 2001 From: Chocobo1 Date: Mon, 19 Jan 2015 20:02:14 +0800 Subject: [PATCH 17/76] using `cfg_setint` is triggering an assertion in confuse library, should use `cfg_setbool` instead --- src/bmon.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/bmon.c b/src/bmon.c index ccb9167..72ed36f 100644 --- a/src/bmon.c +++ b/src/bmon.c @@ -220,7 +220,7 @@ static int parse_args_post(int argc, char *argv[]) break; case 'a': - cfg_setint(cfg, "show_all", 1); + cfg_setbool(cfg, "show_all", cfg_true); break; case 'U': From c1ae292c9542c52f50ab1daf7394cec49960403c Mon Sep 17 00:00:00 2001 From: Thomas Graf Date: Wed, 29 Apr 2015 17:28:31 +0200 Subject: [PATCH 18/76] README: Mention ncurses-devel dependency in installation notes Reported-by: DavidRChristensen Signed-off-by: Thomas Graf --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index bd528b5..2c20d9d 100644 --- a/README.md +++ b/README.md @@ -18,7 +18,7 @@ interface and a programmable text output for scripting. ``` git clone https://github.com/tgraf/bmon.git cd bmon -apt-get install build-essential make libconfuse-dev libnl-3-dev libnl-route-3-dev +apt-get install build-essential make libconfuse-dev libnl-3-dev libnl-route-3-dev libncurses-dev ./configure make make install From 2a410be36f5380e5d986dd3bccf20466d3b5930b Mon Sep 17 00:00:00 2001 From: Thomas Graf Date: Wed, 29 Apr 2015 17:30:22 +0200 Subject: [PATCH 19/76] README: Mention that ./autogen.sh must be run after git clone Reported-by: DavidRChristensen Signed-off-by: Thomas Graf --- README.md | 1 + 1 file changed, 1 insertion(+) diff --git a/README.md b/README.md index 2c20d9d..ad53ad4 100644 --- a/README.md +++ b/README.md @@ -19,6 +19,7 @@ interface and a programmable text output for scripting. git clone https://github.com/tgraf/bmon.git cd bmon apt-get install build-essential make libconfuse-dev libnl-3-dev libnl-route-3-dev libncurses-dev +./autogen.sh ./configure make make install From c80554be16f51b908229ed345df81b760ffd4dd4 Mon Sep 17 00:00:00 2001 From: Tobias Klauser Date: Thu, 30 Apr 2015 11:27:24 +0200 Subject: [PATCH 20/76] Explicitly include linux/if.h to fix cross-compile error MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 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 --- src/in_netlink.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/in_netlink.c b/src/in_netlink.c index 7762592..8dd74fe 100644 --- a/src/in_netlink.c +++ b/src/in_netlink.c @@ -37,6 +37,8 @@ static int c_notc = 0; static struct element_group *grp; static struct bmon_module netlink_ops; +#include + #include #include #include From 5e61c5c0e4af542a0b9d33c65e601b1d08507d0e Mon Sep 17 00:00:00 2001 From: Chocobo1 Date: Sun, 31 May 2015 16:15:51 +0800 Subject: [PATCH 21/76] man page: add explaination of SI uints --- man/bmon.8 | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/man/bmon.8 b/man/bmon.8 index c94f1ba..07e0148 100644 --- a/man/bmon.8 +++ b/man/bmon.8 @@ -44,7 +44,7 @@ text mode. See OUTPUT MODULES for more details. .PP \fB \-U\fR, \fB\-\-use\-si\fR .RS 4 -Use SI unit system instead of 1KB = 1'024 bytes. +Use SI unit system (1KB = 1'000 bytes) instead of 1KB = 1'024 bytes. .RE .PP \fB \-f\fR, \fB\-\-configfile=\fRFILE From 5cecc86856f717711e05696d6202180bfe335ac8 Mon Sep 17 00:00:00 2001 From: Chocobo1 Date: Sun, 31 May 2015 16:32:51 +0800 Subject: [PATCH 22/76] Fix inconsistency in format module example --- src/out_format.c | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/src/out_format.c b/src/out_format.c index 84a5a2b..1cabf9d 100644 --- a/src/out_format.c +++ b/src/out_format.c @@ -189,8 +189,8 @@ static inline void add_token(int type, char *data) if (out_tokens == NULL) quit("Cannot reallocate out token array\n"); } - - + + out_tokens[token_index].ot_type = type; out_tokens[token_index].ot_str = data; token_index++; @@ -250,7 +250,7 @@ static int format_probe(void) } goto out; - + finish_escape: *p = '\0'; add_token(OT_STRING, s); @@ -259,7 +259,7 @@ static int format_probe(void) continue; } -out: +out: if (new_one) { add_token(OT_STRING, p); new_one = 0; @@ -328,9 +328,9 @@ static void print_help(void) " \"$(element:name) $(attr:rxrate:packets) $(attr:txrate:packets)\\n\"\n" \ " eth0 33 5\n" \ "\n" \ - " \"Element: $(element:name)\\nBytes Rate: \" \\\n" \ - " \"$(attr:rxrate:bytes)/$(attr:txrate:bytes)\\nPackets Rate: \" \\\n" \ - " \"$(attr:rxrate:packets)/$(attr:txrate:packets)\\n\"\n" \ + " \"Item: $(element:name)\\n\" \\\n" \ + " \"Bytes Rate: $(attr:rxrate:bytes)/$(attr:txrate:bytes)\\n\" \\\n" \ + " \"Packets Rate: $(attr:rxrate:packets)/$(attr:txrate:packets)\\n\"\n" \ " Item: eth0\n" \ " Bytes Rate: 49130/2119\n" \ " Packets Rate: 40/11\n" \ From 51a24c315b62acce4f2b04a410b2216742aa8b39 Mon Sep 17 00:00:00 2001 From: Chocobo1 Date: Sun, 31 May 2015 20:56:25 +0800 Subject: [PATCH 23/76] Fix wrong unit displayed when using "--use-bit" option --- src/in_netlink.c | 19 ++++++++++++++++--- 1 file changed, 16 insertions(+), 3 deletions(-) diff --git a/src/in_netlink.c b/src/in_netlink.c index 8dd74fe..d71ee9a 100644 --- a/src/in_netlink.c +++ b/src/in_netlink.c @@ -774,6 +774,17 @@ static void netlink_shutdown(void) nl_socket_free(sock); } +static void netlink_use_bit(struct attr_map *map, const int size) +{ + if(cfg_getbool(cfg, "use_bit")) { + for(int i = 0; i < size; ++i) { + if(!strcmp(map[i].description, "Bytes")) { + map[i].description = "Bits"; + } + } + } +} + static int netlink_do_init(void) { int err; @@ -798,6 +809,8 @@ static int netlink_do_init(void) goto disable; } + netlink_use_bit(link_attrs, ARRAY_SIZE(link_attrs)); + netlink_use_bit(tc_attrs, ARRAY_SIZE(tc_attrs)); if (attr_map_load(link_attrs, ARRAY_SIZE(link_attrs)) || attr_map_load(tc_attrs, ARRAY_SIZE(tc_attrs))) BUG(); @@ -819,17 +832,17 @@ static int netlink_probe(void) if (!(sock = nl_socket_alloc())) return 0; - + if (nl_connect(sock, NETLINK_ROUTE) < 0) return 0; - + if (rtnl_link_alloc_cache(sock, AF_UNSPEC, &lc) == 0) { nl_cache_free(lc); ret = 1; } nl_socket_free(sock); - + return ret; } From 29172c819cd10901f1b17b633b4ade49fcc55306 Mon Sep 17 00:00:00 2001 From: Thomas Graf Date: Tue, 30 Jun 2015 11:50:40 +0200 Subject: [PATCH 24/76] Document -b option Reported-by: Ross Patterson Signed-off-by: Thomas Graf --- man/bmon.8 | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/man/bmon.8 b/man/bmon.8 index 07e0148..dc43954 100644 --- a/man/bmon.8 +++ b/man/bmon.8 @@ -75,6 +75,11 @@ Set interval in seconds in which the rate per counter is calculated. The default is 1.0 seconds. .RE .PP +\fB \-b\fR +.RS 4 +Show rates in bits per second instead of bytes per second. +.RE +.PP \fB \-L\fR, \fB\-\-lifetime=\fRFLOAT .RS 4 Set lifetime of an element in seconds before it is no longer displayed From 21ec49ed67229fc6b0983c1c5fea876071d0ad20 Mon Sep 17 00:00:00 2001 From: Thomas Graf Date: Tue, 30 Jun 2015 11:59:48 +0200 Subject: [PATCH 25/76] format: Don't print error message for unavailable attributes Signed-off-by: Thomas Graf --- src/out_format.c | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/src/out_format.c b/src/out_format.c index 1cabf9d..ab07408 100644 --- a/src/out_format.c +++ b/src/out_format.c @@ -119,11 +119,8 @@ static char *get_token(struct element_group *g, struct element *e, goto out; } - if (!(a = attr_lookup(e, def->ad_id))) { - fprintf(stderr, "Unable to find attribute %u (%s)\n", - def->ad_id, name); + if (!(a = attr_lookup(e, def->ad_id))) goto out; - } if (!strncasecmp(type, "rx:", 3)) { snprintf(buf, len, "%" PRIu64, a->a_rx_rate.r_total); From 47547eb29ffddb9021fa9bc0dcc9fcd191e9c9d7 Mon Sep 17 00:00:00 2001 From: Thomas Graf Date: Tue, 30 Jun 2015 12:05:53 +0200 Subject: [PATCH 26/76] man: Also mention --use-bit option Signed-off-by: Thomas Graf --- man/bmon.8 | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/man/bmon.8 b/man/bmon.8 index dc43954..a4134b1 100644 --- a/man/bmon.8 +++ b/man/bmon.8 @@ -75,7 +75,7 @@ Set interval in seconds in which the rate per counter is calculated. The default is 1.0 seconds. .RE .PP -\fB \-b\fR +\fB \-b\fR, \fB\-\-use\-bit\fR .RS 4 Show rates in bits per second instead of bytes per second. .RE From 30946f2d783dc0ef0aeef3b5bc91f581fcea2fc4 Mon Sep 17 00:00:00 2001 From: Thomas Graf Date: Tue, 30 Jun 2015 12:09:54 +0200 Subject: [PATCH 27/76] bmon 3.7 release Signed-off-by: Thomas Graf --- NEWS | 6 ++++++ README.md | 7 ++++--- configure.ac | 2 +- 3 files changed, 11 insertions(+), 4 deletions(-) diff --git a/NEWS b/NEWS index 3fb795e..e86ebea 100644 --- a/NEWS +++ b/NEWS @@ -1,3 +1,9 @@ +v3.7 - November 22, 2014 +---------------------- + * Bugfixes + * Documentation updates + * Provide minimal interface information on BSD + v3.6 - November 22, 2014 ---------------------- * Build fix for uclinux diff --git a/README.md b/README.md index ad53ad4..5387fde 100644 --- a/README.md +++ b/README.md @@ -27,9 +27,10 @@ bmon ``` ------------- -## New in 3.6 - * Build fix for uclinux - * Fix LICENSE links +## New in 3.7 + * Bugfixes + * Documentation updates + * Provide minimal interface information on BSD ------------- ### Usage diff --git a/configure.ac b/configure.ac index 18b8eef..a18dd15 100644 --- a/configure.ac +++ b/configure.ac @@ -21,7 +21,7 @@ # FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER # DEALINGS IN THE SOFTWARE. -AC_INIT(bmon, 3.6, [], [], [http://www.infradead.org/~tgr/bmon/]) +AC_INIT(bmon, 3.7, [], [], [http://www.infradead.org/~tgr/bmon/]) AC_CONFIG_HEADERS(include/bmon/defs.h) AC_CONFIG_AUX_DIR([build-aux]) AC_CONFIG_MACRO_DIR([m4]) From 2027a634a72b8cb0a6e0e863c2a55b123e4cd213 Mon Sep 17 00:00:00 2001 From: Thomas Graf Date: Sat, 25 Jul 2015 10:51:47 +0200 Subject: [PATCH 28/76] 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 Signed-off-by: Thomas Graf --- src/in_netlink.c | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/src/in_netlink.c b/src/in_netlink.c index d71ee9a..683e05f 100644 --- a/src/in_netlink.c +++ b/src/in_netlink.c @@ -738,7 +738,7 @@ static void do_link(struct nl_object *obj, void *arg) attr_update(e, m->attrid, c_rx, c_tx, flags); } - if (!c_notc) + if (!c_notc && qdisc_cache) handle_tc(e, link); element_notify_update(e, NULL); @@ -754,7 +754,8 @@ static void netlink_read(void) goto disable; } - if ((err = nl_cache_resync(sock, qdisc_cache, NULL, NULL)) < 0) { + if (qdisc_cache && + (err = nl_cache_resync(sock, qdisc_cache, NULL, NULL)) < 0) { fprintf(stderr, "Unable to resync qdisc cache: %s\n", nl_geterror(err)); goto disable; } @@ -805,8 +806,9 @@ static int netlink_do_init(void) } if ((err = rtnl_qdisc_alloc_cache(sock, &qdisc_cache)) < 0) { - fprintf(stderr, "Unable to allocate qdisc cache: %s\n", nl_geterror(err)); - goto disable; + fprintf(stderr, "Warning: Unable to allocate qdisc cache: %s\n", nl_geterror(err)); + fprintf(stderr, "Disabling QoS statistics.\n"); + qdisc_cache = NULL; } netlink_use_bit(link_attrs, ARRAY_SIZE(link_attrs)); From e31a860af695c08d9863d837c9e5a61a55f969f2 Mon Sep 17 00:00:00 2001 From: Thomas Graf Date: Sat, 25 Jul 2015 11:05:01 +0200 Subject: [PATCH 29/76] Update copyright Signed-off-by: Thomas Graf --- src/bmon.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/bmon.c b/src/bmon.c index 72ed36f..dd4d464 100644 --- a/src/bmon.c +++ b/src/bmon.c @@ -120,7 +120,7 @@ void quit(const char *fmt, ...) static inline void print_version(void) { printf("bmon %s\n", PACKAGE_VERSION); - printf("Copyright (C) 2001-2013 by Thomas Graf \n"); + printf("Copyright (C) 2001-2015 by Thomas Graf \n"); printf("Copyright (C) 2013 Red Hat, Inc.\n"); printf("bmon comes with ABSOLUTELY NO WARRANTY. This is free " \ "software, and you\nare welcome to redistribute it under " \ From 964f48465a36c48adfec84430081adabf841e2aa Mon Sep 17 00:00:00 2001 From: Thomas Graf Date: Sat, 25 Jul 2015 11:10:41 +0200 Subject: [PATCH 30/76] 3.8 release Signed-off-by: Thomas Graf --- NEWS | 4 ++++ README.md | 6 ++---- configure.ac | 2 +- 3 files changed, 7 insertions(+), 5 deletions(-) diff --git a/NEWS b/NEWS index e86ebea..565485d 100644 --- a/NEWS +++ b/NEWS @@ -1,3 +1,7 @@ +v3.8 - July 25, 2015 +---------------------- + * Don't disable Netlink if TC stats are unavailable + v3.7 - November 22, 2014 ---------------------- * Bugfixes diff --git a/README.md b/README.md index 5387fde..a469646 100644 --- a/README.md +++ b/README.md @@ -27,10 +27,8 @@ bmon ``` ------------- -## New in 3.7 - * Bugfixes - * Documentation updates - * Provide minimal interface information on BSD +## New in 3.8 + * Don't disable Netlink if TC stats are unavailable ------------- ### Usage diff --git a/configure.ac b/configure.ac index a18dd15..dd879bb 100644 --- a/configure.ac +++ b/configure.ac @@ -21,7 +21,7 @@ # FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER # DEALINGS IN THE SOFTWARE. -AC_INIT(bmon, 3.7, [], [], [http://www.infradead.org/~tgr/bmon/]) +AC_INIT(bmon, 3.8, [], [], [http://www.infradead.org/~tgr/bmon/]) AC_CONFIG_HEADERS(include/bmon/defs.h) AC_CONFIG_AUX_DIR([build-aux]) AC_CONFIG_MACRO_DIR([m4]) From 665c63d4e75e0cda65e9ef52d7828ff44e028449 Mon Sep 17 00:00:00 2001 From: Tobias Klauser Date: Tue, 4 Aug 2015 14:17:03 +0200 Subject: [PATCH 31/76] 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 --- src/in_netlink.c | 59 ++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 59 insertions(+) diff --git a/src/in_netlink.c b/src/in_netlink.c index d71ee9a..2c51888 100644 --- a/src/in_netlink.c +++ b/src/in_netlink.c @@ -49,6 +49,17 @@ static struct bmon_module netlink_ops; #include #include +/* These counters are not available prior to libnl 3.2.25. Set them to -1 so + * rtnl_link_get_stat() won't be called for them. */ +#if LIBNL_CURRENT < 220 +# define RTNL_LINK_ICMP6_CSUMERRORS -1 +# define RTNL_LINK_IP6_CSUMERRORS -1 +# define RTNL_LINK_IP6_NOECTPKTS -1 +# define RTNL_LINK_IP6_ECT1PKTS -1 +# define RTNL_LINK_IP6_ECT0PKTS -1 +# define RTNL_LINK_IP6_CEPKTS -1 +#endif + static struct attr_map link_attrs[] = { { .name = "bytes", @@ -282,6 +293,14 @@ static struct attr_map link_attrs[] = { .rxid = RTNL_LINK_ICMP6_INERRORS, .txid = RTNL_LINK_ICMP6_OUTERRORS, }, +{ + .name = "icmp6csumerr", + .type = ATTR_TYPE_COUNTER, + .unit = UNIT_NUMBER, + .description = "ICMPv6 Checksum Errors", + .rxid = RTNL_LINK_ICMP6_CSUMERRORS, + .txid = -1, +}, { .name = "ip6inhdrerr", .type = ATTR_TYPE_COUNTER, @@ -322,6 +341,14 @@ static struct attr_map link_attrs[] = { .rxid = RTNL_LINK_IP6_INADDRERRORS, .txid = -1, }, +{ + .name = "ip6csumerr", + .type = ATTR_TYPE_COUNTER, + .unit = UNIT_NUMBER, + .description = "Ip6 Checksum Error", + .rxid = RTNL_LINK_IP6_CSUMERRORS, + .txid = -1, +}, { .name = "ip6reasmtimeo", .type = ATTR_TYPE_COUNTER, @@ -353,6 +380,38 @@ static struct attr_map link_attrs[] = { .description = "Ip6 Reasm/Frag Requests", .rxid = RTNL_LINK_IP6_REASMREQDS, .txid = RTNL_LINK_IP6_FRAGCREATES, +}, +{ + .name = "ip6noectpkts", + .type = ATTR_TYPE_COUNTER, + .unit = UNIT_NUMBER, + .description = "Ip6 Non-ECT Packets", + .rxid = RTNL_LINK_IP6_NOECTPKTS, + .txid = -1, +}, +{ + .name = "ip6ect1pkts", + .type = ATTR_TYPE_COUNTER, + .unit = UNIT_NUMBER, + .description = "Ip6 ECT(1) Packets", + .rxid = RTNL_LINK_IP6_ECT1PKTS, + .txid = -1, +}, +{ + .name = "ip6ect0pkts", + .type = ATTR_TYPE_COUNTER, + .unit = UNIT_NUMBER, + .description = "Ip6 ECT(0) Packets", + .rxid = RTNL_LINK_IP6_ECT0PKTS, + .txid = -1, +}, +{ + .name = "ip6cepkts", + .type = ATTR_TYPE_COUNTER, + .unit = UNIT_NUMBER, + .description = "Ip6 CE Packets", + .rxid = RTNL_LINK_IP6_CEPKTS, + .txid = -1, } }; From 9a69cb6d596413c1d80f432b3eb0362a7e42b8a7 Mon Sep 17 00:00:00 2001 From: Thomas Graf Date: Sun, 9 Aug 2015 18:05:56 +0200 Subject: [PATCH 32/76] man: Fix --ouptut typo Reported-by: xiaohuichan@gmail.com Signed-off-by: Thomas Graf --- man/bmon.8 | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/man/bmon.8 b/man/bmon.8 index a4134b1..ec4431c 100644 --- a/man/bmon.8 +++ b/man/bmon.8 @@ -34,7 +34,7 @@ in parallel. bmon automatically loads a useful and working input module by default. See INPUT MODULES for more details. .RE .PP -\fB \-o\fR, \fB\-\-ouptut\fRMODULE[:OPTIONS][,MODULE...] +\fB \-o\fR, \fB\-\-output\fRMODULE[:OPTIONS][,MODULE...] .RS 4 Set list of output modules to load and use. Multiple modules can be used in parallel. By default, bmon will use the curses output mode, if that is From f666ffd0b7a8cd247da19446fd682eb7c2f7bd46 Mon Sep 17 00:00:00 2001 From: Thomas Graf Date: Wed, 16 Dec 2015 14:00:39 +0100 Subject: [PATCH 33/76] 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 --- src/out_curses.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/out_curses.c b/src/out_curses.c index c973789..d5443fc 100644 --- a/src/out_curses.c +++ b/src/out_curses.c @@ -137,7 +137,7 @@ static void apply_layout(int layout) attrset(cfg_layout[layout].l_attr); } -char *float2str(double value, int width, int prec, char *buf, size_t len) +static char *float2str(double value, int width, int prec, char *buf, size_t len) { snprintf(buf, len, "%'*.*f", width, value == 0.0f ? 0 : prec, value); From 0641291ad54ff6fefdaf867ac099998a27126c79 Mon Sep 17 00:00:00 2001 From: Thomas Graf Date: Wed, 16 Dec 2015 14:01:51 +0100 Subject: [PATCH 34/76] 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 --- src/out_curses.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/out_curses.c b/src/out_curses.c index d5443fc..05b4c45 100644 --- a/src/out_curses.c +++ b/src/out_curses.c @@ -430,7 +430,7 @@ static void draw_statusbar(void) { static const char *help_text = "Press ? for help"; char s[27]; - time_t t = time(0); + time_t t = time(NULL); apply_layout(LAYOUT_STATUSBAR); From 753a9e09ddcfbaa5bc480708e03c83bc6f4c824a Mon Sep 17 00:00:00 2001 From: Thomas Graf Date: Wed, 16 Dec 2015 14:04:14 +0100 Subject: [PATCH 35/76] 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 --- src/bmon.c | 15 +-------------- 1 file changed, 1 insertion(+), 14 deletions(-) diff --git a/src/bmon.c b/src/bmon.c index dd4d464..749ebbf 100644 --- a/src/bmon.c +++ b/src/bmon.c @@ -33,8 +33,6 @@ #include int start_time; -int do_quit = 0; -int is_daemon = 0; struct reader_timing rtiming; @@ -88,14 +86,7 @@ static void do_shutdown(void) } } -RETSIGTYPE sig_int(int unused) -{ - if (do_quit) - exit(-1); - do_quit = 1; -} - -void sig_exit(void) +static void sig_exit(void) { do_shutdown(); } @@ -361,9 +352,6 @@ int main(int argc, char *argv[]) output_post(); } - if (do_quit) - exit(0); - /* * ST := Configured ST */ @@ -399,5 +387,4 @@ int main(int argc, char *argv[]) static void __init bmon_init(void) { atexit(&sig_exit); - //signal(SIGINT, &sig_int); } From 4488cd03f986315cd24114b96a7a5eef56052da4 Mon Sep 17 00:00:00 2001 From: Thomas Graf Date: Wed, 16 Dec 2015 14:09:35 +0100 Subject: [PATCH 36/76] bmon: Properly pass NULL pointers instead of 0 Signed-off-by: Thomas Graf --- src/bmon.c | 32 ++++++++++++++++---------------- src/in_dummy.c | 2 +- 2 files changed, 17 insertions(+), 17 deletions(-) diff --git a/src/bmon.c b/src/bmon.c index 749ebbf..9fa684c 100644 --- a/src/bmon.c +++ b/src/bmon.c @@ -127,10 +127,10 @@ static void parse_args_pre(int argc, char *argv[]) char *gostr = "+:hvVf:"; struct option long_opts[] = { - {"help", 0, 0, 'h'}, - {"version", 0, 0, 'v'}, - {"configfile", 1, 0, 'f'}, - {0, 0, 0, 0}, + {"help", 0, NULL, 'h'}, + {"version", 0, NULL, 'v'}, + {"configfile", 1, NULL, 'f'}, + {NULL, 0, NULL, 0}, }; int c = getopt_long(argc, argv, gostr, long_opts, NULL); if (c == -1) @@ -166,17 +166,17 @@ static int parse_args_post(int argc, char *argv[]) "L:hvVf:"; struct option long_opts[] = { - {"input", 1, 0, 'i'}, - {"output", 1, 0, 'o'}, - {"policy", 1, 0, 'p'}, - {"read-interval", 1, 0, 'r'}, - {"rate-interval", 1, 0, 'R'}, - {"sleep-interval", 1, 0, 's'}, - {"show-all", 0, 0, 'a'}, - {"use-si", 0, 0, 'U'}, - {"use-bit", 0, 0, 'b'}, - {"lifetime", 1, 0, 'L'}, - {0, 0, 0, 0}, + {"input", 1, NULL, 'i'}, + {"output", 1, NULL, 'o'}, + {"policy", 1, NULL, 'p'}, + {"read-interval", 1, NULL, 'r'}, + {"rate-interval", 1, NULL, 'R'}, + {"sleep-interval", 1, NULL, 's'}, + {"show-all", 0, NULL, 'a'}, + {"use-si", 0, NULL, 'U'}, + {"use-bit", 0, NULL, 'b'}, + {"lifetime", 1, NULL, 'L'}, + {NULL, 0, NULL, 0}, }; int c = getopt_long(argc, argv, gostr, long_opts, NULL); if (c == -1) @@ -261,7 +261,7 @@ int main(int argc, char *argv[]) unsigned long sleep_time; double read_interval; - start_time = time(0); + start_time = time(NULL); memset(&rtiming, 0, sizeof(rtiming)); rtiming.rt_variance.v_min = FLT_MAX; diff --git a/src/in_dummy.c b/src/in_dummy.c index 9cf2c05..6b5b135 100644 --- a/src/in_dummy.c +++ b/src/in_dummy.c @@ -185,7 +185,7 @@ static void dummy_parse_opt(const char *type, const char *value) c_numdev = strtol(value, NULL, 0); else if (!strcasecmp(type, "randomize")) { c_randomize = 1; - srand(time(0)); + srand(time(NULL)); } else if (!strcasecmp(type, "seed") && value) srand(strtol(value, NULL, 0)); else if (!strcasecmp(type, "mtu") && value) From 892bdac762f80000e8ee0c27d768f37fce0c53c5 Mon Sep 17 00:00:00 2001 From: Thomas Graf Date: Wed, 16 Dec 2015 14:10:43 +0100 Subject: [PATCH 37/76] 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 --- src/attr.c | 2 +- src/element.c | 5 +++-- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/src/attr.c b/src/attr.c index bd001eb..297fc2b 100644 --- a/src/attr.c +++ b/src/attr.c @@ -111,7 +111,7 @@ int attr_def_add(const char *name, const char *desc, struct unit *unit, return def->ad_id; } -void attr_def_free(struct attr_def *def) +static void attr_def_free(struct attr_def *def) { if (!def) return; diff --git a/src/element.c b/src/element.c index f7c569b..d71a337 100644 --- a/src/element.c +++ b/src/element.c @@ -113,8 +113,9 @@ void element_parse_policy(const char *policy) xfree(copy); } -struct element *__lookup_element(struct element_group *group, const char *name, - uint32_t id, struct element *parent) +static struct element *__lookup_element(struct element_group *group, + const char *name, uint32_t id, + struct element *parent) { struct list_head *list; struct element *e; From f9c714fa1503179896c55ccb5f918e6c5d6cd5f5 Mon Sep 17 00:00:00 2001 From: Thomas Graf Date: Wed, 16 Dec 2015 15:36:03 +0100 Subject: [PATCH 38/76] 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 --- src/in_netlink.c | 23 +++++++++++++++-------- 1 file changed, 15 insertions(+), 8 deletions(-) diff --git a/src/in_netlink.c b/src/in_netlink.c index 84a841a..43019d3 100644 --- a/src/in_netlink.c +++ b/src/in_netlink.c @@ -491,12 +491,13 @@ static struct attr_map tc_attrs[] = { }; struct rdata { + struct nl_cache * class_cache; struct element * parent; int level; }; static struct nl_sock *sock; -static struct nl_cache *link_cache, *qdisc_cache, *class_cache; +static struct nl_cache *link_cache, *qdisc_cache; static void update_tc_attrs(struct element *e, struct rtnl_tc *tc) { @@ -531,10 +532,10 @@ static void update_tc_infos(struct element *e, struct rtnl_tc *tc) static void handle_qdisc(struct nl_object *obj, void *); static void find_classes(uint32_t, struct rdata *); -static void find_qdiscs(uint32_t, struct rdata *); +static void find_qdiscs(int, uint32_t, struct rdata *); static struct element *handle_tc_obj(struct rtnl_tc *tc, const char *prefix, - struct rdata *rdata) + const struct rdata *rdata) { char buf[IFNAME_MAX], name[IFNAME_MAX]; uint32_t id = rtnl_tc_get_handle(tc); @@ -579,8 +580,9 @@ static void handle_class(struct nl_object *obj, void *arg) { struct rtnl_tc *tc = (struct rtnl_tc *) obj; struct element *e; - struct rdata *rdata = arg; + const struct rdata *rdata = arg; struct rdata ndata = { + .class_cache = rdata->class_cache, .level = rdata->level + 1, }; @@ -593,10 +595,10 @@ static void handle_class(struct nl_object *obj, void *arg) element_set_txmax(e, rtnl_htb_get_rate((struct rtnl_class *) tc)); find_classes(rtnl_tc_get_handle(tc), &ndata); - find_qdiscs(rtnl_tc_get_handle(tc), &ndata); + find_qdiscs(rtnl_tc_get_ifindex(tc), rtnl_tc_get_handle(tc), &ndata); } -static void find_qdiscs(uint32_t parent, struct rdata *rdata) +static void find_qdiscs(int ifindex, uint32_t parent, struct rdata *rdata) { struct rtnl_qdisc *filter; @@ -604,6 +606,7 @@ static void find_qdiscs(uint32_t parent, struct rdata *rdata) return; rtnl_tc_set_parent((struct rtnl_tc *) filter, parent); + rtnl_tc_set_ifindex((struct rtnl_tc *) filter, ifindex); nl_cache_foreach_filter(qdisc_cache, OBJ_CAST(filter), handle_qdisc, rdata); @@ -632,7 +635,7 @@ static void find_classes(uint32_t parent, struct rdata *rdata) rtnl_tc_set_parent((struct rtnl_tc *) filter, parent); - nl_cache_foreach_filter(class_cache, OBJ_CAST(filter), + nl_cache_foreach_filter(rdata->class_cache, OBJ_CAST(filter), handle_class, rdata); rtnl_class_put(filter); @@ -642,8 +645,9 @@ static void handle_qdisc(struct nl_object *obj, void *arg) { struct rtnl_tc *tc = (struct rtnl_tc *) obj; struct element *e; - struct rdata *rdata = arg; + const struct rdata *rdata = arg; struct rdata ndata = { + .class_cache = rdata->class_cache, .level = rdata->level + 1, }; @@ -665,6 +669,7 @@ static void handle_qdisc(struct nl_object *obj, void *arg) static void handle_tc(struct element *e, struct rtnl_link *link) { struct rtnl_qdisc *qdisc; + struct nl_cache *class_cache; int ifindex = rtnl_link_get_ifindex(link); struct rdata rdata = { .level = 1, @@ -674,6 +679,8 @@ static void handle_tc(struct element *e, struct rtnl_link *link) if (rtnl_class_alloc_cache(sock, ifindex, &class_cache) < 0) return; + rdata.class_cache = class_cache; + qdisc = rtnl_qdisc_get_by_parent(qdisc_cache, ifindex, TC_H_ROOT); if (qdisc) { handle_qdisc(OBJ_CAST(qdisc), &rdata); From a0eea59519e3f89a5cbc097ec350566103728069 Mon Sep 17 00:00:00 2001 From: Thomas Graf Date: Wed, 16 Dec 2015 15:38:39 +0100 Subject: [PATCH 39/76] 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 --- src/in_netlink.c | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/src/in_netlink.c b/src/in_netlink.c index 43019d3..ef98ae0 100644 --- a/src/in_netlink.c +++ b/src/in_netlink.c @@ -545,11 +545,14 @@ static struct element *handle_tc_obj(struct rtnl_tc *tc, const char *prefix, snprintf(name, sizeof(name), "%s %s (%s)", prefix, buf, rtnl_tc_get_kind(tc)); - if (!(e = element_lookup(grp, name, id, rdata ? rdata->parent : NULL, ELEMENT_CREAT))) + if (!rdata || !rdata->parent) + BUG(); + + if (!(e = element_lookup(grp, name, id, rdata->parent, ELEMENT_CREAT))) return NULL; if (e->e_flags & ELEMENT_FLAG_CREATED) { - e->e_level = rdata ? rdata->level : 0; + e->e_level = rdata->level; if (element_set_key_attr(e, "tc_bytes", "tc_packets") || element_set_usage_attr(e, "tc_bytes")) From 8dcd666db615694e43fd89113e5465b376768b79 Mon Sep 17 00:00:00 2001 From: Thomas Graf Date: Wed, 16 Dec 2015 15:55:20 +0100 Subject: [PATCH 40/76] travis: Switch to trusty ubuntu distro Signed-off-by: Thomas Graf --- .travis.yml | 2 ++ 1 file changed, 2 insertions(+) diff --git a/.travis.yml b/.travis.yml index de9b0f7..5a205a3 100644 --- a/.travis.yml +++ b/.travis.yml @@ -1,3 +1,5 @@ +sudo: required +dist: trusty language: c compiler: - gcc From cbcdab6669dc690230c6ce24e0ca8a91355079bf Mon Sep 17 00:00:00 2001 From: Chocobo1 Date: Tue, 26 Jan 2016 01:23:19 +0800 Subject: [PATCH 41/76] TravisCI: fix script, add OSX builds --- .travis.yml | 31 +++++++++++++++++++++++-------- 1 file changed, 23 insertions(+), 8 deletions(-) diff --git a/.travis.yml b/.travis.yml index 5a205a3..9c6c8eb 100644 --- a/.travis.yml +++ b/.travis.yml @@ -1,12 +1,27 @@ -sudo: required -dist: trusty language: c + +os: + - linux + - osx + compiler: - gcc - clang -before_install: - - sudo apt-get install libconfuse-dev - - sudo apt-get install libnl-3-dev libnl-route-3-dev - - sudo apt-get install libncurses-dev -# Change this to your needs -script: ./.travis/run.sh + +# container-based builds +sudo: false +addons: + apt: + packages: + # packages list: https://github.com/travis-ci/apt-package-whitelist/blob/master/ubuntu-precise + - libconfuse-dev + - libncurses5-dev + - libnl-3-dev + - libnl-route-3-dev + + +install: + - if [ "$TRAVIS_OS_NAME" = "osx" ]; then brew update > /dev/null && brew install confuse ; fi + +script: + - ./.travis/run.sh From 67b6ee3bd6f02fbfe23052d3c05ac93efc348441 Mon Sep 17 00:00:00 2001 From: Chocobo1 Date: Tue, 26 Jan 2016 01:41:25 +0800 Subject: [PATCH 42/76] TravisCI: merge config for coverity scan --- .travis.yml | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/.travis.yml b/.travis.yml index 9c6c8eb..bac4cb1 100644 --- a/.travis.yml +++ b/.travis.yml @@ -4,6 +4,10 @@ os: - linux - osx +env: + global: + - secure: "C87Pgf5AVDoyQfm9MIv81g" + compiler: - gcc - clang @@ -18,9 +22,18 @@ addons: - libncurses5-dev - libnl-3-dev - libnl-route-3-dev + coverity_scan: + project: + name: "tgraf/bmon" + description: "bandwidth monitor" + notification_email: tgraf@suug.ch + build_command_prepend: "./autogen.sh && ./configure" + build_command: "make -j2" + branch_pattern: coverity_scan install: + - if [ "$TRAVIS_BRANCH" = "coverity_scan" ] && ! [ "$TRAVIS_OS_NAME" = "linux" -a "$CC" = "gcc" ]; then exit ; fi - if [ "$TRAVIS_OS_NAME" = "osx" ]; then brew update > /dev/null && brew install confuse ; fi script: From 4efaa8ce9e82777d1208688e5bad833043587d81 Mon Sep 17 00:00:00 2001 From: Thomas Graf Date: Fri, 29 Jan 2016 12:11:44 +0100 Subject: [PATCH 43/76] 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 --- include/bmon/attr.h | 6 ++++++ src/attr.c | 13 +++++++++++++ src/out_ascii.c | 4 ++-- src/out_curses.c | 19 +++++++++++++++++-- src/out_format.c | 4 ++-- 5 files changed, 40 insertions(+), 6 deletions(-) diff --git a/include/bmon/attr.h b/include/bmon/attr.h index 224f151..9d52c78 100644 --- a/include/bmon/attr.h +++ b/include/bmon/attr.h @@ -42,6 +42,9 @@ struct rate /* Value of r_current at last read */ uint64_t r_prev; + /* Reset value to substract to emulate statistics reset */ + uint64_t r_reset; + /* Rate per second calculated every `rate_interval' */ float r_rate; @@ -49,6 +52,8 @@ struct rate timestamp_t r_last_calc; }; +extern uint64_t rate_get_total(struct rate *); + enum { ATTR_TYPE_UNSPEC, ATTR_TYPE_COUNTER, @@ -134,5 +139,6 @@ extern struct attr * attr_select_prev(void); extern struct attr * attr_current(void); extern void attr_start_collecting_history(struct attr *); +extern void attr_reset_counter(struct attr *a); #endif diff --git a/src/attr.c b/src/attr.c index 297fc2b..cb33bb5 100644 --- a/src/attr.c +++ b/src/attr.c @@ -524,6 +524,11 @@ static float __calc_usage(double rate, uint64_t max) return 100.0f / ((double) max / (rate * cfg_rate_interval)); } +uint64_t rate_get_total(struct rate *r) +{ + return r->r_total - r->r_reset; +} + void attr_calc_usage(struct attr *a, float *rx, float *tx, uint64_t rxmax, uint64_t txmax) { @@ -626,6 +631,14 @@ void attr_notify_update(struct attr *a, timestamp_t *ts) } } +void attr_reset_counter(struct attr *a) +{ + if (a->a_def->ad_type == ATTR_TYPE_COUNTER) { + a->a_rx_rate.r_reset = a->a_rx_rate.r_total; + a->a_tx_rate.r_reset = a->a_tx_rate.r_total; + } +} + static void __exit attr_exit(void) { struct attr_def *ad, *n; diff --git a/src/out_ascii.c b/src/out_ascii.c index b3e8d2d..c9d2e91 100644 --- a/src/out_ascii.c +++ b/src/out_ascii.c @@ -101,10 +101,10 @@ static void print_attr_detail(struct element *e, struct attr *a, void *arg) char *rx_u, *tx_u; int rxprec, txprec; - double rx = unit_value2str(a->a_rx_rate.r_total, + double rx = unit_value2str(rate_get_total(&a->a_rx_rate), a->a_def->ad_unit, &rx_u, &rxprec); - double tx = unit_value2str(a->a_tx_rate.r_total, + double tx = unit_value2str(rate_get_total(&a->a_tx_rate), a->a_def->ad_unit, &tx_u, &txprec); diff --git a/src/out_curses.c b/src/out_curses.c index 05b4c45..670be75 100644 --- a/src/out_curses.c +++ b/src/out_curses.c @@ -241,10 +241,10 @@ static void draw_attr_detail(struct element *e, struct attr *a, void *arg) int rxprec, txprec, ncol; struct detail_arg *da = arg; - double rx = unit_value2str(a->a_rx_rate.r_total, + double rx = unit_value2str(rate_get_total(&a->a_rx_rate), a->a_def->ad_unit, &rx_u, &rxprec); - double tx = unit_value2str(a->a_tx_rate.r_total, + double tx = unit_value2str(rate_get_total(&a->a_tx_rate), a->a_def->ad_unit, &tx_u, &txprec); @@ -392,6 +392,7 @@ static void draw_help(void) mvaddnstr(y+15, x+3, "H Start recording history data", -1); mvaddnstr(y+16, x+3, "TAB Switch time unit of graph", -1); mvaddnstr(y+17, x+3, "<, > Change number of graphs", -1); + mvaddnstr(y+18, x+3, "r Reset counter of element", -1); attroff(A_STANDOUT); @@ -1079,6 +1080,16 @@ static void curses_draw(void) refresh(); } +static void __reset_attr_counter(struct element *e, struct attr *a, void *arg) +{ + attr_reset_counter(a); +} + +static void reset_counters(void) +{ + element_foreach_attr(current_element, __reset_attr_counter, NULL); +} + static int handle_input(int ch) { switch (ch) @@ -1198,6 +1209,10 @@ static int handle_input(int ch) case '\t': history_select_next(); return 1; + + case 'r': + reset_counters(); + return 1; } return 0; diff --git a/src/out_format.c b/src/out_format.c index ab07408..d9d5e36 100644 --- a/src/out_format.c +++ b/src/out_format.c @@ -123,10 +123,10 @@ static char *get_token(struct element_group *g, struct element *e, goto out; if (!strncasecmp(type, "rx:", 3)) { - snprintf(buf, len, "%" PRIu64, a->a_rx_rate.r_total); + snprintf(buf, len, "%" PRIu64, rate_get_total(&a->a_rx_rate)); return buf; } else if (!strncasecmp(type, "tx:", 3)) { - snprintf(buf, len, "%" PRIu64, a->a_tx_rate.r_total); + snprintf(buf, len, "%" PRIu64, rate_get_total(&a->a_tx_rate)); return buf; } else if (!strncasecmp(type, "rxrate:", 7)) { snprintf(buf, len, "%.2f", a->a_rx_rate.r_rate); From 0103671f1f3dae63dc9d17ce5cb18183871fef9c Mon Sep 17 00:00:00 2001 From: Thomas Graf Date: Fri, 29 Jan 2016 18:15:47 +0100 Subject: [PATCH 44/76] Check for presence of pkg-config in configure Signed-off-by: Thomas Graf --- configure.ac | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/configure.ac b/configure.ac index dd879bb..a81b792 100644 --- a/configure.ac +++ b/configure.ac @@ -62,6 +62,14 @@ AC_CHECK_FUNCS(atexit gettimeofday memset pow socket strcasecmp) AC_CHECK_FUNCS(strchr strdup strerror strncasecmp strstr strtol) AC_CHECK_FUNCS(uname getdate) +AC_PATH_PROG([PKG_CONFIG], [pkg-config], [no]) +AS_IF([test "x$PKG_CONFIG" = "xno"],[ + AC_MSG_ERROR([ + *** The pkg-config script could not be found. Make sure it is + *** in your path, or set the PKG_CONFIG environment variable + *** to the full path to pkg-config.]) + ]) + AX_WITH_CURSES if test "x$ax_cv_curses" != xyes || test "x$ax_cv_curses_color" != xyes; then AC_MSG_ERROR([requires an X/Open-compatible Curses library with color]) From fa6abf3a80eeafe9b70ffd3c5d0541963b21b9c4 Mon Sep 17 00:00:00 2001 From: Benny Siegert Date: Sat, 26 Mar 2016 21:40:07 +0100 Subject: [PATCH 45/76] NetBSD does not have send or receive quotas. --- src/in_sysctl.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/in_sysctl.c b/src/in_sysctl.c index ff71b4d..595e4f4 100644 --- a/src/in_sysctl.c +++ b/src/in_sysctl.c @@ -232,11 +232,13 @@ sysctl_read(void) snprintf(info_buf, sizeof(info_buf), "%u", ifm->ifm_data.ifi_metric); element_update_info(e, "Metric", info_buf); +#ifndef __NetBSD__ snprintf(info_buf, sizeof(info_buf), "%u", ifm->ifm_data.ifi_recvquota); element_update_info(e, "RX-Quota", info_buf); snprintf(info_buf, sizeof(info_buf), "%u", ifm->ifm_data.ifi_xmitquota); element_update_info(e, "TX-Quota", info_buf); +#endif element_notify_update(e, NULL); element_lifesign(e, 1); From 74770b880692a97b74e971825a7f2f445b0f2aa5 Mon Sep 17 00:00:00 2001 From: Benny Siegert Date: Sat, 26 Mar 2016 21:42:05 +0100 Subject: [PATCH 46/76] Use uintmax_t cast for some printfs. Some of the BSDs have 32-bit, some 64-bit vars for this. --- src/in_sysctl.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/in_sysctl.c b/src/in_sysctl.c index 595e4f4..faf647a 100644 --- a/src/in_sysctl.c +++ b/src/in_sysctl.c @@ -226,10 +226,10 @@ sysctl_read(void) attr_update(e, m->attrid, rx, tx, flags); } - snprintf(info_buf, sizeof(info_buf), "%u", ifm->ifm_data.ifi_mtu); + snprintf(info_buf, sizeof(info_buf), "%ju", (uintmax_t)ifm->ifm_data.ifi_mtu); element_update_info(e, "MTU", info_buf); - snprintf(info_buf, sizeof(info_buf), "%u", ifm->ifm_data.ifi_metric); + snprintf(info_buf, sizeof(info_buf), "%ju", (uintmax_t)ifm->ifm_data.ifi_metric); element_update_info(e, "Metric", info_buf); #ifndef __NetBSD__ From f78c0e5b98a45dcd142e4b7bef1d42cb23064239 Mon Sep 17 00:00:00 2001 From: Thomas Graf Date: Tue, 29 Mar 2016 12:22:56 +0200 Subject: [PATCH 47/76] Add 'info' option to show additional info screen by default Suggested-by: @Berzerker Signed-off-by: Thomas Graf --- src/out_curses.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/out_curses.c b/src/out_curses.c index 670be75..7b8bc7a 100644 --- a/src/out_curses.c +++ b/src/out_curses.c @@ -1257,6 +1257,7 @@ static void print_module_help(void) " nocolors Do not use colors\n" \ " graph Show graphical stats by default\n" \ " details Show detailed stats by default\n" \ + " info Show additional info screen by default\n" \ " minlist=INT Minimum item list length\n"); } @@ -1279,6 +1280,8 @@ static void curses_parse_opt(const char *type, const char *value) c_show_graph = !!c_ngraph; } else if (!strcasecmp(type, "details")) c_show_details = 1; + else if (!strcasecmp(type, "info")) + c_show_info = 1; else if (!strcasecmp(type, "nocolors")) c_use_colors = 0; else if (!strcasecmp(type, "minlist") && value) From a6c635dc96845bd864e8677ff67529fcf65dc1d5 Mon Sep 17 00:00:00 2001 From: Berzerker Date: Tue, 29 Mar 2016 17:28:24 -0400 Subject: [PATCH 48/76] Update Readme to include additional dependencies pkg-config and dh-autoreconf are required packages for proper configuration --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index a469646..df4dab3 100644 --- a/README.md +++ b/README.md @@ -18,7 +18,7 @@ interface and a programmable text output for scripting. ``` git clone https://github.com/tgraf/bmon.git cd bmon -apt-get install build-essential make libconfuse-dev libnl-3-dev libnl-route-3-dev libncurses-dev +apt-get install build-essential make libconfuse-dev libnl-3-dev libnl-route-3-dev libncurses-dev pkg-config dh-autoreconf ./autogen.sh ./configure make From 19c35e4990acf264824169a881656ed17088a3b5 Mon Sep 17 00:00:00 2001 From: yamadapc Date: Wed, 20 Apr 2016 10:35:41 -0300 Subject: [PATCH 49/76] Add OSX install instructions I'm not sure if this is universal, but this worked for installing on El Capitan here. --- README.md | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) diff --git a/README.md b/README.md index df4dab3..2e477e3 100644 --- a/README.md +++ b/README.md @@ -26,6 +26,27 @@ make install bmon ``` +## OSX Installation +Install libconfuse +``` +wget https://github.com/martinh/libconfuse/releases/download/v2.8/confuse-2.8.zip +unzip confuse-2.8.zip && cd confuse-2.8 +PATH=/usr/local/opt/gettext/bin:$PATH ./configure +make +make install +``` + +Install bmon +``` +git clone https://github.com/tgraf/bmon.git +cd bmon +./autogen.sh +./configure +make +make install +bmon +``` + ------------- ## New in 3.8 * Don't disable Netlink if TC stats are unavailable From f177718f24c050c458f9ec8f944a8f2cea92b372 Mon Sep 17 00:00:00 2001 From: Tobias Klauser Date: Thu, 28 Apr 2016 16:11:30 +0200 Subject: [PATCH 50/76] format: Add missing braces around 'if' clause MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 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 --- src/out_format.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/out_format.c b/src/out_format.c index d9d5e36..aea38c5 100644 --- a/src/out_format.c +++ b/src/out_format.c @@ -131,9 +131,10 @@ static char *get_token(struct element_group *g, struct element *e, } else if (!strncasecmp(type, "rxrate:", 7)) { snprintf(buf, len, "%.2f", a->a_rx_rate.r_rate); return buf; - } else if (!strncasecmp(token+5, "txrate:", 7)) + } else if (!strncasecmp(type, "txrate:", 7)) { snprintf(buf, len, "%.2f", a->a_tx_rate.r_rate); return buf; + } } fprintf(stderr, "Unknown field \"%s\"\n", token); From 828b5b5368bc5054b16a2504fcbb7a7e77087598 Mon Sep 17 00:00:00 2001 From: blastmaster Date: Sat, 16 Jul 2016 01:53:42 +0200 Subject: [PATCH 51/76] 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] --- examples/bmon.conf | 24 ++++++++ include/bmon/conf.h | 2 + include/bmon/layout.h | 128 ++++++++++++++++++++++++++++++++++++++++++ src/conf.c | 100 +++++++++++++++++++++++++++++---- src/out_curses.c | 17 ++++-- 5 files changed, 253 insertions(+), 18 deletions(-) create mode 100644 include/bmon/layout.h diff --git a/examples/bmon.conf b/examples/bmon.conf index 389b054..93d64c3 100644 --- a/examples/bmon.conf +++ b/examples/bmon.conf @@ -86,3 +86,27 @@ history day { interval = 86400. size = 60 } + +layout colors { + color default { + color_pair = {"white", "black"} + } + color statusbar { + color_pair = {"blue", "white", "reverse"} + } + color header { + color_pair = {"yellow", "black"} + } + color list { + color_pair = {"white", "black"} + } + color selected { + color_pair = {"white", "black", "reverse"} + } + color RX_graph { + color_pair = {"green", "black"} + } + color TX_graph { + color_pair = {"red", "black"} + } +} diff --git a/include/bmon/conf.h b/include/bmon/conf.h index f95d48f..6f248af 100644 --- a/include/bmon/conf.h +++ b/include/bmon/conf.h @@ -74,6 +74,8 @@ enum { LAYOUT_HEADER, LAYOUT_LIST, LAYOUT_SELECTED, + LAYOUT_RX_GRAPH, + LAYOUT_TX_GRAPH, __LAYOUT_MAX }; diff --git a/include/bmon/layout.h b/include/bmon/layout.h new file mode 100644 index 0000000..cca2a4c --- /dev/null +++ b/include/bmon/layout.h @@ -0,0 +1,128 @@ + +#ifndef __BMON_LAYOUT_H_ +#define __BMON_LAYOUT_H_ + +#include +#include +#include +#include + + +static int parse_color(const char* color) +{ + int color_code = -1; + + if ((strcasestr(color, "red") != NULL)) + color_code = COLOR_RED; + else if ((strcasestr(color, "green") != NULL)) + color_code = COLOR_GREEN; + else if ((strcasestr(color, "white") != NULL)) + color_code = COLOR_WHITE; + else if ((strcasestr(color, "black") != NULL)) + color_code = COLOR_BLACK; + else if ((strcasestr(color, "blue") != NULL)) + color_code = COLOR_BLUE; + else if ((strcasestr(color, "yellow") != NULL)) + color_code = COLOR_YELLOW; + else if ((strcasestr(color, "magenta") != NULL)) + color_code = COLOR_MAGENTA; + else if ((strcasestr(color, "cyan") != NULL)) + color_code = COLOR_CYAN; + + return color_code; +} + +/* + A_NORMAL Normal display (no highlight) + A_STANDOUT Best highlighting mode of the terminal. + A_UNDERLINE Underlining + A_REVERSE Reverse video + A_BLINK Blinking + A_DIM Half bright + A_BOLD Extra bright or bold + A_PROTECT Protected mode + A_INVIS Invisible or blank mode + A_ALTCHARSET Alternate character set + A_CHARTEXT Bit-mask to extract a character +*/ + +static int parse_attribute(const char* attr) +{ + /* no attribute is valid, so we have nothing to do */ + if (attr == NULL) + return 0; + + if ((strcasestr(attr, "normal") != NULL)) + return A_NORMAL; + else if ((strcasestr(attr, "standout") != NULL)) + return A_STANDOUT; + else if ((strcasestr(attr, "underline") != NULL)) + return A_UNDERLINE; + else if ((strcasestr(attr, "reverse") != NULL)) + return A_REVERSE; + else if ((strcasestr(attr, "blink") != NULL)) + return A_BLINK; + else if ((strcasestr(attr, "dim") != NULL)) + return A_DIM; + else if ((strcasestr(attr, "bold") != NULL)) + return A_BOLD; + else if ((strcasestr(attr, "protect") != NULL)) + return A_PROTECT; + else if ((strcasestr(attr, "invis") != NULL)) + return A_INVIS; + else if ((strcasestr(attr, "altcharset") != NULL)) + return A_ALTCHARSET; + else if ((strcasestr(attr, "chartext") != NULL)) + return A_CHARTEXT; + + return -1; +} + + +static void add_layout(const char *layout_name, cfg_t *color_cfg) +{ + const char *fg, *bg, *attr_str = NULL; + int size = -1, fg_code, bg_code, attr_mask, layout_idx = 0; + + size = cfg_size(color_cfg, "color_pair"); + fg = cfg_getnstr(color_cfg, "color_pair", 0); + bg = cfg_getnstr(color_cfg, "color_pair", 1); + if (size > 2) + attr_str = cfg_getnstr(color_cfg, "color_pair", 2); + + fg_code = parse_color(fg); + bg_code = parse_color(bg); + if (fg_code == -1 || bg_code == -1) { + quit("Unknown color [%s]: %s\n", (fg_code == -1) ? "fg" : "bg", + (fg_code == -1) ? fg : bg); + } + attr_mask = parse_attribute(attr_str); + if (attr_mask == -1) { + quit("Unknown attribute: '%s'\n", attr_str); + } + + DBG("%s:\tfg: %s bg: %s attr: %s\n", layout_name, fg, bg, attr_str); + + if ((strcasecmp(layout_name, "default") == 0)) + layout_idx = LAYOUT_DEFAULT; + else if ((strcasecmp(layout_name, "statusbar") == 0)) + layout_idx = LAYOUT_STATUSBAR; + else if ((strcasecmp(layout_name, "header") == 0)) + layout_idx = LAYOUT_HEADER; + else if ((strcasecmp(layout_name, "list") == 0)) + layout_idx = LAYOUT_LIST; + else if ((strcasecmp(layout_name, "selected") == 0)) + layout_idx = LAYOUT_SELECTED; + else if ((strcasecmp(layout_name, "rx_graph") == 0)) + layout_idx = LAYOUT_RX_GRAPH; + else if ((strcasecmp(layout_name, "tx_graph") == 0)) + layout_idx = LAYOUT_TX_GRAPH; + else { + quit("Unknown layout name: '%s'\n", layout_name); + } + + struct layout l = { fg_code, bg_code, attr_mask}; + cfg_layout[layout_idx] = l; +} + +#endif /* __BMON_LAYOUT_H_ */ diff --git a/src/conf.c b/src/conf.c index d85e9f6..c61fcf8 100644 --- a/src/conf.c +++ b/src/conf.c @@ -30,6 +30,7 @@ #include #include #include +#include #include cfg_t *cfg; @@ -69,6 +70,16 @@ static cfg_opt_t unit_opts[] = { CFG_END() }; +static cfg_opt_t color_opts[] = { + CFG_STR_LIST("color_pair", "", CFGF_NONE), + CFG_END() +}; + +static cfg_opt_t layout_opts[] = { + CFG_SEC("color", color_opts, CFGF_MULTI | CFGF_TITLE), + CFG_END() +}; + static cfg_opt_t global_opts[] = { CFG_FLOAT("read_interval", 1.0f, CFGF_NONE), CFG_FLOAT("rate_interval", 1.0f, CFGF_NONE), @@ -87,6 +98,7 @@ static cfg_opt_t global_opts[] = { CFG_SEC("attr", attr_opts, CFGF_MULTI | CFGF_TITLE), CFG_SEC("history", history_opts, CFGF_MULTI | CFGF_TITLE), CFG_SEC("element", element_opts, CFGF_MULTI | CFGF_TITLE), + CFG_SEC("layout", layout_opts, CFGF_MULTI | CFGF_TITLE), CFG_END() }; @@ -103,22 +115,26 @@ static char * configfile = NULL; #if defined HAVE_USE_DEFAULT_COLORS struct layout cfg_layout[] = { - {-1, -1, 0}, /* dummy, not used */ - {-1, -1, 0}, /* default */ - {-1, -1, A_REVERSE}, /* statusbar */ - {-1, -1, 0}, /* header */ - {-1, -1, 0}, /* list */ - {-1, -1, A_REVERSE}, /* selected */ + {-1, -1, 0}, /* dummy, not used */ + {-1, -1, 0}, /* default */ + {-1, -1, A_REVERSE}, /* statusbar */ + {-1, -1, 0}, /* header */ + {-1, -1, 0}, /* list */ + {-1, -1, A_REVERSE}, /* selected */ + {-1, -1, 0}, /* RX graph */ + {-1, -1, 0}, /* TX graph */ }; #else struct layout cfg_layout[] = { - {0, 0, 0}, /* dummy, not used */ - {COLOR_BLACK, COLOR_WHITE, 0}, /* default */ - {COLOR_BLACK, COLOR_WHITE, A_REVERSE}, /* statusbar */ - {COLOR_BLACK, COLOR_WHITE, 0}, /* header */ - {COLOR_BLACK, COLOR_WHITE, 0}, /* list */ - {COLOR_BLACK, COLOR_WHITE, A_REVERSE}, /* selected */ + {0, 0, 0}, /* dummy, not used */ + {COLOR_WHITE, COLOR_BLACK, 0}, /* default */ + {COLOR_BLUE, COLOR_GREEN, A_REVERSE}, /* statusbar */ + {COLOR_GREEN, COLOR_BLACK, 0}, /* header */ + {COLOR_WHITE, COLOR_BLACK, 0}, /* list */ + {COLOR_YELLOW, COLOR_BLACK, A_REVERSE}, /* selected */ + {COLOR_GREEN, COLOR_BLACK, 0}, /* RX graph */ + {COLOR_RED, COLOR_BLACK, 0}, /* TX graph */ }; #endif #endif @@ -423,6 +439,41 @@ static void configfile_read_attrs(void) } } +static void configfile_read_layout_cfg(void) +{ + int i, nlayouts; + cfg_t *lout; + nlayouts = cfg_size(cfg, "layout"); + for (i = 0; i < nlayouts; i++) + { + int c, ncolors; + const char *name; + if (!(lout = cfg_getnsec(cfg, "layout", i))) + BUG(); + + if (!(name = cfg_title(lout))) + BUG(); + + ncolors = cfg_size(lout, "color"); + if (ncolors > LAYOUT_MAX) { + fprintf(stderr, "Warning excceeded maximum number of layouts\n"); + ncolors = LAYOUT_MAX; + } + + for (c = 0; c < ncolors; c++) { + cfg_t *color_pair; + + if (!(color_pair = cfg_getnsec(lout, "color", c))) + BUG(); + + if (!(name = cfg_title(color_pair))) + BUG(); + + add_layout(name, color_pair); + } + } +} + static void conf_read(const char *path, int must) { int err; @@ -450,6 +501,7 @@ static void conf_read(const char *path, int must) configfile_read_history(); configfile_read_attrs(); configfile_read_element_cfg(); + configfile_read_layout_cfg(); } static const char default_config[] = \ @@ -508,6 +560,29 @@ static const char default_config[] = \ "history day {" \ " interval = 86400.0" \ " size = 60" \ +"}" +"layout colors {" \ +" color default {" \ +" color_pair = { \"white\", \"black\" }" \ +" }" \ +" color statusbar{" \ +" color_pair = { \"blue\", \"white\", \"reverse\" }" \ +" }" \ +" color header {" \ +" color_pair = { \"yellow\", \"black\" }" \ +" }" \ +" color list {" \ +" color_pair = { \"white\", \"black\" }" \ +" }" \ +" color selected {" \ +" color_pair = { \"yellow\", \"black\", \"reverse\" }" \ +" }" \ +" color rx_graph {" \ +" color_pair = { \"green\", \"black\" }" \ +" }" \ +" color tx_graph {" \ +" color_pair = { \"red\", \"black\" }" \ +" }" \ "}"; static void conf_read_default(void) @@ -524,6 +599,7 @@ static void conf_read_default(void) configfile_read_history(); configfile_read_attrs(); configfile_read_element_cfg(); + configfile_read_layout_cfg(); } void configfile_read(void) diff --git a/src/out_curses.c b/src/out_curses.c index 7b8bc7a..5724121 100644 --- a/src/out_curses.c +++ b/src/out_curses.c @@ -420,6 +420,7 @@ static void draw_header(void) move(row, COLS - strlen(PACKAGE_STRING) - 1); put_line("%s", PACKAGE_STRING); move(row, 0); + apply_layout(LAYOUT_LIST); } static int lines_required_for_statusbar(void) @@ -632,6 +633,7 @@ static void draw_element(struct element_group *g, struct element *e, static void draw_group(struct element_group *g, void *arg) { + apply_layout(LAYOUT_HEADER); int *line = arg; if (line_visible(*line)) { @@ -684,7 +686,7 @@ static void draw_graph_centered(struct graph *g, int row, int ncol, static void draw_table(struct graph *g, struct graph_table *tbl, struct attr *a, struct history *h, - const char *hdr, int ncol) + const char *hdr, int ncol, int layout) { int i, save_row; char buf[32]; @@ -709,11 +711,14 @@ static void draw_table(struct graph *g, struct graph_table *tbl, //move(row, ncol + g->g_cfg.gc_width - 3); //put_line("[err %.2f%%]", rtiming.rt_variance.v_error); + memset(buf, 0, strlen(buf)); for (i = (g->g_cfg.gc_height - 1); i >= 0; i--) { move(++row, ncol); - put_line("%'8.2f %s", - tbl->gt_scale[i], - tbl->gt_table + (i * graph_row_size(&g->g_cfg))); + sprintf(buf, "%'8.2f ", tbl->gt_scale[i]); + addstr(buf); + apply_layout(layout); + put_line("%s", tbl->gt_table + (i * graph_row_size(&g->g_cfg))); + apply_layout(LAYOUT_LIST); } move(++row, ncol); @@ -747,14 +752,14 @@ static void draw_history_graph(struct attr *a, struct history *h) graph_refill(g, h); save_row = row; - draw_table(g, &g->g_rx, a, h, "RX", ncol); + draw_table(g, &g->g_rx, a, h, "RX", ncol, LAYOUT_RX_GRAPH); if (graph_display == GRAPH_DISPLAY_SIDE_BY_SIDE) { ncol = cols / 2; row = save_row; } - draw_table(g, &g->g_tx, a, h, "TX", ncol); + draw_table(g, &g->g_tx, a, h, "TX", ncol, LAYOUT_TX_GRAPH); graph_free(g); } From e47a376f70ef309b78eed864abecea9c1900a765 Mon Sep 17 00:00:00 2001 From: blastmaster Date: Tue, 19 Jul 2016 22:04:26 +0200 Subject: [PATCH 52/76] fix make distcheck error * add layout.h in include/Makefile.am --- include/Makefile.am | 1 + 1 file changed, 1 insertion(+) diff --git a/include/Makefile.am b/include/Makefile.am index 327db14..75a88fc 100644 --- a/include/Makefile.am +++ b/include/Makefile.am @@ -16,4 +16,5 @@ noinst_HEADERS = \ bmon/module.h \ bmon/output.h \ bmon/unit.h \ + bmon/layout.h \ bmon/utils.h From df271c43a497799be34b2ccce8283ce9ccbdfd44 Mon Sep 17 00:00:00 2001 From: Thomas Graf Date: Tue, 19 Jul 2016 23:16:10 +0200 Subject: [PATCH 53/76] 3.9 release Signed-off-by: Thomas Graf --- NEWS | 8 ++++++++ README.md | 18 +++++++++++++----- configure.ac | 2 +- 3 files changed, 22 insertions(+), 6 deletions(-) diff --git a/NEWS b/NEWS index 565485d..38771d3 100644 --- a/NEWS +++ b/NEWS @@ -1,3 +1,11 @@ +v3.9 - Jul 19, 2016 + * Color support + * Add ability to reset statistics from curses UI + * NetBSD compile fix + * Option to enable info display by default + * Additional IPv6 statistics + * Various fixes + v3.8 - July 25, 2015 ---------------------- * Don't disable Netlink if TC stats are unavailable diff --git a/README.md b/README.md index 2e477e3..508d3bb 100644 --- a/README.md +++ b/README.md @@ -48,8 +48,13 @@ bmon ``` ------------- -## New in 3.8 - * Don't disable Netlink if TC stats are unavailable +## New in 3.9 + * Color support + * Add ability to reset statistics from curses UI + * NetBSD compile fix + * Option to enable info display by default + * Additional IPv6 statistics + * Various fixes ------------- ### Usage @@ -65,12 +70,15 @@ provided via: ## Screenshots -![Screenshot 1](https://github.com/tgraf/bmon/raw/gh-pages/images/shot1.png) -![Screenshot 2](https://github.com/tgraf/bmon/raw/gh-pages/images/shot2.png) +![Screenshot 1](https://github.com/tgraf/bmon/raw/gh-pages/images/shot3.png) +![Screenshot 2](https://github.com/tgraf/bmon/raw/gh-pages/images/shot1.png) +![Screenshot 3](https://github.com/tgraf/bmon/raw/gh-pages/images/shot2.png) ## Copyright -> *Copyright (c) 2001-2014 Thomas Graf * +Various authors, see git commit log. + +> *Copyright (c) 2001-2016 Thomas Graf * > *Copyright (c) 2013 Red Hat, Inc.* Please see the [LICENSE.BSD](https://github.com/tgraf/bmon/blob/master/LICENSE.BSD) diff --git a/configure.ac b/configure.ac index a81b792..70adab3 100644 --- a/configure.ac +++ b/configure.ac @@ -21,7 +21,7 @@ # FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER # DEALINGS IN THE SOFTWARE. -AC_INIT(bmon, 3.8, [], [], [http://www.infradead.org/~tgr/bmon/]) +AC_INIT(bmon, 3.9, [], [], [http://www.infradead.org/~tgr/bmon/]) AC_CONFIG_HEADERS(include/bmon/defs.h) AC_CONFIG_AUX_DIR([build-aux]) AC_CONFIG_MACRO_DIR([m4]) From ddcd5e7d24ad57257117402529eacddd8feed2cf Mon Sep 17 00:00:00 2001 From: Thomas Graf Date: Tue, 2 Aug 2016 10:10:34 +0200 Subject: [PATCH 54/76] 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 --- NEWS | 3 +++ src/element.c | 26 +++++++++++++++++++++++++- 2 files changed, 28 insertions(+), 1 deletion(-) diff --git a/NEWS b/NEWS index 38771d3..f25b836 100644 --- a/NEWS +++ b/NEWS @@ -1,3 +1,6 @@ +HEAD + * Pick default selected interface based on policy + v3.9 - Jul 19, 2016 * Color support * Add ability to reset statistics from curses UI diff --git a/src/element.c b/src/element.c index d71a337..ebddc2e 100644 --- a/src/element.c +++ b/src/element.c @@ -358,6 +358,26 @@ int element_set_usage_attr(struct element *e, const char *usage) return 0; } +void element_pick_from_policy(struct element_group *g) +{ + if (!list_empty(&allowed)) { + struct policy *p; + + list_for_each_entry(p, &allowed, p_list) { + struct element *e; + + list_for_each_entry(e, &g->g_elements, e_list) { + if (match_mask(p, e->e_name)) { + g->g_current = e; + return; + } + } + } + } + + element_select_first(); +} + struct element *element_current(void) { struct element_group *g; @@ -365,8 +385,12 @@ struct element *element_current(void) if (!(g = group_current())) return NULL; + /* + * If no element is picked yet, pick a default interface according to + * the selection policy. + */ if (!g->g_current) - element_select_first(); + element_pick_from_policy(g); return g->g_current; } From 723f6a5b472163ac326851f8903aa929a328648c Mon Sep 17 00:00:00 2001 From: Thomas Graf Date: Tue, 2 Aug 2016 11:37:50 +0200 Subject: [PATCH 55/76] dummy: Use default group as first group name Signed-off-by: Thomas Graf --- src/in_dummy.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/src/in_dummy.c b/src/in_dummy.c index 6b5b135..14edbce 100644 --- a/src/in_dummy.c +++ b/src/in_dummy.c @@ -89,7 +89,11 @@ static void dummy_read(void) char gname[32]; struct element_group *group; - snprintf(gname, sizeof(gname), "group%02d", gidx); + if (gidx == 0) + snprintf(gname, sizeof(gname), "%s", DEFAULT_GROUP); + else + snprintf(gname, sizeof(gname), "group%02d", gidx); + group = group_lookup(gname, GROUP_CREATE); for (n = 0; n < c_numdev; n++) { From 86f6da070300b94d0cad96b000675403d0915dd4 Mon Sep 17 00:00:00 2001 From: Thomas Graf Date: Tue, 2 Aug 2016 11:38:07 +0200 Subject: [PATCH 56/76] Use DEFAULT_GROUP instead of hardcoded string Signed-off-by: Thomas Graf --- src/group.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/group.c b/src/group.c index e745bbe..6991f5f 100644 --- a/src/group.c +++ b/src/group.c @@ -261,7 +261,7 @@ static void __init group_init(void) { DBG("init"); - group_new_hdr("intf", "Interfaces", + group_new_hdr(DEFAULT_GROUP, "Interfaces", "RX bps", "pps", "TX bps", "pps"); } From 7317715e157027d103abfd31337a0337112c77f0 Mon Sep 17 00:00:00 2001 From: Thomas Graf Date: Tue, 2 Aug 2016 12:05:29 +0200 Subject: [PATCH 57/76] 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 --- src/element.c | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/src/element.c b/src/element.c index ebddc2e..32917db 100644 --- a/src/element.c +++ b/src/element.c @@ -201,12 +201,6 @@ void element_free(struct element *e) struct attr *a, *an; int i; - if (e->e_group->g_current == e) { - element_select_prev(); - if (e->e_group->g_current == e) - e->e_group->g_current = NULL; - } - list_for_each_entry_safe(c, cnext, &e->e_childs, e_list) element_free(c); @@ -221,6 +215,12 @@ void element_free(struct element *e) list_for_each_entry_safe(a, an, &e->e_attrhash[i], a_list) attr_free(a); + if (e->e_group->g_current == e) { + element_select_prev(); + if (e->e_group->g_current == e) + e->e_group->g_current = NULL; + } + list_del(&e->e_list); e->e_group->g_nelements--; From 702df3c0a1e3346fdb80dd6e5a2ec263816f9784 Mon Sep 17 00:00:00 2001 From: blastmaster Date: Thu, 4 Aug 2016 22:57:33 +0200 Subject: [PATCH 58/76] Fix issue #43 * Remove newline from put_line formatstring while drawing details. --- src/out_curses.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/out_curses.c b/src/out_curses.c index 5724121..6d70ae3 100644 --- a/src/out_curses.c +++ b/src/out_curses.c @@ -258,7 +258,7 @@ static void draw_attr_detail(struct element *e, struct attr *a, void *arg) if (ncol > 0) addch(ACS_VLINE); - put_line(" %-14.14s %8s%-3s %8s%-3s\n", + put_line(" %-14.14s %8s%-3s %8s%-3s", a->a_def->ad_description, (a->a_flags & ATTR_RX_ENABLED) ? float2str(rx, 8, rxprec, buf1, sizeof(buf1)) : "-", rx_u, From 5b938e05c74ef0f6c162b1899b517440297996d6 Mon Sep 17 00:00:00 2001 From: Adam Drescher Date: Fri, 7 Oct 2016 11:37:13 -0500 Subject: [PATCH 59/76] Added a format string example to the man page. While the documentation is clear, it is nice to see an example to get started. Single quotes are used to prevent the shell from running our bmon patterns as commands, and to prevent it from doing wildcard expansion for the interface string. --- man/bmon.8 | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/man/bmon.8 b/man/bmon.8 index ec4431c..e371ad8 100644 --- a/man/bmon.8 +++ b/man/bmon.8 @@ -220,6 +220,14 @@ and eth1: .RS 4 \fBbmon \-p eth0,eth1 \-o curses\fP .RE +.PP +To run bmon in format mode, monitoring any eth* interfaces, with a specified +format string: +.PP +.RS 4 +\fBbmon \-p \(aqeth*\(aq \-o format:fmt=\(aq$(element:name) $(attr:rxrate:packets)\en\(aq\fP +.RE +.PP .SH "FILES" /etc/bmon.conf From 577112870d616fb5e65feeefcb16e7889c4ece9d Mon Sep 17 00:00:00 2001 From: Adam Drescher Date: Fri, 7 Oct 2016 11:42:14 -0500 Subject: [PATCH 60/76] Replaced format string double quotes with single quotes to prevent the shell from running our provided format placeholders. --- src/out_format.c | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/src/out_format.c b/src/out_format.c index aea38c5..be08b29 100644 --- a/src/out_format.c +++ b/src/out_format.c @@ -320,15 +320,15 @@ static void print_help(void) " Supported Escape Sequences: \\n, \\t, \\r, \\v, \\b, \\f, \\a\n" \ "\n" \ " Examples:\n" \ - " \"$(element:name)\\t$(attr:rx:bytes)\\t$(attr:tx:bytes)\\n\"\n" \ + " '$(element:name)\\t$(attr:rx:bytes)\\t$(attr:tx:bytes)\\n'\n" \ " lo 12074 12074\n" \ "\n" \ - " \"$(element:name) $(attr:rxrate:packets) $(attr:txrate:packets)\\n\"\n" \ + " '$(element:name) $(attr:rxrate:packets) $(attr:txrate:packets)\\n'\n" \ " eth0 33 5\n" \ "\n" \ - " \"Item: $(element:name)\\n\" \\\n" \ - " \"Bytes Rate: $(attr:rxrate:bytes)/$(attr:txrate:bytes)\\n\" \\\n" \ - " \"Packets Rate: $(attr:rxrate:packets)/$(attr:txrate:packets)\\n\"\n" \ + " 'Item: $(element:name)\\n' \\\n" \ + " 'Bytes Rate: $(attr:rxrate:bytes)/$(attr:txrate:bytes)\\n' \\\n" \ + " 'Packets Rate: $(attr:rxrate:packets)/$(attr:txrate:packets)\\n'\n" \ " Item: eth0\n" \ " Bytes Rate: 49130/2119\n" \ " Packets Rate: 40/11\n" \ From 32d8c76b18cb829a8e8178f7508cede2a95c9c80 Mon Sep 17 00:00:00 2001 From: Adam Drescher Date: Fri, 7 Oct 2016 11:49:39 -0500 Subject: [PATCH 61/76] 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). --- src/out_format.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/out_format.c b/src/out_format.c index be08b29..4d017f3 100644 --- a/src/out_format.c +++ b/src/out_format.c @@ -326,9 +326,9 @@ static void print_help(void) " '$(element:name) $(attr:rxrate:packets) $(attr:txrate:packets)\\n'\n" \ " eth0 33 5\n" \ "\n" \ - " 'Item: $(element:name)\\n' \\\n" \ - " 'Bytes Rate: $(attr:rxrate:bytes)/$(attr:txrate:bytes)\\n' \\\n" \ - " 'Packets Rate: $(attr:rxrate:packets)/$(attr:txrate:packets)\\n'\n" \ + " 'Item: $(element:name)\\nBytes Rate: $(attr:rxrate:bytes)/" \ + "$(attr:txrate:bytes)\\nPackets Rate: $(attr:rxrate:packets)/" \ + "$(attr:txrate:packets)\\n'\n" \ " Item: eth0\n" \ " Bytes Rate: 49130/2119\n" \ " Packets Rate: 40/11\n" \ From a5301347f60fb61cb03f336729ac5bc3f0c919f9 Mon Sep 17 00:00:00 2001 From: Adam Drescher Date: Mon, 17 Oct 2016 18:54:46 -0500 Subject: [PATCH 62/76] Flushed stdout after every group is printed in an iteration. This allows us to redirect ascii based output to a file. --- src/out_ascii.c | 1 + src/out_format.c | 1 + 2 files changed, 2 insertions(+) diff --git a/src/out_ascii.c b/src/out_ascii.c index c9d2e91..19762ba 100644 --- a/src/out_ascii.c +++ b/src/out_ascii.c @@ -212,6 +212,7 @@ static void ascii_draw_group(struct element_group *g, void *arg) static void ascii_draw(void) { group_foreach(ascii_draw_group, NULL); + fflush(stdout); if (c_quit_after > 0) if (--c_quit_after == 0) diff --git a/src/out_format.c b/src/out_format.c index 4d017f3..263f8c9 100644 --- a/src/out_format.c +++ b/src/out_format.c @@ -166,6 +166,7 @@ static void draw_element(struct element_group *g, struct element *e, void *arg) static void format_draw(void) { group_foreach_recursive(draw_element, NULL); + fflush(stdout); if (c_quit_after > 0) if (--c_quit_after == 0) From a3d894000b7243e4bfd54f99de3bee8154827897 Mon Sep 17 00:00:00 2001 From: Baptiste Jonglez Date: Mon, 5 Sep 2016 22:02:40 +0200 Subject: [PATCH 63/76] 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. --- configure.ac | 5 ++++- include/bmon/defs.h.in | 9 ++++++--- src/utils.c | 22 ++++++++++++++++++---- 3 files changed, 28 insertions(+), 8 deletions(-) diff --git a/configure.ac b/configure.ac index 70adab3..f1439e1 100644 --- a/configure.ac +++ b/configure.ac @@ -58,7 +58,7 @@ AC_CHECK_HEADERS(sys/param.h sys/socket.h) AC_CHECK_TYPES(suseconds_t) -AC_CHECK_FUNCS(atexit gettimeofday memset pow socket strcasecmp) +AC_CHECK_FUNCS(atexit clock_gettime memset pow socket strcasecmp) AC_CHECK_FUNCS(strchr strdup strerror strncasecmp strstr strtol) AC_CHECK_FUNCS(uname getdate) @@ -86,6 +86,9 @@ esac AC_CHECK_LIB(m, pow, [], AC_MSG_ERROR([requires libm])) +# Don't fail if not found (for instance, OS X does not have clock_gettime) +AC_CHECK_LIB(rt, clock_gettime, [], []) + BMON_LIB="" ##################################################################### diff --git a/include/bmon/defs.h.in b/include/bmon/defs.h.in index d176c30..92b72eb 100644 --- a/include/bmon/defs.h.in +++ b/include/bmon/defs.h.in @@ -9,6 +9,9 @@ /* Define to 1 if you have the `atexit' function. */ #undef HAVE_ATEXIT +/* Define to 1 if you have the `clock_gettime' function. */ +#undef HAVE_CLOCK_GETTIME + /* have curses */ #undef HAVE_CURSES @@ -39,15 +42,15 @@ /* Define to 1 if you have the header file. */ #undef HAVE_GETOPT_H -/* Define to 1 if you have the `gettimeofday' function. */ -#undef HAVE_GETTIMEOFDAY - /* Define to 1 if you have the header file. */ #undef HAVE_INTTYPES_H /* Define to 1 if you have the `m' library (-lm). */ #undef HAVE_LIBM +/* Define to 1 if you have the `rt' library (-lrt). */ +#undef HAVE_LIBRT + /* Define to 1 if you have the header file. */ #undef HAVE_MEMORY_H diff --git a/src/utils.c b/src/utils.c index 248d829..7db96e7 100644 --- a/src/utils.c +++ b/src/utils.c @@ -27,6 +27,11 @@ #include #include +#ifdef __MACH__ +#include +#include +#endif + void *xcalloc(size_t n, size_t s) { void *d = calloc(n, s); @@ -112,12 +117,21 @@ int timestamp_is_negative(timestamp_t *ts) void update_timestamp(timestamp_t *dst) { - struct timeval tv; +#ifdef __MACH__ + clock_serv_t cclock; + mach_timespec_t tp; - gettimeofday(&tv, NULL); + host_get_clock_service(mach_host_self(), SYSTEM_CLOCK, &cclock); + clock_get_time(cclock, &tp); + mach_port_deallocate(mach_task_self(), cclock); +#else + struct timespec tp; + + clock_gettime(CLOCK_MONOTONIC, &tp); +#endif - dst->tv_sec = tv.tv_sec; - dst->tv_usec = tv.tv_usec; + dst->tv_sec = tp.tv_sec; + dst->tv_usec = tp.tv_nsec / 1000; } void copy_timestamp(timestamp_t *ts1, timestamp_t *ts2) From f31267973877b14959c1d0cf402504c56152a6bf Mon Sep 17 00:00:00 2001 From: L00Cyph3r Date: Mon, 28 Nov 2016 16:02:11 +0100 Subject: [PATCH 64/76] Added CentOS installation steps Works on my CentOS 6.8 box --- README.md | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/README.md b/README.md index 508d3bb..bd58561 100644 --- a/README.md +++ b/README.md @@ -25,6 +25,18 @@ make make install bmon ``` +## CentOS (6) Installation + +``` +git clone https://github.com/tgraf/bmon.git +cd bmon +yum install make libconfuse-devel libnl3-devel libnl-route3-devel ncurses-devel +./autogen.sh +./configure +make +make install +bmon +``` ## OSX Installation Install libconfuse From af8923b779898033a9237e36a78c96f2d7e4d0bf Mon Sep 17 00:00:00 2001 From: Tobias Klauser Date: Tue, 13 Dec 2016 10:24:26 +0100 Subject: [PATCH 65/76] 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 --- src/in_netlink.c | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/src/in_netlink.c b/src/in_netlink.c index ef98ae0..4b5e3b1 100644 --- a/src/in_netlink.c +++ b/src/in_netlink.c @@ -60,6 +60,11 @@ static struct bmon_module netlink_ops; # define RTNL_LINK_IP6_CEPKTS -1 #endif +/* Not available prior to libnl 3.2.29 */ +#if LIBNL_CURRENT < 224 +# define RTNL_LINK_RX_NOHANDLER -1 +#endif + static struct attr_map link_attrs[] = { { .name = "bytes", @@ -101,6 +106,14 @@ static struct attr_map link_attrs[] = { .rxid = RTNL_LINK_RX_COMPRESSED, .txid = RTNL_LINK_TX_COMPRESSED, }, +{ + .name = "nohandler", + .type = ATTR_TYPE_COUNTER, + .unit = UNIT_NUMBER, + .description = "No Handler", + .rxid = RTNL_LINK_RX_NOHANDLER, + .txid = -1, +}, { .name = "fifoerr", .type = ATTR_TYPE_COUNTER, From 1b3f11bde315e221474f7d066ce4efb4ff4d39e3 Mon Sep 17 00:00:00 2001 From: Thomas Graf Date: Tue, 13 Dec 2016 11:55:54 +0100 Subject: [PATCH 66/76] 4.0 release Signed-off-by: Thomas Graf --- NEWS | 13 +++++++------ README.md | 14 +++++++------- configure.ac | 4 ++-- 3 files changed, 16 insertions(+), 15 deletions(-) diff --git a/NEWS b/NEWS index f25b836..b62f316 100644 --- a/NEWS +++ b/NEWS @@ -1,5 +1,12 @@ HEAD + +v4.0 - Dec 13, 2016 + * Use monotonic clock instead of realtime clock * Pick default selected interface based on policy + * Collect RX NoHandler statistics if available (Linux) + * CentOS installation instructions + * Proper stdout flush in ASCII mode + * Bugfixes v3.9 - Jul 19, 2016 * Color support @@ -10,36 +17,30 @@ v3.9 - Jul 19, 2016 * Various fixes v3.8 - July 25, 2015 ----------------------- * Don't disable Netlink if TC stats are unavailable v3.7 - November 22, 2014 ----------------------- * Bugfixes * Documentation updates * Provide minimal interface information on BSD v3.6 - November 22, 2014 ----------------------- * Build fix for uclinux * Fix LICENSE links v3.5 - August 30, 2014 ----------------------- * Fixes for all defects identified by coverity * Fix accuracy issue on total rate calculation * Travis-CI support * Various other small bugfixes v3.4 - August 24, 2014 ----------------------- * Bugfixes * blank screen with config file * quick-help toggle with '?' in curses * Better bmon.conf example v3.3 - July 6, 2014 -------------------- * MacOS X port * Only initialize curses module if actually used * Assorted bug and spelling fixes diff --git a/README.md b/README.md index bd58561..24c8cd4 100644 --- a/README.md +++ b/README.md @@ -60,13 +60,13 @@ bmon ``` ------------- -## New in 3.9 - * Color support - * Add ability to reset statistics from curses UI - * NetBSD compile fix - * Option to enable info display by default - * Additional IPv6 statistics - * Various fixes +## New in 4.0 + * Use monotonic clock instead of realtime clock + * Pick default selected interface based on policy + * Collect RX NoHandler statistics if available (Linux) + * CentOS installation instructions + * Proper stdout flush in ASCII mode + * Bugfixes ------------- ### Usage diff --git a/configure.ac b/configure.ac index f1439e1..b9174eb 100644 --- a/configure.ac +++ b/configure.ac @@ -1,7 +1,7 @@ # # configure.in Configure Script # -# Copyright (c) 2001-2013 Thomas Graf +# Copyright (c) 2001-2016 Thomas Graf # # Permission is hereby granted, free of charge, to any person obtaining a # copy of this software and associated documentation files (the "Software"), @@ -21,7 +21,7 @@ # FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER # DEALINGS IN THE SOFTWARE. -AC_INIT(bmon, 3.9, [], [], [http://www.infradead.org/~tgr/bmon/]) +AC_INIT(bmon, 4.0, [], [], [https://github.com/tgraf/bmon]) AC_CONFIG_HEADERS(include/bmon/defs.h) AC_CONFIG_AUX_DIR([build-aux]) AC_CONFIG_MACRO_DIR([m4]) From 341375179514bfd96f2d6001df15a4079631491b Mon Sep 17 00:00:00 2001 From: Nachiketa Prachanda Date: Tue, 31 Jan 2017 12:08:48 -0800 Subject: [PATCH 67/76] 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 --- src/out_curses.c | 16 +++++++++------- 1 file changed, 9 insertions(+), 7 deletions(-) diff --git a/src/out_curses.c b/src/out_curses.c index 6d70ae3..e5317de 100644 --- a/src/out_curses.c +++ b/src/out_curses.c @@ -147,22 +147,24 @@ static char *float2str(double value, int width, int prec, char *buf, size_t len) static void put_line(const char *fmt, ...) { va_list args; - char buf[2048]; + char *buf; + int len; int x, y __unused__; - memset(buf, 0, sizeof(buf)); getyx(stdscr, y, x); + len = cols - x; + buf = xcalloc(len+1, 1); + va_start(args, fmt); - vsnprintf(buf, sizeof(buf), fmt, args); + vsnprintf(buf, len+1, fmt, args); va_end(args); - if (strlen(buf) > cols-x) - buf[cols - x] = '\0'; - else - memset(&buf[strlen(buf)], ' ', cols - strlen(buf)-x); + if (strlen(buf) < len) + memset(&buf[strlen(buf)], ' ', len - strlen(buf)); addstr(buf); + xfree(buf); } static void center_text(const char *fmt, ...) From 14db0bff4cb2fac7ca2705ae00ada4b38ae81951 Mon Sep 17 00:00:00 2001 From: Fredrik Fornwall Date: Thu, 9 Feb 2017 09:19:31 +0100 Subject: [PATCH 68/76] Avoid trying to include on Android The header file is not present on Android, and the project builds there without it. --- include/bmon/config.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/include/bmon/config.h b/include/bmon/config.h index ad6a367..e1d749f 100644 --- a/include/bmon/config.h +++ b/include/bmon/config.h @@ -48,7 +48,7 @@ #include #ifdef SYS_BSD # include -#else +#elif !defined(__ANDROID__) # include #endif From 49ce252ec54fd9dbd9a850950d4ab5f0b8e8287c Mon Sep 17 00:00:00 2001 From: Thomas Graf Date: Fri, 10 Feb 2017 06:11:19 -0800 Subject: [PATCH 69/76] OSX: Add brew usage instructions Signed-off-by: Thomas Graf --- README.md | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/README.md b/README.md index 24c8cd4..b7624b9 100644 --- a/README.md +++ b/README.md @@ -39,6 +39,13 @@ bmon ``` ## OSX Installation + +### Brew +``` +brew install bmon +``` + +### Compile yourself Install libconfuse ``` wget https://github.com/martinh/libconfuse/releases/download/v2.8/confuse-2.8.zip From fdd139ada21b958a17d79dd2f1db5d514136d131 Mon Sep 17 00:00:00 2001 From: Thomas Graf Date: Fri, 10 Feb 2017 06:14:05 -0800 Subject: [PATCH 70/76] Fix configuration syntax in examples/bmon.conf Fixes: #53 Signed-off-by: Thomas Graf --- examples/bmon.conf | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/examples/bmon.conf b/examples/bmon.conf index 93d64c3..7cf43b9 100644 --- a/examples/bmon.conf +++ b/examples/bmon.conf @@ -11,10 +11,10 @@ /* * element eth0 { - * description = { "My description" } - * rxmax = { 10000 } - * txmax = { 10000 } - * max = { 12500000 } + * description = "My description" + * rxmax = 10000 + * txmax = 10000 + * max = 12500000 * } */ From b44d0152c47105db081d36b13b590b8f423f0265 Mon Sep 17 00:00:00 2001 From: Alexis Hildebrandt Date: Mon, 2 Oct 2017 21:01:18 +0200 Subject: [PATCH 71/76] Allow numeric colors in bmonrc --- include/bmon/layout.h | 2 ++ 1 file changed, 2 insertions(+) diff --git a/include/bmon/layout.h b/include/bmon/layout.h index cca2a4c..4633806 100644 --- a/include/bmon/layout.h +++ b/include/bmon/layout.h @@ -28,6 +28,8 @@ static int parse_color(const char* color) color_code = COLOR_MAGENTA; else if ((strcasestr(color, "cyan") != NULL)) color_code = COLOR_CYAN; + else if ((atoi(color) >= 0)) + color_code = atoi(color); return color_code; } From 737c642819d0af392872d0ca607f075d62c0ed70 Mon Sep 17 00:00:00 2001 From: Alexis Hildebrandt Date: Tue, 3 Oct 2017 10:02:26 +0200 Subject: [PATCH 72/76] Fix typographical errors --- man/bmon.8 | 6 +++--- src/bmon.c | 4 ++-- src/out_curses.c | 2 +- 3 files changed, 6 insertions(+), 6 deletions(-) diff --git a/man/bmon.8 b/man/bmon.8 index e371ad8..36e0d53 100644 --- a/man/bmon.8 +++ b/man/bmon.8 @@ -34,7 +34,7 @@ in parallel. bmon automatically loads a useful and working input module by default. See INPUT MODULES for more details. .RE .PP -\fB \-o\fR, \fB\-\-output\fRMODULE[:OPTIONS][,MODULE...] +\fB \-o\fR, \fB\-\-output=\fRMODULE[:OPTIONS][,MODULE...] .RS 4 Set list of output modules to load and use. Multiple modules can be used in parallel. By default, bmon will use the curses output mode, if that is @@ -58,7 +58,7 @@ Set policy defining which network interfaces to display. See INTERFACE SELECTION for more details. .RE .PP -\fB \-a\fR, \fB\-\-show\-all=\fR +\fB \-a\fR, \fB\-\-show\-all\fR .RS 4 Display all interfaces, even interface that are administratively down. .RE @@ -137,7 +137,7 @@ The following output modules exist: .TP \fBcurses\fR Interactive curses based text user interface providing real time rate -estimations and a graphical representatio nof each attribute. Press '?' +estimations and a graphical representation of each attribute. Press '?' to display the quick reference guide. This is the default output mode. .TP diff --git a/src/bmon.c b/src/bmon.c index 9fa684c..882ab67 100644 --- a/src/bmon.c +++ b/src/bmon.c @@ -67,14 +67,14 @@ static char *usage_text = " Examples:\n" \ " -o curses:ngraph=2\n" \ " -o list # Shows a list of available modules\n" \ -" -o curses:help # Shows a help text for html module\n" \ +" -o curses:help # Shows a help text for curses module\n" \ "\n" \ "Interface selection:\n" \ " policy := [!]simple_regexp,[!]simple_regexp,...\n" \ "\n" \ " Example: -p 'eth*,lo*,!eth1'\n" \ "\n" \ -"Please see the bmon(1) man pages for full documentation.\n"; +"Please see the bmon(8) man pages for full documentation.\n"; static void do_shutdown(void) { diff --git a/src/out_curses.c b/src/out_curses.c index e5317de..c7bcf17 100644 --- a/src/out_curses.c +++ b/src/out_curses.c @@ -1254,7 +1254,7 @@ static void print_module_help(void) " Author: Thomas Graf \n" \ "\n" \ " Options:\n" \ - " fgchar=CHAR Foreground character (default: '*')\n" \ + " fgchar=CHAR Foreground character (default: '|')\n" \ " bgchar=CHAR Background character (default: '.')\n" \ " nchar=CHAR Noise character (default: ':')\n" \ " uchar=CHAR Unknown character (default: '?')\n" \ From ed8528cf9c83f937e1441933b8736b0f42a53664 Mon Sep 17 00:00:00 2001 From: Alexis Hildebrandt Date: Tue, 3 Oct 2017 11:17:42 +0200 Subject: [PATCH 73/76] curses: Fix seperator lines when section above or below is collapsed --- src/out_curses.c | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/src/out_curses.c b/src/out_curses.c index c7bcf17..51b6391 100644 --- a/src/out_curses.c +++ b/src/out_curses.c @@ -981,8 +981,10 @@ static void draw_content(void) */ NEXT_ROW(); hline(ACS_HLINE, cols); - mvaddch(row, LIST_COL_1, ACS_BTEE); - mvaddch(row, LIST_COL_2, ACS_BTEE); + if (c_show_list) { + mvaddch(row, LIST_COL_1, ACS_BTEE); + mvaddch(row, LIST_COL_2, ACS_BTEE); + } if (!c_show_graph) center_text(" Press %c to enable graphical statistics ", @@ -1024,6 +1026,12 @@ static void draw_content(void) NEXT_ROW(); hline(ACS_HLINE, cols); + if (c_show_details) { + int i; + for (i = 1; i < detail_cols; i++) + mvaddch(row, (i * DETAILS_COLS) - 1, ACS_BTEE); + } + if (!c_show_info) center_text(" Press %c to enable additional information ", KEY_TOGGLE_INFO); From 5677863e61e2c115eb86613b09f636b84cf4ada3 Mon Sep 17 00:00:00 2001 From: Alexis Hildebrandt Date: Tue, 3 Oct 2017 00:00:07 +0200 Subject: [PATCH 74/76] curses: Add CTRL-N/CTRL-P for next/previous element --- src/out_curses.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/out_curses.c b/src/out_curses.c index 51b6391..330e8f6 100644 --- a/src/out_curses.c +++ b/src/out_curses.c @@ -45,6 +45,8 @@ enum { KEY_TOGGLE_DETAILS = 'd', KEY_TOGGLE_INFO = 'i', KEY_COLLECT_HISTORY = 'h', + KEY_CTRL_N = 14, + KEY_CTRL_P = 16, }; #define DETAILS_COLS 40 @@ -1186,10 +1188,12 @@ static int handle_input(int ch) return 1; case KEY_DOWN: + case KEY_CTRL_N: element_select_next(); return 1; case KEY_UP: + case KEY_CTRL_P: element_select_prev(); return 1; From 169332baa8823aa4d7572a0b2a4a9a440e482ca9 Mon Sep 17 00:00:00 2001 From: Carl George Date: Tue, 15 Oct 2019 17:53:55 -0500 Subject: [PATCH 75/76] Add package installation instructions for Fedora/CentOS --- README.md | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index b7624b9..4d6acb7 100644 --- a/README.md +++ b/README.md @@ -25,7 +25,7 @@ make make install bmon ``` -## CentOS (6) Installation +## CentOS 6 Installation ``` git clone https://github.com/tgraf/bmon.git @@ -38,6 +38,18 @@ make install bmon ``` +## CentOS 7 Installation + +``` +yum install bmon +``` + +## Fedora Installation + +``` +dnf install bmon +``` + ## OSX Installation ### Brew From def45f59a830cd1c07f2cd0a56f7262e18f3a8a8 Mon Sep 17 00:00:00 2001 From: Babak Farrokhi Date: Sun, 11 Nov 2018 21:40:17 +0330 Subject: [PATCH 76/76] Fix build in FreeBSD/DragonflyBSD --- configure.ac | 2 +- src/in_sysctl.c | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/configure.ac b/configure.ac index b9174eb..afc43c7 100644 --- a/configure.ac +++ b/configure.ac @@ -175,7 +175,7 @@ case ${target_os} in AC_DEFINE_UNQUOTED(SYS_SUNOS, "1", [operating system]) ;; - *bsd*) + *bsd*|dragonfly*) AC_DEFINE_UNQUOTED(SYS_BSD, "1", [operating system]) ;; diff --git a/src/in_sysctl.c b/src/in_sysctl.c index faf647a..1112e35 100644 --- a/src/in_sysctl.c +++ b/src/in_sysctl.c @@ -232,7 +232,7 @@ sysctl_read(void) snprintf(info_buf, sizeof(info_buf), "%ju", (uintmax_t)ifm->ifm_data.ifi_metric); element_update_info(e, "Metric", info_buf); -#ifndef __NetBSD__ +#if !(defined(__NetBSD__) || defined(__FreeBSD__)) snprintf(info_buf, sizeof(info_buf), "%u", ifm->ifm_data.ifi_recvquota); element_update_info(e, "RX-Quota", info_buf);