Compare commits

...

48 Commits

Author SHA1 Message Date
Thomas Graf
1e83e238db New API token
Signed-off-by: Thomas Graf <tgraf@suug.ch>
2015-12-16 15:49:54 +01:00
Thomas Graf
32e4d7b2a6 coverty: Update token and version
Signed-off-by: Thomas Graf <tgraf@suug.ch>
2015-12-16 15:46:42 +01:00
Thomas Graf
26497a9896 build: Enable coverity scan through travis-ci
Signed-off-by: Thomas Graf <tgraf@suug.ch>
2015-12-16 15:46:42 +01:00
Thomas Graf
a0eea59519 netlink: BUG() if we don't have parent information
This would indicate that we hang a TC object to the tree root.

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

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

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

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

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

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

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

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

Reported-by: Wen Chiu <Wen.Chiu@brocade.com>
Signed-off-by: Thomas Graf <tgraf@suug.ch>
2015-07-25 10:51:47 +02:00
Thomas Graf
30946f2d78 bmon 3.7 release
Signed-off-by: Thomas Graf <tgraf@suug.ch>
2015-06-30 12:09:54 +02:00
Thomas Graf
47547eb29f man: Also mention --use-bit option
Signed-off-by: Thomas Graf <tgraf@suug.ch>
2015-06-30 12:05:53 +02:00
Thomas Graf
21ec49ed67 format: Don't print error message for unavailable attributes
Signed-off-by: Thomas Graf <tgraf@suug.ch>
2015-06-30 11:59:48 +02:00
Thomas Graf
29172c819c Document -b option
Reported-by: Ross Patterson
Signed-off-by: Thomas Graf <tgraf@suug.ch>
2015-06-30 11:50:40 +02:00
Thomas Graf
2ccea2c56e Merge pull request #25 from Chocobo1/bits
Fix wrong unit displayed when using "--use-bit" option
2015-05-31 18:04:27 +02:00
Chocobo1
51a24c315b Fix wrong unit displayed when using "--use-bit" option 2015-05-31 21:27:52 +08:00
Chocobo1
5cecc86856 Fix inconsistency in format module example 2015-05-31 18:53:35 +08:00
Chocobo1
5e61c5c0e4 man page: add explaination of SI uints 2015-05-31 16:15:51 +08:00
Thomas Graf
4645116a57 Merge pull request #24 from tklauser/cross-compile-fix
[v2] Explicitly include linux/if.h to fix cross-compile error
2015-04-30 09:45:18 -07:00
Tobias Klauser
c80554be16 Explicitly include linux/if.h to fix cross-compile error
When compiling bmon with the Linaro 2014.01 ARM toolchain
(gcc-linaro-arm-linux-gnueabihf-4.8-2014.01_linux) the following compile error occurs:

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

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

Signed-off-by: Tobias Klauser <tklauser@distanz.ch>
2015-04-30 12:00:35 +02:00
Thomas Graf
2a410be36f README: Mention that ./autogen.sh must be run after git clone
Reported-by: DavidRChristensen
Signed-off-by: Thomas Graf <tgraf@suug.ch>
2015-04-29 17:30:22 +02:00
Thomas Graf
c1ae292c95 README: Mention ncurses-devel dependency in installation notes
Reported-by: DavidRChristensen
Signed-off-by: Thomas Graf <tgraf@suug.ch>
2015-04-29 17:28:31 +02:00
Thomas Graf
234efb85f6 Merge pull request #20 from Chocobo1/dev
assertion failed in libConfuse
2015-04-29 08:25:47 -07:00
Chocobo1
229d58c975 using cfg_setint is triggering an assertion in confuse library, should use cfg_setbool instead 2015-01-19 20:02:14 +08:00
Thomas Graf
8fc5a55da4 Merge pull request #19 from halid/master
Debian / Ubuntu Installation Procedures
2015-01-08 16:18:53 +01:00
Halid Altuner
3ecdad6f56 Update README.md
make and build-essential package
2015-01-08 14:14:02 +02:00
Halid Altuner
511e0196e1 Update README.md
debian installation procedures
2015-01-08 14:11:38 +02:00
Thomas Graf
0100916a95 BSD: Provide minimal interface information
Including:
 - MTU
 - Metric
 - RX/TX IRQ Quota

