Flood uses df -T
in server/util/diskUsageUtil.ts where it defines the disks in use. However, I have a box that has a jail and df
is useless as it shows all other filesystems we don't use in our jail. Users have to use quota
to get their own data usage on their space.
As quota
uses different format than df
it's not enough to just change the command. We also need more arguments to get all data in the same line:
$ quota -w --show-mntpoint
Disk quotas for user rolle (uid 1020):
Filesystem blocks quota limit grace files quota limit grace
/dev/sdb1 /home2 1059357988 3905945600 3905945600 266012 0 0
I got flood working with quota by modifying the linux option like so:
linux: (timeout) =>
spawnAsync(
'quota',
['-w', '--show-mntpoint'],
{
timeout: timeout,
},
MAX_BUFFER_SIZE,
).then((stdout) =>
stdout
.trim()
.split('\n')
.slice(1)
.map((disk) => disk.split(/\s+/))
.filter((disk) => filterMountPoint(disk[6]))
.filter((disk) => !['devtmpfs', 'squashfs', 'tmpfs', 'overlay'].includes(disk[1]))
.map(([_dev, target, blocks, quota, limit, quota2, limit2, grace]) => {
return {
size: Number.parseInt(quota, 10) * 1024,
used: Number.parseInt(blocks, 10) * 1024,
avail: (Number.parseInt(quota, 10) * 1024) - (Number.parseInt(blocks, 10) * 1024),
target,
};
}),
),
This works.
I'm not very experienced with ts/js but this could be an option in Flood. Just an idea and working concept I'd like to share. Thoughts?
Originally here.