Code Monkey home page Code Monkey logo

bwm-ng's People

Contributors

dreibh avatar fweimer-rh avatar moto-timo avatar ofalk avatar samueloph avatar soapgentoo avatar vgropp avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

bwm-ng's Issues

Json output

Hi and congrats for such tool
Would be great to have a JSON output as well since most things nowdays parse Json
Regards

Logic for the DYNAMIC option seems to be inverted

bwm-ng's manpage says:

       -d, --dynamic [value]
              shows bytes and bits with dynamic unit like K,  M  or  G  (Kilo,
              Mega,  Giga).   value  can be 0 (off) or 1 (on), without a value
              '1' is used.

So we can understand that, to enable the dynamic values, we need to set it to 1

Then we have:

CONFIGFILE
       The behavior of bwm-ng can be also  controlled  by  a  configfile.   By
       default bwm-ng first reads /etc/bwm-ng.conf and then ~/.bwm-ng.conf. If
       specified on command line bwm-ng skips those.  It consists of the  same
       long-options as used for command line as keys followed by a '=' and the
       value. Lines starting with a # or unknown key will be ignored.

       For example:
       DYNAMIC=1
       UNIT=bits
       PROCFILE=/proc/net/dev
       OUTPUT=plain

Which also confirms that, to have dynamic value, we should set it to 1

But when using DYNAMIC=1 in ~/.bwm-ng.conf it doesn't work. It only works when using DYNAMIC=0

