Skip to content

Commit

Permalink
fix(api): get sizes of all drives instead of just the main one
Browse files Browse the repository at this point in the history
there has been a problem with only the main drive being read in the usage statistics, which this
issue should fix

for #59
  • Loading branch information
MauriceNino committed Jun 8, 2022
1 parent 8718f5e commit 356cacd
Show file tree
Hide file tree
Showing 4 changed files with 27 additions and 9 deletions.
22 changes: 16 additions & 6 deletions INSTALL.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,28 +10,36 @@ To read more about configuration options, you can visit the [CONFIGURATION.md](.

docker container run -it \
-p 80:3001 \
--privileged \
-v /etc/os-release:/etc/os-release:ro \
-v /proc/1/ns/net:/mnt/host_ns_net:ro \
--privileged \
-v /media:/mnt/host_media:ro \
-v /mnt:/mnt/host_mnt:ro \
mauricenino/dashdot
```

> Note: The `--privileged` flag is needed to correctly determine the memory and storage info.
<!-- -->

> Note: The volume mount on `/etc/os-release:/etc/os-release:ro` is for the
> dashboard to show the OS version of the host instead of the OS of the docker
> container (which is running on Alpine Linux). If you wish to show the docker
> container OS instead, just remove this line. If you are not able to use this
> mount, you can pass a custom OS with the `DASHDOT_OVERRIDE_OS` flag.
<!-- -->

> Note: The volume mount on `/proc/1/ns/net:/host_ns_net:ro` is needed to
> correctly determine the network info. If you are not able to use this mount,
> you will need to fall back to `--net host`, or you will only get the network
> stats of the container instead of the host.
<!-- -->

> Note: The volume mount on `/etc/os-release:/etc/os-release:ro` is for the
> dashboard to show the OS version of the host instead of the OS of the docker
> container (which is running on Alpine Linux). If you wish to show the docker
> container OS instead, just remove this line. If you are not able to use this
> mount, you can pass a custom OS with the `DASHDOT_OVERRIDE_OS` flag.
> Note: The volume mounts on `/media:/mnt/host_media:ro` and `/mnt:/mnt/host_mnt:ro`
> are needed to read the usage stats of all drives. If your drives are mounted somewhere
> else, you need to pass that drive path with the following format: `-v /{path}:/mnt/host_{path}:ro`.
## Docker-Compose

Expand All @@ -53,6 +61,8 @@ services:
volumes:
- /etc/os-release:/etc/os-release:ro
- /proc/1/ns/net:/mnt/host_ns_net:ro
- /media:/mnt/host_media:ro
- /mnt:/mnt/host_mnt:ro
```
## From Source
Expand Down
2 changes: 2 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,8 @@ docker container run -it \
-p 80:3001 \
-v /etc/os-release:/etc/os-release:ro \
-v /proc/1/ns/net:/mnt/host_ns_net:ro \
-v /media:/mnt/host_media:ro \
-v /mnt:/mnt/host_mnt:ro \
--privileged \
mauricenino/dashdot
```
Expand Down
10 changes: 7 additions & 3 deletions apps/api/src/dynamic-info.ts
Original file line number Diff line number Diff line change
Expand Up @@ -77,10 +77,14 @@ export const storageObs = createBufferedInterval(
1,
CONFIG.storage_poll_interval,
async (): Promise<StorageLoad> => {
const data = await si.fsSize();
const root = data.find(d => d.mount === '/');
const [disks, sizes] = await Promise.all([si.diskLayout(), si.fsSize()]);
const devices = disks.map(({ device }) => device);

return root?.used ?? 0;
const filtered = sizes.filter(
({ fs }) => devices.some(dev => fs.startsWith(dev)) || fs === 'overlay'
);

return filtered.reduce((acc, { used }) => acc + used, 0);
}
);

Expand Down
2 changes: 2 additions & 0 deletions docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -23,3 +23,5 @@ services:
- ./:/app
- /etc/os-release:/etc/os-release:ro
- /proc/1/ns/net:/mnt/host_ns_net:ro
- /media:/mnt/host_media:ro
- /mnt:/mnt/host_mnt:ro

0 comments on commit 356cacd

Please sign in to comment.