flood icon indicating copy to clipboard operation
flood copied to clipboard

Disk usage not reporting correctly

Open MattMattV opened this issue 4 years ago • 12 comments

Type: Bug Report

  • [x] Try to follow the update procedure described in the README and try again before opening this issue.
  • [x] Please check the F.A.Q..
  • [x] Please check the Troubleshooting wiki section.

Your Environment

Flood is running in a Docker container using the provided Dockerfile.

  • Version used: 86008d5ffb5d073278bf29f46b874b85495980ed
Docker engine version
Version:          18.06.1-ce
API version:      1.38 (minimum version 1.12)
Go version:       go1.10.3
Git commit:       e68fc7a
Built:            Tue Aug 21 17:23:21 2018
OS/Arch:          linux/amd64
Experimental:     false
  • Operating System and version (inside container):

Alpine Linux 3.9.4

Summary

Disk widget indicates NaN%

disk widget showing NaN%

Expected Behavior

Disk usage widget reporting space usage

Current Behavior

NaN% is show instead of targeted storage usage

Possible Solution

Review df options to take account of various Linux distributions

Steps to Reproduce

  1. Build docker image at root of repository
  2. Run it with a volume to host downloaded data
  3. Download torrent

Appendix

Output of the "df" command executed inside the container
/usr/src/app # df --block-size=1024 --portability
df: unrecognized option: block-size=1024
BusyBox v1.29.3 (2019-01-24 07:45:07 UTC) multi-call binary.

Usage: df [-PkmhTai] [-B SIZE] [FILESYSTEM]...

Print filesystem usage statistics

-P	POSIX output format
-k	1024-byte blocks (default)
-m	1M-byte blocks
-h	Human readable (e.g. 1K 243M 2G)
-T	Print filesystem type
-a	Show all filesystems
-i	Inodes
-B SIZE	Blocksize
Output of "df -B 1024" executed inside the container
/usr/src/app # df -B 1024
Filesystem           1K-blocks      Used Available Use% Mounted on
overlay              1902052484 1527146244 278264552  85% /
tmpfs                    65536         0     65536   0% /dev
tmpfs                  8165532         0   8165532   0% /sys/fs/cgroup
/dev/sda3            1902052484 1527146244 278264552  85% /data
/dev/sda3            1902052484 1527146244 278264552  85% /data/rtorrent.sock
/dev/sda3            1902052484 1527146244 278264552  85% /etc/resolv.conf
/dev/sda3            1902052484 1527146244 278264552  85% /etc/hostname
/dev/sda3            1902052484 1527146244 278264552  85% /etc/hosts
shm                      65536         0     65536   0% /dev/shm
/dev/sda3            1902052484 1527146244 278264552  85% /data/server/db
/dev/sda3            1902052484 1527146244 278264552  85% /home/data/storage
tmpfs                  8165532         0   8165532   0% /proc/acpi
tmpfs                    65536         0     65536   0% /proc/kcore
tmpfs                    65536         0     65536   0% /proc/keys
tmpfs                    65536         0     65536   0% /proc/timer_list
tmpfs                    65536         0     65536   0% /proc/sched_debug
tmpfs                  8165532         0   8165532   0% /proc/scsi
tmpfs                  8165532         0   8165532   0% /sys/firmware

MattMattV avatar Sep 02 '19 11:09 MattMattV

Any error message in the console output ?

noraj avatar Sep 02 '19 18:09 noraj

I have flood running in a docker container, I have added the volume for my NAS, but I am still getting the above error. can someone explain exactly where this is looking?

slicepaperwords avatar Sep 03 '19 02:09 slicepaperwords

@noraj docker logs does not reveal any error

image

MattMattV avatar Sep 03 '19 06:09 MattMattV

@MattMattV I'm not a dev, only issue manager. Only @jfurrow is a dev on this project but he doesn't have much time.

To see if it's a bug only happening with docker or not, please install Flood on a machine and see if the bug is happening. If only happening with docker it's maybe related in the way you mount volumes and how docker see them.

noraj avatar Sep 03 '19 08:09 noraj

@MattMattV it looks like it can be resolved by changing server/services/diskUsageService.js on line 22 change 'df --block-size=1024 --portability | tail -n+2' to 'df -k | tail -n+2' I have not tested this on my debian machine yet, just in docker, but it is working. image image

slicepaperwords avatar Sep 03 '19 18:09 slicepaperwords

https://github.com/Flood-UI/flood/blob/86008d5ffb5d073278bf29f46b874b85495980ed/server/services/diskUsageService.js#L22

into df -k | tail -n+2

By the way using --block-size is useless when not using something like -h because bytes are always bytes so when you display them without grouping (when not using human readable format) there is no grouping by 1000 or 1024. So -B is only useful when combined with -h or when is specify the size unit like K,M (power fo 1024) or KB,MB (power of 1000). But anyway using power of 1024 is already the default for df so in this case using -block-size=1024 is two times useless.

If your remove the -P you remove the posix format output.

If you add -k = --block-size=1K = -B 1K which is still useless because you don't use -h. Using -B K will just add a K and using -B KB will change the display.

So the only thing you really did was removing -P. And using -P = --portability only change teh first line

-Filesystem            1K-blocks      Used Available Use% Mounted on
+Filesystem            1024-blocks      Used Available Capacity Mounted on

So it only change the display of the first line from 1K-blocks to 1024-blocks (which is the same thing) and Use% to Capacity. BUT since we use tail -n+2 to strip the two first lines that's exatly the same output in final.

So in reality df --block-size=1024 --portability | tail -n+2 strictly has the same output as df -k | tail -n+2 and as df | tail -n+2 alone. In the first place the option @jfurrow used where useless but you @slicepaperwords changed nothing.

As a proof look at this :

image

To convince yourself you can do man df.

I still don't know where does the problem comes from but changing the options of df here changes nothing.

noraj avatar Sep 03 '19 18:09 noraj

the issue is in the docker alpine image, neither of those 2 options exist for df. image looks like https://github.com/Flood-UI/flood/pull/825 should resolve it for docker as well.

slicepaperwords avatar Sep 03 '19 19:09 slicepaperwords

Yeah if df was failing in alpine because the options don't exist on such a platform so not using any option should make it work. You try the change and build the docker image with that change and see if it works @MattMattV. if so @jfurrow could merge it.

noraj avatar Sep 04 '19 17:09 noraj

It works ! :tada:

image

MattMattV avatar Sep 05 '19 07:09 MattMattV

Thanks! ah I assumed all dfs on linux were the same haha ;( So lets hope then that df always return 1K blocks!

sktt avatar Sep 05 '19 23:09 sktt

By the way @MattMattV , was it obvious enough to find the diskUsageService field in the config template?

sktt avatar Sep 05 '19 23:09 sktt

To be honest I did not check at all if there was a new setting !

This explains why there is so much entries in my screenshot :smile:

MattMattV avatar Sep 06 '19 06:09 MattMattV