It seems that the logic is inverted.
Maybe it's this part in `src/options.c:213?

    } else if( strcasecmp( token, "DYNAMIC" ) == 0 ) {
        if (value) dynamic=value[0]=='0' ? 1 : 0;

bwm-ng.c build failure

I try to update in openSUSE bwm-ng from 0.6 to 0.6.1

Get these build failures

[   44s] + make -j4
[   44s] make  all-recursive
[   44s] make[1]: Entering directory '/home/abuild/rpmbuild/BUILD/bwm-ng-0.6.1'
[   44s] Making all in src
[   44s] make[2]: Entering directory '/home/abuild/rpmbuild/BUILD/bwm-ng-0.6.1/src'
[   44s] gcc -DHAVE_CONFIG_H -I. -I..     -fmessage-length=0 -grecord-gcc-switches -O2 -Wall -D_FORTIFY_SOURCE=2 -fstack-protector -funwind-tables -fasynchronous-unwind-tables -g -c -o bwm-ng.o bwm-ng.c
[   44s] gcc -DHAVE_CONFIG_H -I. -I..     -fmessage-length=0 -grecord-gcc-switches -O2 -Wall -D_FORTIFY_SOURCE=2 -fstack-protector -funwind-tables -fasynchronous-unwind-tables -g -c -o process.o process.c
[   44s] gcc -DHAVE_CONFIG_H -I. -I..     -fmessage-length=0 -grecord-gcc-switches -O2 -Wall -D_FORTIFY_SOURCE=2 -fstack-protector -funwind-tables -fasynchronous-unwind-tables -g -c -o output.o output.c
[   44s] gcc -DHAVE_CONFIG_H -I. -I..     -fmessage-length=0 -grecord-gcc-switches -O2 -Wall -D_FORTIFY_SOURCE=2 -fstack-protector -funwind-tables -fasynchronous-unwind-tables -g -c -o options.o options.c
[   45s] bwm-ng.c: In function 'main':
[   45s] bwm-ng.c:197:6: error: too many arguments to function 'sg_init'
[   45s]   if (sg_init(0) != 0) {
[   45s]       ^
[   45s] In file included from input/libstatgrab.h:30:0,
[   45s]                  from input/retrieve.h:57,
[   45s]                  from bwm-ng.h:32,
[   45s]                  from bwm-ng.c:25:
[   45s] /usr/include/statgrab.h:37:5: note: declared here
[   45s]  int sg_init(void);
[   45s]      ^
[   45s] Makefile:374: recipe for target 'bwm-ng.o' failed
[   45s] make[2]: *** [bwm-ng.o] Error 1
[   45s] make[2]: *** Waiting for unfinished jobs....
[   45s] make[2]: Leaving directory '/home/abuild/rpmbuild/BUILD/bwm-ng-0.6.1/src'
[   45s] Makefile:434: recipe for target 'all-recursive' failed
[   45s] make[1]: *** [all-recursive] Error 1
[   45s] make[1]: Leaving directory '/home/abuild/rpmbuild/BUILD/bwm-ng-0.6.1'
[   45s] Makefile:332: recipe for target 'all' failed
[   45s] make: *** [all] Error 2

Please correct this, thanks.

output buffer to zero ?

Hello,

I launch bwm-ng collectors (rate + max for nic + disk) as background service.
bwm-ng writes directly to /var/log in CSV format.

Commands:
/usr/bin/bwm-ng -i proc -t 1000 -A 10 -o csv -D 1 -C ; -N -d --procfile /proc/net/dev -F /var/log/bwmNG-net-max.log -T max
/usr/bin/bwm-ng -i proc -t 1000 -A 10 -o csv -D 1 -C ; -N -d --procfile /proc/net/dev -F /var/log/bwmNG-net-rate.log -T rate
/usr/bin/bwm-ng -i disk -t 1000 -A 10 -o csv -D 1 -C ; -N -d MB --diskstatsfile /proc/diskstats --partitionsfile /proc/partitions -I sdc sdb1 sdb2 -F /var/log/bwmNG-disk-max.log -T max
/usr/bin/bwm-ng -i disk -t 1000 -A 10 -o csv -D 1 -C ; -N -d MB --diskstatsfile /proc/diskstats --partitionsfile /proc/partitions -I sdc sdb1 sdb2 -F /var/log/bwmNG-disk-rate.log -T rate

Reading my monitoring script supposed to provide 'secondly' information, I see in real bwm-ng updates the output not in realtime but apparently each 20s (adding 40 lines, 1 for disk + total).

Could it be possible to set a zero size output buffer to have 'realtime' updates ?

Thanks

Brgrds

CSV output: timestamp inaccuracy and Y-2038 problem

bwm-ng has two issues with the unix timestamp written for CSV output:

  • It uses (int)time(NULL) -> With 32-bit "int" type, it has the Y-2038 problem.
  • Calling "bwm-ng -o csv -F x.csv" causes bwm-ng to write 2 measurements per second (i.e. every 0.5 seconds), but the time stamp granularity is 1 second => two measurements for the same time stamp.

New release?

bwm-ng fails to build with gcc 7 and this already fixed on master. Please bump new release.

mips-openwrt-linux-musl-gcc  -Os -pipe -mno-branch-likely -mips32r2 -mtune=24kc -fno-caller-saves -fno-plt -fhonour-copts -Wno-error=unused-but-set-variable -Wno-error=unused-result -msoft-float -mips16 -minterlink-mips16 -ir
emap/srv/raid/filez/builder/lede/build_dir/target-mips_24kc_musl/bwm-ng-0.6.1:bwm-ng-0.6.1 -Wformat -Werror=format-security -fstack-protector -D_FORTIFY_SOURCE=1 -Wl,-z,now -Wl,-z,relro   -L/srv/raid/filez/builder/lede/stagin
g_dir/target-mips_24kc_musl/usr/lib -L/srv/raid/filez/builder/lede/staging_dir/target-mips_24kc_musl/lib -L/srv/raid/filez/builder/lede/staging_dir/toolchain-mips_24kc_gcc-7.1.0_musl/usr/lib -L/srv/raid/filez/builder/lede/sta
ging_dir/toolchain-mips_24kc_gcc-7.1.0_musl/lib -znow -zrelro  -o bwm-ng bwm-ng.o process.o output.o options.o help.o curses_tools.o retrieve.o proc_net_dev.o proc_diskstats.o                                                  
bwm-ng.o: In function `main':                                                                   
bwm-ng.c:(.text.startup+0x4): undefined reference to `init'                
process.o: In function `save_avg':                                         
process.c:(.text+0x488): undefined reference to `save_avg_values'                               
process.c:(.text+0x4a4): undefined reference to `save_avg_values'                               
process.c:(.text+0x4c0): undefined reference to `save_avg_values'          
process.c:(.text+0x4fc): undefined reference to `save_avg_values'          
process.c:(.text+0x518): undefined reference to `save_avg_values'          
process.o:process.c:(.text+0x534): more undefined references to `save_avg_values' follow                        
process.o: In function `save_avg':                                         
process.c:(.text+0x570): undefined reference to `sub_avg_values'           
process.c:(.text+0x584): undefined reference to `sub_avg_values'           
process.c:(.text+0x598): undefined reference to `sub_avg_values'           
process.o: In function `process_if_data':                                                       
process.c:(.text+0x89c): undefined reference to `save_max'                                      
process.c:(.text+0x8b8): undefined reference to `save_max'                                      
process.c:(.text+0x8d4): undefined reference to `save_max'                                      
process.o: In function `finish_iface_stats':                                                    
process.c:(.text+0xc54): undefined reference to `save_max'                                                      
process.c:(.text+0xc68): undefined reference to `save_max'                                                      
process.o:process.c:(.text+0xc7c): more undefined references to `save_max' follow                               
output.o: In function `print_header':                   
output.c:(.text+0x46): undefined reference to `input2str'                                                       
output.c:(.text+0x54): undefined reference to `show_all_if2str'                                                 
output.o: In function `values2str':                     
output.c:(.text+0x180): undefined reference to `direction2value'                                                
output.c:(.text+0x1ca): undefined reference to `direction2value'                                                
output.c:(.text+0x1ea): undefined reference to `direction_max2value'                                            
output.c:(.text+0x262): undefined reference to `direction2value'                                                
output.c:(.text+0x2a2): undefined reference to `dyn_bit_value2str'                                              
output.c:(.text+0x2d4): undefined reference to `direction2value'                                                
output.c:(.text+0x2f4): undefined reference to `direction_max2value'                                            
output.c:(.text+0x31e): undefined reference to `dyn_byte_value2str'                                             
output.c:(.text+0x366): undefined reference to `direction2value'                                                
output.c:(.text+0x3a2): undefined reference to `direction2value'
output.c:(.text+0x3c2): undefined reference to `direction_max2value'
options.o: In function `get_cmdln_options':
options.c:(.text+0x1fa): undefined reference to `str2in_method'
options.c:(.text+0x230): undefined reference to `str2out_method'
options.c:(.text+0x23c): undefined reference to `str2output_type'
options.c:(.text+0x276): undefined reference to `str2output_unit'
collect2: error: ld returned 1 exit status
make[6]: *** [Makefile:333: bwm-ng] Error 1
make[6]: Leaving directory '/srv/raid/filez/builder/lede/build_dir/target-mips_24kc_musl/bwm-ng-0.6.1/src'
make[5]: *** [Makefile:425: all-recursive] Error 1
make[5]: Leaving directory '/srv/raid/filez/builder/lede/build_dir/target-mips_24kc_musl/bwm-ng-0.6.1'
make[4]: *** [Makefile:322: all] Error 2
make[4]: Leaving directory '/srv/raid/filez/builder/lede/build_dir/target-mips_24kc_musl/bwm-ng-0.6.1'
make[3]: *** [Makefile:64: /srv/raid/filez/builder/lede/build_dir/target-mips_24kc_musl/bwm-ng-0.6.1/.built] Error 2
make[3]: Leaving directory '/srv/raid/filez/builder/lede/feeds/packages/net/bwm-ng'
make[2]: *** [package/Makefile:111: package/feeds/packages/bwm-ng/compile] Error 2
make[2]: Leaving directory '/srv/raid/filez/builder/lede'
make[1]: *** [package/Makefile:105: /srv/raid/filez/builder/lede/staging_dir/target-mips_24kc_musl/stamp/.package_compile] Error 2
make[1]: Leaving directory '/srv/raid/filez/builder/lede'
make: *** [/srv/raid/filez/builder/lede/include/toplevel.mk:209: world] Error 2

Averages break when window is resized

In an SSH prompt (I'm using PuTTY), viewing averages (either by switching the type after launching the program or by launching with '-T avg') and then resizing the window in any way causes all the numbers to get stuck at -nan.

Cycling inputs ('n' key) fixes this until the next resize event.

Actually, it also seems to break when 's' is pressed or the up arrow is pressed. It might happen with other toggles as well.

$ lsb_release -a
No LSB modules are available.
Distributor ID: Ubuntu
Description: Ubuntu 16.04.3 LTS
Release: 16.04
Codename: xenial

$ uname -a
Linux vishnu 4.13.0-32-generic #35~16.04.1-Ubuntu SMP Thu Jan 25 10:13:43 UTC 2018 x86_64 x86_64 x86_64 GNU/Linux

Request - add column in display for corresponding IP address of interface

Would it be possible to have the output include a column that displays of the corresponding IP address for a given interface? This would be really handy for systems with many interfaces.

For example, something like the following:

bwm-ng v0.6.X (probing every 0.500s), press 'h' for help
  input: /proc/net/dev type: rate
  |             ip        iface                  Rx                 Tx                    Total
  =============================================================================================
     192.168.1.254       ens20:           4.28 kb/s            0.00 kb/s              4.28 kb/s
     192.168.2.254       ens23:      390620.64 kb/s       375944.06 kb/s         766564.67 kb/s
     192.168.3.254        ens1:      374566.66 kb/s       390539.07 kb/s         765105.73 kb/s
     192.168.4.254       ens22:        2183.31 kb/s       184439.30 kb/s         186622.61 kb/s
     192.168.5.254       ens19:      370634.37 kb/s         4291.27 kb/s         374925.60 kb/s
     192.168.6.254       ens21:        2188.39 kb/s        184456.69 kb/s        186645.09 kb/s
     127.0.0.1              lo:           0.00 kb/s             0.00 kb/s             0.00 kb/s
     192.168.8.254       ens18:           0.96 kb/s             9.61 kb/s            10.57 kb/s
  ---------------------------------------------------------------------------------------------
                         total:      1140198.53 kb/s       1139680.00 kb/s       2279878.66 kb/s

Vulnerability? Bug? Null write in the get_cmdln_options function in src/options.c.

Hi,

In src/options.c, line 337.

// malloc() may fail, and str will be NULL.
str=(char*)malloc(strlen(pwd_entry->pw_dir)+14);
// write to Null
snprintf(str,strlen(pwd_entry->pw_dir)+14,"%s/.bwm-ng.conf",pwd_entry->pw_dir);

I think this is a vulnerability, and maybe we can patch it as following?

str=(char*)malloc(strlen(pwd_entry->pw_dir)+14);
if(!str) return

Thanks for any consideration!

Peiyu Liu,
NESA lab,
Zhejiang University

Sorting the list

I've managed to grep and cut the list of interfaces down from 94 to 18 and input them nicely sorted to the -I parameter, alas in the curses list they're reordered (presumably in the order found by /proc/net/dev).

Could I have an option to either sort by order given in -I or plain old ascii+numerical sort?

thanks!

Fixed Y-axis scale with curses2 output

Having the Y-axis scale is not very useful in some cases - even if the traffic is not very high, the bar 'jumps' to the maximum a lot.

Could we have parameters -min-bandwidth and -max-bandwidth, so that the scale would be fixed between these two?

flush outfile data

Hello,

I integrated bwmNG to monitor my Vigrid NAS. It works perfectly under Ubuntu.
Because Linux has nfsd process load issues, I moved to FreeBSD and update to fit into it.

I detected 2 issues with bwmng. When launching, in shell:
/usr/local/bin/bwm-ng -i devstat -t 1000 -o csv -D 1 -C ';' -N -d MB -I da0p3 -F /var/log/bwmNG-disk-max.log -T max

  1. -D 1 is supposed to turn it to daemon, it does nothing as -D 0, but I can workaround that, did with Linux.

  2. Much more problematic : data is not flushed 'realtime' into the -F file. Apparently it takes roughly 5 minutes to update the physical file. However, all data is present, seems to just be an output buffering. I would suggest to add an output buffering to zero into the program.

Thanks

Brgrds

checking for netstat version... unknown netstat version - disabled

./configure asked me to send you the output of netstat -i so fyi:

netstat -i
Kernel Interface table
Iface MTU RX-OK RX-ERR RX-DRP RX-OVR TX-OK TX-ERR TX-DRP TX-OVR Flg
eno1 1500 49629382 0 8 0 47076697 0 0 0 BMRU
eno2 1500 0 0 0 0 0 0 0 0 BMU
lo 65536 36376 0 0 0 36376 0 0 0 LRU
tun0 1500 11838865 0 0 0 21192577 0 0 0 MOPRU

from:

cat /etc/centos-release
CentOS Linux release 7.2.1511 (Core)

and also thank you for this awesome utility.

"-D 1" daemonize not working

Hi, so I was trying to use bwm-ng by launching it in the background and keeping track of the bandwidth usage. I tried in an alpine container, but for some reason it still grabs my shell and doesn't really fork into a background process. I thought this could be a alpine related problem, so I tried in a Ubuntu 19 (non container) and it behaved the same. So then I thought it could be an old version in the ubuntu repositories so I downloaded from git and built it myself. Same behaviour. No fork at all and holds my shell, by this I mean it produces measurements, but not in the background.

This is the command I ran:
bwm-ng -t 1000 -I eth0 -o csv -c 10 -u bytes -T rate -F bandwidth_measures.csv -D 1

Thank you.

rt_acct input

There is some rarely used and somehow limited (to 256 values), almost abandoned, but still pretty nice feature of Linux network stack being route realms. Unfortunately, except for rtacct, there's virtually no tools to help visualize them.

Therefore I issue this RFE, as watching these counters online would perfectly fit bwm-ng.

Support console resize better

I use a tiling window manager. If I add a window, the bwm-ng resizes, and all numbers go to -nan/nan/-inf/inf. Depending on the mode, the output may self-correct. For example, 'rate' fixes this on the next update, while 'avg' leaves nan/inf forever.

Edit: In case this is needed for repro, I'm typically using bwm-ng inside tmux over ssh

Output via pipe

When I run bwm-ng, e.g. like so:
bwm-ng -I ens9 -u bits -o csv -t 1000 | cat
The output is buffered massively, if I pass it through script or stdbuf I get the output straight away:
script -q -f -c "bwm-ng -I ens9 -u bits -o csv -t 1000" | cat
or:
stdbuf -oL -eL bwm-ng -I ens9 -u bits -o csv -t 1000 | cat

I know it's a non-trivial fix, but could you either
a) fix it
b) document the workaround so others can find it easily!

Obviously I'm not using cat but another program to analyze the csv output (and removing the total lines)...

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    πŸ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. πŸ“ŠπŸ“ˆπŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❀️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.