mirror of
https://github.com/BobbyWibowo/lolisafe.git
synced 2024-12-14 16:36:21 +00:00
Improved disk usage entry in statistics
Now will calculate usage as (total - avail). In Linux, ext filesystems by default reserves 5% of the space to be usable by root, making them essentially already "used" space. Originally we didn't take that into account. Disk usage percentage will now round down: Math.round() -> Math.floor(). The general behavior in other tools such as "df".
This commit is contained in:
parent
0cac4a947f
commit
c113184385
@ -746,7 +746,7 @@ self.stats = async (req, res, next) => {
|
|||||||
await new Promise((resolve, reject) => {
|
await new Promise((resolve, reject) => {
|
||||||
const proc = spawn('df', [
|
const proc = spawn('df', [
|
||||||
'--block-size=1',
|
'--block-size=1',
|
||||||
'--output=used,size',
|
'--output=size,avail',
|
||||||
paths.uploads
|
paths.uploads
|
||||||
])
|
])
|
||||||
|
|
||||||
@ -764,9 +764,11 @@ self.stats = async (req, res, next) => {
|
|||||||
// Skip lines that have non-number chars
|
// Skip lines that have non-number chars
|
||||||
if (columns.some(w => !/^\d+$/.test(w))) continue
|
if (columns.some(w => !/^\d+$/.test(w))) continue
|
||||||
|
|
||||||
|
const total = parseInt(columns[0])
|
||||||
|
const avail = parseInt(columns[1])
|
||||||
stats.disk.drive = {
|
stats.disk.drive = {
|
||||||
used: parseInt(columns[0]),
|
total,
|
||||||
total: parseInt(columns[1])
|
used: total - avail
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
@ -2860,7 +2860,7 @@ page.getStatistics = (params = {}) => {
|
|||||||
if ((types.byte || []).includes(valKeys[j]))
|
if ((types.byte || []).includes(valKeys[j]))
|
||||||
parsed = page.getPrettyBytes(value)
|
parsed = page.getPrettyBytes(value)
|
||||||
if ((types.byteUsage || []).includes(valKeys[j]))
|
if ((types.byteUsage || []).includes(valKeys[j]))
|
||||||
parsed = `${page.getPrettyBytes(value.used)} / ${page.getPrettyBytes(value.total)} (${Math.round(value.used / value.total * 100)}%)`
|
parsed = `${page.getPrettyBytes(value.used)} / ${page.getPrettyBytes(value.total)} (${Math.floor(value.used / value.total * 100)}%)`
|
||||||
if ((types.uptime || []).includes(valKeys[j]))
|
if ((types.uptime || []).includes(valKeys[j]))
|
||||||
parsed = page.getPrettyUptime(value)
|
parsed = page.getPrettyUptime(value)
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user