Show file system inode usage and read-only status

This commit is contained in:
josh committed 2026-04-14 08:41:39 -04:00
1 parent 1e87b08b54
commit 23008b4997
2 files changed
+51 -13

No files matched your search

+26 -5
View File
@@ -210,21 +210,42 @@ if cgi.params.key?("content")
used_b = entry["used"].to_i
pct_f = size_b > 0 ? (used_b * 100.0 / size_b) : 0.0
pct = pct_f.round
cls = pct_f >= 90 ? "bad" : pct_f >= 75 ? "warn" : "ok"
space_cls = pct_f >= 90 ? "bad" : pct_f >= 75 ? "warn" : "ok"
used_h = CGI.escapeHTML(human_capacity(used_b))
size_h = CGI.escapeHTML(human_capacity(size_b))
fs_stats = []
inode_cls = "ok"
if (itot = entry["inode_total"].to_i) > 0
iused = entry["inode_used"].to_i
ipct_f = iused * 100.0 / itot
inode_cls = ipct_f >= 90 ? "bad" : ipct_f >= 75 ? "warn" : "ok"
fs_stats << [inode_cls, "Inodes #{ipct_f.round}%"]
end
fs_stats << ["warn", "READ-ONLY"] if entry["readonly"]
severities = [space_cls, inode_cls]
card_cls = severities.include?("bad") ? "bad" :
severities.include?("warn") ? "warn" : "ok"
stats_html = fs_stats.map { |c, txt|
%(<span class="stat #{c}">#{CGI.escapeHTML(txt)}</span>)
}.join
stats_block = fs_stats.empty? ? "" :
%(<div class="drive-stats" style="margin-top:0.6rem;">#{stats_html}</div>)
html << <<~HTML
<div class="card #{cls}">
<div class="card #{card_cls}">
<div class="card-header">
<span class="card-title">#{mount} <span class="card-capacity">#{fstype}</span></span>
<span class="badge #{cls}">#{pct}%</span>
<span class="badge #{space_cls}">#{pct}%</span>
</div>
<div style="display:flex;justify-content:space-between;align-items:center;margin-top:0.5rem;margin-bottom:0.3rem;">
<span style="font-size:0.72rem;color:#64748b;font-weight:600;">#{source}</span>
<span class="subitem-value #{cls}">#{used_h} / #{size_h}</span>
<span class="subitem-value #{space_cls}">#{used_h} / #{size_h}</span>
</div>
<div class="bar-track" style="height:6px;"><div class="bar-fill #{cls}" style="width:#{pct}%"></div></div>
<div class="bar-track" style="height:6px;"><div class="bar-fill #{space_cls}" style="width:#{pct}%"></div></div>
#{stats_block}
</div>
HTML
end