bwm-ng icon indicating copy to clipboard operation
bwm-ng copied to clipboard

flush outfile data

Open llevier opened this issue 3 years ago • 13 comments
trafficstars

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

llevier avatar Jul 22 '22 13:07 llevier

just a wild guess without currently being able to check it, -D need #ifdef HAVE_FORK, is it enabled in your config.h? There should be flushing using fflush (https://www.freebsd.org/cgi/man.cgi?query=fflush&sektion=3&apropos=0&manpath=freebsd), are other outputs working (rate, etc)?

vgropp avatar Jul 26 '22 12:07 vgropp

Hello,

For fork(), please notice I did not install the port from source tree but from pkg. However, I could build it if you wish.

For both issues, I could also have updated the code to flush data upon write (simple setting output buffer to zero btw).

Because of that, I think it was best to raise you an issue, so you can setup a generic solution (forced flush, new argument...) for FreeBSD.

If you want I try to solve that by myself, just tell me.

Thanks

Brgrds

llevier avatar Jul 27 '22 07:07 llevier

I welcome PR especially for non linux systems.

vgropp avatar Jul 27 '22 09:07 vgropp

Ok, I reinstall it from source ports tree.

Upon correction, I'll submit them to the maintainer per FreeBSD process, giving you the diff as well :-)

I also have a suggestion : sometimes disk is overloaded with IOps. Maybe a IO option for bwmng ? :-)

+++

llevier avatar Jul 28 '22 09:07 llevier

Hello,

Ok, I updated output.c, after your switch of output_method (line 254 on 570), simply adding fflush(tmp_out_file):

    // Laurent LEVIER patch for FreeBSD to force immediate flush of written data
    fflush(tmp_out_file);

It demonstrates the solving of the issue for this point. However, looks like a dirty work to me, it might not be needed at all times. I would suggest to add -f flag to fflush stream when needed. What do you think ?

Still the -D issue, I'll check that now.

+++

llevier avatar Jul 29 '22 06:07 llevier

Hello,

Maybe I mistake but to me there are many issues with bwmNG under FreeBSD 13. Let me summ some I saw and sometimes handled:

1- device names are not correct. I just get 'da', without its logical value, and so I cant select a specific device

2- The fflush() is now an -z option to force flush at write time. So anyone can manage :-)

3- -D fails but under FreeBSD the 'daemon' command handles this bug, so I took no action.

4- There are bugs in the getopt management. For example I set -d -F, output normally fails but in real bwmNG should report -d is missing a value... I did not managed this, just detected.

Here are the patches I created. Please advise if you integrate them into your code, meaning I will not send them to the FreeBSD port maintainer:

patch-src__defines.txt patch-src__global_vars.txt patch-src__input__devstat.txt patch-src__options.txt patch-src__output.txt

Thanks

Brgrds

llevier avatar Aug 02 '22 12:08 llevier

Hi, can you create a github Pull Request? Merging would be easier that way. https://gist.github.com/Chaser324/ce0505fbed06b947d962

vgropp avatar Aug 03 '22 07:08 vgropp

Hello,

I am not truly familiar with this git stuff and the URL you give is for maintainer, not anonymous public. I just use git for my CyberRange, but as owner of the branch, much easier :-)

At the moment, I am able to submit the changes to you but: git push --set-upstream origin freebsd13-llevier

remote: Permission to vgropp/bwm-ng.git denied to llevier. fatal: unable to access 'https://github.com/vgropp/bwm-ng.git/': The requested URL returned error: 403

llevier avatar Aug 03 '22 08:08 llevier

ok, ill look into the patches later

vgropp avatar Aug 03 '22 08:08 vgropp

no pb. FYI, each patch applied perfectly into the git as well (in case FreeBSD was not taking it another way).

Please keep me posted so I know the end of the story :-)

llevier avatar Aug 03 '22 09:08 llevier

Hello,

Got some feedback for me ? :-) It would also be a great new source of infos to collect disk I/O. It is a major bottleneck most of times missed (disk bandwidth is not everything) :-)

Thanks

Brgrds

llevier avatar Aug 18 '22 14:08 llevier

not yet, but its on my todo list

vgropp avatar Aug 23 '22 11:08 vgropp

hi, sorry for the long delay, i included the devstat device number fix and change the fflush() a bit to not use in when printing the header but always flush with CSV or HTML out as this seemed to be missing. Does it fix your output issue?

I did not get your -z option, it was set but never used in your patches

vgropp avatar Sep 24 '22 13:09 vgropp