Compare commits
48 Commits
test
...
coverity_s
Author | SHA1 | Date | |
---|---|---|---|
|
1e83e238db | ||
|
32e4d7b2a6 | ||
|
26497a9896 | ||
|
a0eea59519 | ||
|
f9c714fa15 | ||
|
892bdac762 | ||
|
4488cd03f9 | ||
|
753a9e09dd | ||
|
0641291ad5 | ||
|
f666ffd0b7 | ||
|
559e31e62f | ||
|
9a69cb6d59 | ||
|
665c63d4e7 | ||
|
964f48465a | ||
|
e31a860af6 | ||
|
2027a634a7 | ||
|
30946f2d78 | ||
|
47547eb29f | ||
|
21ec49ed67 | ||
|
29172c819c | ||
|
2ccea2c56e | ||
|
51a24c315b | ||
|
5cecc86856 | ||
|
5e61c5c0e4 | ||
|
4645116a57 | ||
|
c80554be16 | ||
|
2a410be36f | ||
|
c1ae292c95 | ||
|
234efb85f6 | ||
|
229d58c975 | ||
|
8fc5a55da4 | ||
|
3ecdad6f56 | ||
|
511e0196e1 | ||
|
0100916a95 | ||
|
ea065c5619 | ||
|
baabc8b729 | ||
|
88548ccf96 | ||
|
c4ed01f272 | ||
|
c1d0bb41c7 | ||
|
7f8d60f40f | ||
|
6920af805c | ||
|
8b4ce86cc9 | ||
|
17a4adb0f2 | ||
|
4492ab547c | ||
|
a36136ec4d | ||
|
e3d208905d | ||
|
68bd14ffd1 | ||
|
e2df502abc |
43
.travis.yml
43
.travis.yml
@ -1,10 +1,33 @@
|
|||||||
language: c
|
script: ./autogen.sh && ./configure && make
|
||||||
compiler:
|
|
||||||
- gcc
|
env:
|
||||||
- clang
|
global:
|
||||||
before_install:
|
# COVERITY_SCAN_TOKEN
|
||||||
- sudo apt-get install libconfuse-dev
|
# ** specific to your project **
|
||||||
- sudo apt-get install libnl-3-dev libnl-route-3-dev
|
secure: "UwSy57y9-USTD6w65Ubvyg"
|
||||||
- sudo apt-get install libncurses-dev
|
|
||||||
# Change this to your needs
|
addons:
|
||||||
script: ./.travis/run.sh
|
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
|
||||||
|
@ -6,4 +6,4 @@ if [ $CC = "clang" ]; then
|
|||||||
FLAGS="$FLAGS -Wno-error=unused-command-line-argument"
|
FLAGS="$FLAGS -Wno-error=unused-command-line-argument"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
./autogen.sh && ./configure && make CFLAGS="$FLAGS"
|
./autogen.sh && ./configure && make CFLAGS="$FLAGS" && make distcheck
|
||||||
|
@ -4,4 +4,4 @@ ACLOCAL_AMFLAGS = -I m4
|
|||||||
|
|
||||||
SUBDIRS = src man include examples
|
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
22
NEWS
@ -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
|
v3.4 - August 24, 2014
|
||||||
----------------------
|
----------------------
|
||||||
* Bugfixes
|
* Bugfixes
|
||||||
|
40
README.md
40
README.md
@ -8,20 +8,29 @@ statistics and prepare them visually in a human friendly way. It
|
|||||||
features various output methods including an interactive curses user
|
features various output methods including an interactive curses user
|
||||||
interface and a programmable text output for scripting.
|
interface and a programmable text output for scripting.
|
||||||
|
|
||||||
## Changes
|
## Download
|
||||||
|
|
||||||
### New in 3.4
|
* [Latest Release](https://github.com/tgraf/bmon/releases/latest)
|
||||||
* Bugfixes
|
* [Older Releases](https://github.com/tgraf/bmon/releases)
|
||||||
* blank screen with config file
|
|
||||||
* quick-help toggle with '?' in curses
|
|
||||||
* Better bmon.conf example
|
|
||||||
|
|
||||||
## New in 3.3
|
## Debian/Ubuntu Installation
|
||||||
* MacOS X port
|
|
||||||
* Only initialize curses module if actually used
|
|
||||||
* Assorted bug and spelling fixes
|
|
||||||
* Various build fixes
|
|
||||||
|
|
||||||
|
```
|
||||||
|
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
|
### Usage
|
||||||
|
|
||||||
To run bmon in the default curses mode:
|
To run bmon in the default curses mode:
|
||||||
@ -40,9 +49,10 @@ provided via:
|
|||||||
|
|
||||||
## Copyright
|
## Copyright
|
||||||
|
|
||||||
> *Copyright (c) 2001-2014 Thomas Graf <tgraf@suug.ch>
|
> *Copyright (c) 2001-2014 Thomas Graf <tgraf@suug.ch>*
|
||||||
> Copyright (c) 2013 Red Hat, Inc.*
|
> *Copyright (c) 2013 Red Hat, Inc.*
|
||||||
|
|
||||||
Please see the [LICENSE](https://github.com/tgraf/bmon/blob/master/LICENSE)
|
Please see the [LICENSE.BSD](https://github.com/tgraf/bmon/blob/master/LICENSE.BSD)
|
||||||
file for additional details.
|
and [LICENSE.MIT](https://github.com/tgraf/bmon/blob/master/LICENSE.MIT) files for
|
||||||
|
additional details.
|
||||||
|
|
||||||
|
@ -21,7 +21,7 @@
|
|||||||
# FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
|
# FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
|
||||||
# DEALINGS IN THE SOFTWARE.
|
# 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_HEADERS(include/bmon/defs.h)
|
||||||
AC_CONFIG_AUX_DIR([build-aux])
|
AC_CONFIG_AUX_DIR([build-aux])
|
||||||
AC_CONFIG_MACRO_DIR([m4])
|
AC_CONFIG_MACRO_DIR([m4])
|
||||||
@ -70,7 +70,7 @@ fi
|
|||||||
PKG_CHECK_MODULES([CONFUSE], [libconfuse], [], AC_MSG_ERROR([requires libconfuse]))
|
PKG_CHECK_MODULES([CONFUSE], [libconfuse], [], AC_MSG_ERROR([requires libconfuse]))
|
||||||
|
|
||||||
case ${target_os} in
|
case ${target_os} in
|
||||||
linux*)
|
linux*|uclinux*)
|
||||||
PKG_CHECK_MODULES([LIBNL], [libnl-3.0], [], AC_MSG_ERROR([requires libnl3-dev]))
|
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]))
|
PKG_CHECK_MODULES([LIBNL_ROUTE], [libnl-route-3.0], [], AC_MSG_ERROR([requires libnl3-route]))
|
||||||
;;
|
;;
|
||||||
|
@ -60,9 +60,11 @@ enum {
|
|||||||
#if defined __GNUC__
|
#if defined __GNUC__
|
||||||
#define __init __attribute__ ((constructor))
|
#define __init __attribute__ ((constructor))
|
||||||
#define __exit __attribute__ ((destructor))
|
#define __exit __attribute__ ((destructor))
|
||||||
|
#define __unused__ __attribute__ ((unused))
|
||||||
#else
|
#else
|
||||||
#define __init
|
#define __init
|
||||||
#define __exit
|
#define __exit
|
||||||
|
#define __unused__
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifdef DEBUG
|
#ifdef DEBUG
|
||||||
|
@ -34,7 +34,7 @@ in parallel. bmon automatically loads a useful and working input module
|
|||||||
by default. See INPUT MODULES for more details.
|
by default. See INPUT MODULES for more details.
|
||||||
.RE
|
.RE
|
||||||
.PP
|
.PP
|
||||||
\fB \-o\fR, \fB\-\-ouptut\fRMODULE[:OPTIONS][,MODULE...]
|
\fB \-o\fR, \fB\-\-output\fRMODULE[:OPTIONS][,MODULE...]
|
||||||
.RS 4
|
.RS 4
|
||||||
Set list of output modules to load and use. Multiple modules can be used
|
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
|
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
|
.PP
|
||||||
\fB \-U\fR, \fB\-\-use\-si\fR
|
\fB \-U\fR, \fB\-\-use\-si\fR
|
||||||
.RS 4
|
.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
|
.RE
|
||||||
.PP
|
.PP
|
||||||
\fB \-f\fR, \fB\-\-configfile=\fRFILE
|
\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.
|
The default is 1.0 seconds.
|
||||||
.RE
|
.RE
|
||||||
.PP
|
.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
|
\fB \-L\fR, \fB\-\-lifetime=\fRFLOAT
|
||||||
.RS 4
|
.RS 4
|
||||||
Set lifetime of an element in seconds before it is no longer displayed
|
Set lifetime of an element in seconds before it is no longer displayed
|
||||||
|
@ -7,6 +7,7 @@ bmon_CFLAGS = \
|
|||||||
-I${top_builddir}/include \
|
-I${top_builddir}/include \
|
||||||
-DSYSCONFDIR=\"$(sysconfdir)\" \
|
-DSYSCONFDIR=\"$(sysconfdir)\" \
|
||||||
-D_GNU_SOURCE \
|
-D_GNU_SOURCE \
|
||||||
|
-Wall \
|
||||||
$(CURSES_CFLAGS) \
|
$(CURSES_CFLAGS) \
|
||||||
$(CONFUSE_CFLAGS) \
|
$(CONFUSE_CFLAGS) \
|
||||||
$(LIBNL_CFLAGS) \
|
$(LIBNL_CFLAGS) \
|
||||||
|
@ -111,7 +111,7 @@ int attr_def_add(const char *name, const char *desc, struct unit *unit,
|
|||||||
return def->ad_id;
|
return def->ad_id;
|
||||||
}
|
}
|
||||||
|
|
||||||
void attr_def_free(struct attr_def *def)
|
static void attr_def_free(struct attr_def *def)
|
||||||
{
|
{
|
||||||
if (!def)
|
if (!def)
|
||||||
return;
|
return;
|
||||||
|
52
src/bmon.c
52
src/bmon.c
@ -33,8 +33,6 @@
|
|||||||
#include <bmon/group.h>
|
#include <bmon/group.h>
|
||||||
|
|
||||||
int start_time;
|
int start_time;
|
||||||
int do_quit = 0;
|
|
||||||
int is_daemon = 0;
|
|
||||||
|
|
||||||
struct reader_timing rtiming;
|
struct reader_timing rtiming;
|
||||||
|
|
||||||
@ -88,14 +86,7 @@ static void do_shutdown(void)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
RETSIGTYPE sig_int(int unused)
|
static void sig_exit(void)
|
||||||
{
|
|
||||||
if (do_quit)
|
|
||||||
exit(-1);
|
|
||||||
do_quit = 1;
|
|
||||||
}
|
|
||||||
|
|
||||||
void sig_exit(void)
|
|
||||||
{
|
{
|
||||||
do_shutdown();
|
do_shutdown();
|
||||||
}
|
}
|
||||||
@ -120,7 +111,7 @@ void quit(const char *fmt, ...)
|
|||||||
static inline void print_version(void)
|
static inline void print_version(void)
|
||||||
{
|
{
|
||||||
printf("bmon %s\n", PACKAGE_VERSION);
|
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("Copyright (C) 2013 Red Hat, Inc.\n");
|
||||||
printf("bmon comes with ABSOLUTELY NO WARRANTY. This is free " \
|
printf("bmon comes with ABSOLUTELY NO WARRANTY. This is free " \
|
||||||
"software, and you\nare welcome to redistribute it under " \
|
"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:";
|
char *gostr = "+:hvVf:";
|
||||||
|
|
||||||
struct option long_opts[] = {
|
struct option long_opts[] = {
|
||||||
{"help", 0, 0, 'h'},
|
{"help", 0, NULL, 'h'},
|
||||||
{"version", 0, 0, 'v'},
|
{"version", 0, NULL, 'v'},
|
||||||
{"configfile", 1, 0, 'f'},
|
{"configfile", 1, NULL, 'f'},
|
||||||
{0, 0, 0, 0},
|
{NULL, 0, NULL, 0},
|
||||||
};
|
};
|
||||||
int c = getopt_long(argc, argv, gostr, long_opts, NULL);
|
int c = getopt_long(argc, argv, gostr, long_opts, NULL);
|
||||||
if (c == -1)
|
if (c == -1)
|
||||||
@ -175,17 +166,17 @@ static int parse_args_post(int argc, char *argv[])
|
|||||||
"L:hvVf:";
|
"L:hvVf:";
|
||||||
|
|
||||||
struct option long_opts[] = {
|
struct option long_opts[] = {
|
||||||
{"input", 1, 0, 'i'},
|
{"input", 1, NULL, 'i'},
|
||||||
{"output", 1, 0, 'o'},
|
{"output", 1, NULL, 'o'},
|
||||||
{"policy", 1, 0, 'p'},
|
{"policy", 1, NULL, 'p'},
|
||||||
{"read-interval", 1, 0, 'r'},
|
{"read-interval", 1, NULL, 'r'},
|
||||||
{"rate-interval", 1, 0, 'R'},
|
{"rate-interval", 1, NULL, 'R'},
|
||||||
{"sleep-interval", 1, 0, 's'},
|
{"sleep-interval", 1, NULL, 's'},
|
||||||
{"show-all", 0, 0, 'a'},
|
{"show-all", 0, NULL, 'a'},
|
||||||
{"use-si", 0, 0, 'U'},
|
{"use-si", 0, NULL, 'U'},
|
||||||
{"use-bit", 0, 0, 'b'},
|
{"use-bit", 0, NULL, 'b'},
|
||||||
{"lifetime", 1, 0, 'L'},
|
{"lifetime", 1, NULL, 'L'},
|
||||||
{0, 0, 0, 0},
|
{NULL, 0, NULL, 0},
|
||||||
};
|
};
|
||||||
int c = getopt_long(argc, argv, gostr, long_opts, NULL);
|
int c = getopt_long(argc, argv, gostr, long_opts, NULL);
|
||||||
if (c == -1)
|
if (c == -1)
|
||||||
@ -220,7 +211,7 @@ static int parse_args_post(int argc, char *argv[])
|
|||||||
break;
|
break;
|
||||||
|
|
||||||
case 'a':
|
case 'a':
|
||||||
cfg_setint(cfg, "show_all", 1);
|
cfg_setbool(cfg, "show_all", cfg_true);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case 'U':
|
case 'U':
|
||||||
@ -269,9 +260,8 @@ int main(int argc, char *argv[])
|
|||||||
{
|
{
|
||||||
unsigned long sleep_time;
|
unsigned long sleep_time;
|
||||||
double read_interval;
|
double read_interval;
|
||||||
int unused;
|
|
||||||
|
|
||||||
start_time = time(0);
|
start_time = time(NULL);
|
||||||
memset(&rtiming, 0, sizeof(rtiming));
|
memset(&rtiming, 0, sizeof(rtiming));
|
||||||
rtiming.rt_variance.v_min = FLT_MAX;
|
rtiming.rt_variance.v_min = FLT_MAX;
|
||||||
|
|
||||||
@ -362,9 +352,6 @@ int main(int argc, char *argv[])
|
|||||||
output_post();
|
output_post();
|
||||||
}
|
}
|
||||||
|
|
||||||
if (do_quit)
|
|
||||||
exit(0);
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* ST := Configured ST
|
* ST := Configured ST
|
||||||
*/
|
*/
|
||||||
@ -400,5 +387,4 @@ int main(int argc, char *argv[])
|
|||||||
static void __init bmon_init(void)
|
static void __init bmon_init(void)
|
||||||
{
|
{
|
||||||
atexit(&sig_exit);
|
atexit(&sig_exit);
|
||||||
//signal(SIGINT, &sig_int);
|
|
||||||
}
|
}
|
||||||
|
@ -371,7 +371,7 @@ static void configfile_read_units(void)
|
|||||||
|
|
||||||
static void configfile_read_attrs(void)
|
static void configfile_read_attrs(void)
|
||||||
{
|
{
|
||||||
int i, nattrs, t;
|
int i, nattrs, t = 0;
|
||||||
|
|
||||||
nattrs = cfg_size(cfg, "attr");
|
nattrs = cfg_size(cfg, "attr");
|
||||||
|
|
||||||
|
@ -113,8 +113,9 @@ void element_parse_policy(const char *policy)
|
|||||||
xfree(copy);
|
xfree(copy);
|
||||||
}
|
}
|
||||||
|
|
||||||
struct element *__lookup_element(struct element_group *group, const char *name,
|
static struct element *__lookup_element(struct element_group *group,
|
||||||
uint32_t id, struct element *parent)
|
const char *name, uint32_t id,
|
||||||
|
struct element *parent)
|
||||||
{
|
{
|
||||||
struct list_head *list;
|
struct list_head *list;
|
||||||
struct element *e;
|
struct element *e;
|
||||||
|
20
src/graph.c
20
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);
|
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,
|
static void fill_table(struct graph *g, struct graph_table *tbl,
|
||||||
struct history *h, struct history_store *data)
|
struct history *h, struct history_store *data)
|
||||||
{
|
{
|
||||||
|
@ -185,7 +185,7 @@ static void dummy_parse_opt(const char *type, const char *value)
|
|||||||
c_numdev = strtol(value, NULL, 0);
|
c_numdev = strtol(value, NULL, 0);
|
||||||
else if (!strcasecmp(type, "randomize")) {
|
else if (!strcasecmp(type, "randomize")) {
|
||||||
c_randomize = 1;
|
c_randomize = 1;
|
||||||
srand(time(0));
|
srand(time(NULL));
|
||||||
} else if (!strcasecmp(type, "seed") && value)
|
} else if (!strcasecmp(type, "seed") && value)
|
||||||
srand(strtol(value, NULL, 0));
|
srand(strtol(value, NULL, 0));
|
||||||
else if (!strcasecmp(type, "mtu") && value)
|
else if (!strcasecmp(type, "mtu") && value)
|
||||||
|
122
src/in_netlink.c
122
src/in_netlink.c
@ -37,6 +37,8 @@ static int c_notc = 0;
|
|||||||
static struct element_group *grp;
|
static struct element_group *grp;
|
||||||
static struct bmon_module netlink_ops;
|
static struct bmon_module netlink_ops;
|
||||||
|
|
||||||
|
#include <linux/if.h>
|
||||||
|
|
||||||
#include <netlink/netlink.h>
|
#include <netlink/netlink.h>
|
||||||
#include <netlink/cache.h>
|
#include <netlink/cache.h>
|
||||||
#include <netlink/utils.h>
|
#include <netlink/utils.h>
|
||||||
@ -47,6 +49,17 @@ static struct bmon_module netlink_ops;
|
|||||||
#include <netlink/route/classifier.h>
|
#include <netlink/route/classifier.h>
|
||||||
#include <netlink/route/qdisc/htb.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[] = {
|
static struct attr_map link_attrs[] = {
|
||||||
{
|
{
|
||||||
.name = "bytes",
|
.name = "bytes",
|
||||||
@ -280,6 +293,14 @@ static struct attr_map link_attrs[] = {
|
|||||||
.rxid = RTNL_LINK_ICMP6_INERRORS,
|
.rxid = RTNL_LINK_ICMP6_INERRORS,
|
||||||
.txid = RTNL_LINK_ICMP6_OUTERRORS,
|
.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",
|
.name = "ip6inhdrerr",
|
||||||
.type = ATTR_TYPE_COUNTER,
|
.type = ATTR_TYPE_COUNTER,
|
||||||
@ -320,6 +341,14 @@ static struct attr_map link_attrs[] = {
|
|||||||
.rxid = RTNL_LINK_IP6_INADDRERRORS,
|
.rxid = RTNL_LINK_IP6_INADDRERRORS,
|
||||||
.txid = -1,
|
.txid = -1,
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
.name = "ip6csumerr",
|
||||||
|
.type = ATTR_TYPE_COUNTER,
|
||||||
|
.unit = UNIT_NUMBER,
|
||||||
|
.description = "Ip6 Checksum Error",
|
||||||
|
.rxid = RTNL_LINK_IP6_CSUMERRORS,
|
||||||
|
.txid = -1,
|
||||||
|
},
|
||||||
{
|
{
|
||||||
.name = "ip6reasmtimeo",
|
.name = "ip6reasmtimeo",
|
||||||
.type = ATTR_TYPE_COUNTER,
|
.type = ATTR_TYPE_COUNTER,
|
||||||
@ -351,6 +380,38 @@ static struct attr_map link_attrs[] = {
|
|||||||
.description = "Ip6 Reasm/Frag Requests",
|
.description = "Ip6 Reasm/Frag Requests",
|
||||||
.rxid = RTNL_LINK_IP6_REASMREQDS,
|
.rxid = RTNL_LINK_IP6_REASMREQDS,
|
||||||
.txid = RTNL_LINK_IP6_FRAGCREATES,
|
.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 rdata {
|
||||||
|
struct nl_cache * class_cache;
|
||||||
struct element * parent;
|
struct element * parent;
|
||||||
int level;
|
int level;
|
||||||
};
|
};
|
||||||
|
|
||||||
static struct nl_sock *sock;
|
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)
|
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 handle_qdisc(struct nl_object *obj, void *);
|
||||||
static void find_classes(uint32_t, struct rdata *);
|
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,
|
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];
|
char buf[IFNAME_MAX], name[IFNAME_MAX];
|
||||||
uint32_t id = rtnl_tc_get_handle(tc);
|
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)",
|
snprintf(name, sizeof(name), "%s %s (%s)",
|
||||||
prefix, buf, rtnl_tc_get_kind(tc));
|
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;
|
return NULL;
|
||||||
|
|
||||||
if (e->e_flags & ELEMENT_FLAG_CREATED) {
|
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") ||
|
if (element_set_key_attr(e, "tc_bytes", "tc_packets") ||
|
||||||
element_set_usage_attr(e, "tc_bytes"))
|
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 rtnl_tc *tc = (struct rtnl_tc *) obj;
|
||||||
struct element *e;
|
struct element *e;
|
||||||
struct rdata *rdata = arg;
|
const struct rdata *rdata = arg;
|
||||||
struct rdata ndata = {
|
struct rdata ndata = {
|
||||||
|
.class_cache = rdata->class_cache,
|
||||||
.level = rdata->level + 1,
|
.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));
|
element_set_txmax(e, rtnl_htb_get_rate((struct rtnl_class *) tc));
|
||||||
|
|
||||||
find_classes(rtnl_tc_get_handle(tc), &ndata);
|
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;
|
struct rtnl_qdisc *filter;
|
||||||
|
|
||||||
@ -543,6 +609,7 @@ static void find_qdiscs(uint32_t parent, struct rdata *rdata)
|
|||||||
return;
|
return;
|
||||||
|
|
||||||
rtnl_tc_set_parent((struct rtnl_tc *) filter, parent);
|
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),
|
nl_cache_foreach_filter(qdisc_cache, OBJ_CAST(filter),
|
||||||
handle_qdisc, rdata);
|
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);
|
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);
|
handle_class, rdata);
|
||||||
|
|
||||||
rtnl_class_put(filter);
|
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 rtnl_tc *tc = (struct rtnl_tc *) obj;
|
||||||
struct element *e;
|
struct element *e;
|
||||||
struct rdata *rdata = arg;
|
const struct rdata *rdata = arg;
|
||||||
struct rdata ndata = {
|
struct rdata ndata = {
|
||||||
|
.class_cache = rdata->class_cache,
|
||||||
.level = rdata->level + 1,
|
.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)
|
static void handle_tc(struct element *e, struct rtnl_link *link)
|
||||||
{
|
{
|
||||||
struct rtnl_qdisc *qdisc;
|
struct rtnl_qdisc *qdisc;
|
||||||
|
struct nl_cache *class_cache;
|
||||||
int ifindex = rtnl_link_get_ifindex(link);
|
int ifindex = rtnl_link_get_ifindex(link);
|
||||||
struct rdata rdata = {
|
struct rdata rdata = {
|
||||||
.level = 1,
|
.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)
|
if (rtnl_class_alloc_cache(sock, ifindex, &class_cache) < 0)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
|
rdata.class_cache = class_cache;
|
||||||
|
|
||||||
qdisc = rtnl_qdisc_get_by_parent(qdisc_cache, ifindex, TC_H_ROOT);
|
qdisc = rtnl_qdisc_get_by_parent(qdisc_cache, ifindex, TC_H_ROOT);
|
||||||
if (qdisc) {
|
if (qdisc) {
|
||||||
handle_qdisc(OBJ_CAST(qdisc), &rdata);
|
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);
|
attr_update(e, m->attrid, c_rx, c_tx, flags);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!c_notc)
|
if (!c_notc && qdisc_cache)
|
||||||
handle_tc(e, link);
|
handle_tc(e, link);
|
||||||
|
|
||||||
element_notify_update(e, NULL);
|
element_notify_update(e, NULL);
|
||||||
@ -752,7 +823,8 @@ static void netlink_read(void)
|
|||||||
goto disable;
|
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));
|
fprintf(stderr, "Unable to resync qdisc cache: %s\n", nl_geterror(err));
|
||||||
goto disable;
|
goto disable;
|
||||||
}
|
}
|
||||||
@ -772,9 +844,20 @@ static void netlink_shutdown(void)
|
|||||||
nl_socket_free(sock);
|
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)
|
static int netlink_do_init(void)
|
||||||
{
|
{
|
||||||
int err, i;
|
int err;
|
||||||
|
|
||||||
if (!(sock = nl_socket_alloc())) {
|
if (!(sock = nl_socket_alloc())) {
|
||||||
fprintf(stderr, "Unable to allocate netlink socket\n");
|
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) {
|
if ((err = rtnl_qdisc_alloc_cache(sock, &qdisc_cache)) < 0) {
|
||||||
fprintf(stderr, "Unable to allocate qdisc cache: %s\n", nl_geterror(err));
|
fprintf(stderr, "Warning: Unable to allocate qdisc cache: %s\n", nl_geterror(err));
|
||||||
goto disable;
|
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)) ||
|
if (attr_map_load(link_attrs, ARRAY_SIZE(link_attrs)) ||
|
||||||
attr_map_load(tc_attrs, ARRAY_SIZE(tc_attrs)))
|
attr_map_load(tc_attrs, ARRAY_SIZE(tc_attrs)))
|
||||||
BUG();
|
BUG();
|
||||||
@ -817,17 +903,17 @@ static int netlink_probe(void)
|
|||||||
|
|
||||||
if (!(sock = nl_socket_alloc()))
|
if (!(sock = nl_socket_alloc()))
|
||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
if (nl_connect(sock, NETLINK_ROUTE) < 0)
|
if (nl_connect(sock, NETLINK_ROUTE) < 0)
|
||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
if (rtnl_link_alloc_cache(sock, AF_UNSPEC, &lc) == 0) {
|
if (rtnl_link_alloc_cache(sock, AF_UNSPEC, &lc) == 0) {
|
||||||
nl_cache_free(lc);
|
nl_cache_free(lc);
|
||||||
ret = 1;
|
ret = 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
nl_socket_free(sock);
|
nl_socket_free(sock);
|
||||||
|
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -101,7 +101,7 @@ static void proc_read(void)
|
|||||||
{
|
{
|
||||||
struct element *e;
|
struct element *e;
|
||||||
FILE *fd;
|
FILE *fd;
|
||||||
char buf[512], *p, *s, *unused;
|
char buf[512], *p, *s, *unused __unused__;
|
||||||
int w;
|
int w;
|
||||||
|
|
||||||
if (!(fd = fopen(c_path, "r")))
|
if (!(fd = fopen(c_path, "r")))
|
||||||
|
@ -163,6 +163,7 @@ sysctl_read(void)
|
|||||||
struct element *e, *e_parent = NULL;
|
struct element *e, *e_parent = NULL;
|
||||||
struct if_msghdr *ifm, *nextifm;
|
struct if_msghdr *ifm, *nextifm;
|
||||||
struct sockaddr_dl *sdl;
|
struct sockaddr_dl *sdl;
|
||||||
|
char info_buf[64];
|
||||||
|
|
||||||
ifm = (struct if_msghdr *) next;
|
ifm = (struct if_msghdr *) next;
|
||||||
if (ifm->ifm_type != RTM_IFINFO)
|
if (ifm->ifm_type != RTM_IFINFO)
|
||||||
@ -225,6 +226,18 @@ sysctl_read(void)
|
|||||||
attr_update(e, m->attrid, rx, tx, flags);
|
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_notify_update(e, NULL);
|
||||||
element_lifesign(e, 1);
|
element_lifesign(e, 1);
|
||||||
}
|
}
|
||||||
|
@ -130,7 +130,6 @@ static void __auto_load(struct bmon_module *m)
|
|||||||
int module_set(struct bmon_subsys *ss, const char *name)
|
int module_set(struct bmon_subsys *ss, const char *name)
|
||||||
{
|
{
|
||||||
struct bmon_module *mod;
|
struct bmon_module *mod;
|
||||||
struct list_head *list;
|
|
||||||
LIST_HEAD(tmp_list);
|
LIST_HEAD(tmp_list);
|
||||||
module_conf_t *m;
|
module_conf_t *m;
|
||||||
|
|
||||||
|
@ -137,7 +137,7 @@ static void apply_layout(int layout)
|
|||||||
attrset(cfg_layout[layout].l_attr);
|
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);
|
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;
|
va_list args;
|
||||||
char buf[2048];
|
char buf[2048];
|
||||||
int x, y;
|
int x, y __unused__;
|
||||||
|
|
||||||
memset(buf, 0, sizeof(buf));
|
memset(buf, 0, sizeof(buf));
|
||||||
getyx(stdscr, y, x);
|
getyx(stdscr, y, x);
|
||||||
@ -430,7 +430,7 @@ static void draw_statusbar(void)
|
|||||||
{
|
{
|
||||||
static const char *help_text = "Press ? for help";
|
static const char *help_text = "Press ? for help";
|
||||||
char s[27];
|
char s[27];
|
||||||
time_t t = time(0);
|
time_t t = time(NULL);
|
||||||
|
|
||||||
apply_layout(LAYOUT_STATUSBAR);
|
apply_layout(LAYOUT_STATUSBAR);
|
||||||
|
|
||||||
|
@ -119,11 +119,8 @@ static char *get_token(struct element_group *g, struct element *e,
|
|||||||
goto out;
|
goto out;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!(a = attr_lookup(e, def->ad_id))) {
|
if (!(a = attr_lookup(e, def->ad_id)))
|
||||||
fprintf(stderr, "Unable to find attribute %u (%s)\n",
|
|
||||||
def->ad_id, name);
|
|
||||||
goto out;
|
goto out;
|
||||||
}
|
|
||||||
|
|
||||||
if (!strncasecmp(type, "rx:", 3)) {
|
if (!strncasecmp(type, "rx:", 3)) {
|
||||||
snprintf(buf, len, "%" PRIu64, a->a_rx_rate.r_total);
|
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)
|
if (out_tokens == NULL)
|
||||||
quit("Cannot reallocate out token array\n");
|
quit("Cannot reallocate out token array\n");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
out_tokens[token_index].ot_type = type;
|
out_tokens[token_index].ot_type = type;
|
||||||
out_tokens[token_index].ot_str = data;
|
out_tokens[token_index].ot_str = data;
|
||||||
token_index++;
|
token_index++;
|
||||||
@ -250,7 +247,7 @@ static int format_probe(void)
|
|||||||
}
|
}
|
||||||
|
|
||||||
goto out;
|
goto out;
|
||||||
|
|
||||||
finish_escape:
|
finish_escape:
|
||||||
*p = '\0';
|
*p = '\0';
|
||||||
add_token(OT_STRING, s);
|
add_token(OT_STRING, s);
|
||||||
@ -259,7 +256,7 @@ finish_escape:
|
|||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
out:
|
out:
|
||||||
if (new_one) {
|
if (new_one) {
|
||||||
add_token(OT_STRING, p);
|
add_token(OT_STRING, p);
|
||||||
new_one = 0;
|
new_one = 0;
|
||||||
@ -328,9 +325,9 @@ static void print_help(void)
|
|||||||
" \"$(element:name) $(attr:rxrate:packets) $(attr:txrate:packets)\\n\"\n" \
|
" \"$(element:name) $(attr:rxrate:packets) $(attr:txrate:packets)\\n\"\n" \
|
||||||
" eth0 33 5\n" \
|
" eth0 33 5\n" \
|
||||||
"\n" \
|
"\n" \
|
||||||
" \"Element: $(element:name)\\nBytes Rate: \" \\\n" \
|
" \"Item: $(element:name)\\n\" \\\n" \
|
||||||
" \"$(attr:rxrate:bytes)/$(attr:txrate:bytes)\\nPackets Rate: \" \\\n" \
|
" \"Bytes Rate: $(attr:rxrate:bytes)/$(attr:txrate:bytes)\\n\" \\\n" \
|
||||||
" \"$(attr:rxrate:packets)/$(attr:txrate:packets)\\n\"\n" \
|
" \"Packets Rate: $(attr:rxrate:packets)/$(attr:txrate:packets)\\n\"\n" \
|
||||||
" Item: eth0\n" \
|
" Item: eth0\n" \
|
||||||
" Bytes Rate: 49130/2119\n" \
|
" Bytes Rate: 49130/2119\n" \
|
||||||
" Packets Rate: 40/11\n" \
|
" Packets Rate: 40/11\n" \
|
||||||
|
@ -28,7 +28,7 @@
|
|||||||
#include <bmon/utils.h>
|
#include <bmon/utils.h>
|
||||||
#include <bmon/unit.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);
|
static LIST_HEAD(units);
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user