Signed-off-by: Thomas Graf <tgraf@suug.ch>
2014-12-16 18:31:27 +01:00
Thomas Graf
ea065c5619 Provide download link in README.md
Signed-off-by: Thomas Graf <tgraf@suug.ch>
2014-11-22 13:40:10 +01:00
Thomas Graf
baabc8b729 3.6 release
Signed-off-by: Thomas Graf <tgraf@suug.ch>
2014-11-22 13:33:24 +01:00
Thomas Graf
88548ccf96 Merge pull request #18 from gustavoz/master
build: uclinux is also linux
2014-11-13 12:13:03 +01:00
Gustavo Zacarias
c4ed01f272 build: uclinux is also linux 2014-11-11 20:37:21 -03:00
Thomas Graf
c1d0bb41c7 Fix LICENSE links in README.md
Reported-by: Eric Leblond
Signed-off-by: Thomas Graf <tgraf@suug.ch>
2014-09-05 09:39:24 +02:00
Thomas Graf
7f8d60f40f 3.5 release
Signed-off-by: Thomas Graf <tgraf@suug.ch>
2014-08-30 13:36:46 +02:00
Thomas Graf
6920af805c travis: Run make distcheck
Signed-off-by: Thomas Graf <tgraf@suug.ch>
2014-08-30 13:32:49 +02:00
Thomas Graf
8b4ce86cc9 Makefile: Fix README.md distribution inclusion
Signed-off-by: Thomas Graf <tgraf@suug.ch>
2014-08-30 13:30:30 +02:00
Thomas Graf
17a4adb0f2 build: fail CI builds if a new warning is introduced
Signed-off-by: Thomas Graf <tgraf@suug.ch>
2014-08-25 01:07:19 +02:00
Thomas Graf
4492ab547c build: Enable -Wall
Signed-off-by: Thomas Graf <tgraf@suug.ch>
2014-08-25 01:07:19 +02:00
Thomas Graf
a36136ec4d Annotate unused variables
Signed-off-by: Thomas Graf <tgraf@suug.ch>
2014-08-25 01:07:19 +02:00
Thomas Graf
e3d208905d Initialize t to silence uninit warning
Signed-off-by: Thomas Graf <tgraf@suug.ch>
2014-08-25 01:07:19 +02:00
Thomas Graf
68bd14ffd1 Remove unused write_column() function
Signed-off-by: Thomas Graf <tgraf@suug.ch>
2014-08-25 01:07:19 +02:00
Thomas Graf
e2df502abc Remove unused variables
Signed-off-by: Thomas Graf <tgraf@suug.ch>
2014-08-25 01:07:19 +02:00
22 changed files with 256 additions and 121 deletions

View File

@ -1,10 +1,33 @@
language: c
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: ./autogen.sh && ./configure && make
env:
global:
# COVERITY_SCAN_TOKEN
# ** specific to your project **
secure: "UwSy57y9-USTD6w65Ubvyg"
addons:
coverity_scan:
# GitHub project metadata
# ** specific to your project **
project:
name: tgraf/bmon
version: 3.7
description: bandwidth monitor
# Where email notification of build analysis results will be sent
notification_email: tgraf@suug.ch
# Commands to prepare for build_command
# ** likely specific to your build **
build_command_prepend: ./autogen.sh && ./configure
# The command that will be added as an argument to "cov-build" to compile your project for analysis,
# ** likely specific to your build **
build_command: make
# Pattern to match selecting branches that will run analysis. We recommend leaving this set to 'coverity_scan'.
# Take care in resource usage, and consider the build frequency allowances per
# https://scan.coverity.com/faq#frequency
branch_pattern: coverity_scan

9
.travis/run.sh Executable file
View File

@ -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" && make distcheck

View File

@ -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

