scottchiefbaker / dool

Python3 compatible fork of dstat
GNU General Public License v3.0
323 stars 64 forks source link

When specfying `--output `-dool still prints on stdout #8

Closed mucholove closed 1 year ago

mucholove commented 3 years ago

When specfying --output-dool still prints on stdout.

I expected dool to exclusivley print to a file.

I fixed this on my local version by introducing an if statement inside the perform function. (~/2868)

if op.output and step == op.delay:
    outputfile.write(oline + '\n')
else:
    sys.stdout.write(line + theme['input'])
    if op.debug:
       /,,,,

PS - Something else that is pretty weird is that the output dosen't follow the delay. The csv file is HUGE and adds several thousand lines every few seconds when it flushes. Not sure why

xlight05 commented 2 years ago

+1. I tried running this on a bash script to perform. Couldn't get it done due to this issue.

kmac commented 1 year ago

As another datapoint, I prefer the current behaviour, so that I can monitor the data as it's being recorded. You can always redirect the output to /dev/null in a script if you don't want it.

tomchon commented 1 year ago

The output file is not written until sending ctrl+c to "dool --output test.log" . i think it's not proper....

scottchiefbaker commented 1 year ago

I just landed some code that addresses all of these things:

  1. --output /tmp/foo.csv will output only to a file
  2. Output file respects the delay again
  3. Fixed the output going line by line to the file so you can run tail -f on it as it writes
  4. Added a --display option so you can write to a file and display on your screen

Example: dool --more --output /tmp/foo.csv --display 15

Please test and let me know.

scottchiefbaker commented 1 year ago

This code has landed and will be in the next release.