22
NEWS
View File

@ -1,3 +1,25 @@
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

View File

@ -8,20 +8,29 @@ 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
### New in 3.4
* Bugfixes
* blank screen with config file
* quick-help toggle with '?' in curses
* Better bmon.conf example
* [Latest Release](https://github.com/tgraf/bmon/releases/latest)
* [Older Releases](https://github.com/tgraf/bmon/releases)
## New in 3.3
* MacOS X port
* Only initialize curses module if actually used
* Assorted bug and spelling fixes
* Various build fixes
## Debian/Ubuntu Installation
```
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
bmon
```
-------------
## New in 3.8
* Don't disable Netlink if TC stats are unavailable
-------------
### Usage
To run bmon in the default curses mode:
@ -40,9 +49,10 @@ provided via:
## Copyright
> *Copyright (c) 2001-2014 Thomas Graf <tgraf@suug.ch>
> Copyright (c) 2013 Red Hat, Inc.*
> *Copyright (c) 2001-2014 Thomas Graf <tgraf@suug.ch>*
> *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.

View File

@ -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.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])
@ -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]))
;;

View File

@ -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

View File

@ -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
@ -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
@ -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, \fB\-\-use\-bit\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

View File

@ -7,6 +7,7 @@ bmon_CFLAGS = \
-I${top_builddir}/include \
-DSYSCONFDIR=\"$(sysconfdir)\" \
-D_GNU_SOURCE \
-Wall \
$(CURSES_CFLAGS) \
$(CONFUSE_CFLAGS) \
$(LIBNL_CFLAGS) \

View File

@ -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;

View File

@ -33,8 +33,6 @@
#include <bmon/group.h>
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();
}
@ -120,7 +111,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 <tgraf@suug.ch>\n");
printf("Copyright (C) 2001-2015 by Thomas Graf <tgraf@suug.ch>\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 " \
@ -136,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)
@ -175,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)
@ -220,7 +211,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':
@ -270,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;
@ -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);
}

View File

@ -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");

View File

@ -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;

View File

@ -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)
{

View File

@ -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)

View File

@ -37,6 +37,8 @@ static int c_notc = 0;
static struct element_group *grp;
static struct bmon_module netlink_ops;
#include <linux/if.h>
#include <netlink/netlink.h>
#include <netlink/cache.h>
#include <netlink/utils.h>
@ -47,6 +49,17 @@ static struct bmon_module netlink_ops;
#include <netlink/route/classifier.h>
#include <netlink/route/qdisc/htb.h>
/* 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",
@ -280,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,
@ -320,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,
@ -351,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,
}
};
@ -430,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)
{
@ -470,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);
@ -483,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"))
@ -518,8 +583,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,
};
@ -532,10 +598,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;
@ -543,6 +609,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);
@ -571,7 +638,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);
@ -581,8 +648,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,
};
@ -604,6 +672,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,
@ -613,6 +682,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);
@ -736,7 +807,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);
@ -752,7 +823,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;
}
@ -772,9 +844,20 @@ 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, i;
int err;
if (!(sock = nl_socket_alloc())) {
fprintf(stderr, "Unable to allocate netlink socket\n");
@ -792,10 +875,13 @@ 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));
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();
@ -817,17 +903,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;
}

View File

@ -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")))

View File

@ -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);
}

View File

@ -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;

View File

@ -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);
@ -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);
@ -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);

View File

@ -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);
@ -189,8 +186,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 +247,7 @@ static int format_probe(void)
}
goto out;
finish_escape:
*p = '\0';
add_token(OT_STRING, s);
@ -259,7 +256,7 @@ finish_escape:
continue;
}
out:
out:
if (new_one) {
add_token(OT_STRING, p);
new_one = 0;
@ -328,9 +325,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" \

View File

@ -28,7 +28,7 @@
#include <bmon/utils.h>
#include <bmon/unit.h>
static struct unit *byte_unit, *bit_unit, *number_unit;
static struct unit *byte_unit, *bit_unit;
static LIST_HEAD(units);