From 93c9bf27fadba7e8f3c7a7f13f28309373844561 Mon Sep 17 00:00:00 2001 From: Josh Holtrop Date: Mon, 20 Apr 2026 21:04:09 -0400 Subject: [PATCH] Reorganize cards with server info and file systems in left column --- cgi-bin/malp.rb | 114 ++++++++++++++++++++++++------------------------ 1 file changed, 58 insertions(+), 56 deletions(-) diff --git a/cgi-bin/malp.rb b/cgi-bin/malp.rb index 52728b0..745eb56 100755 --- a/cgi-bin/malp.rb +++ b/cgi-bin/malp.rb @@ -114,7 +114,7 @@ if cgi.params.key?("content") vms = info.select { |e| e["type"] == "vm" } server = info.find { |e| e["type"] == "server" } - html << %(
) + html << %(
) if server html << %() @@ -173,6 +173,63 @@ if cgi.params.key?("content") html << %(
) end + if filesystems.any? + html << %(
File Systems
) + html << %(
) + filesystems.each do |entry| + mount = CGI.escapeHTML(entry["mount"].to_s) + source = CGI.escapeHTML(entry["source"].to_s) + fstype = CGI.escapeHTML(entry["fstype"].to_s) + size_b = entry["size"].to_i + used_b = entry["used"].to_i + pct_f = size_b > 0 ? (used_b * 100.0 / size_b) : 0.0 + pct = pct_f.round + 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| + %(#{CGI.escapeHTML(txt)}) + }.join + stats_block = fs_stats.empty? ? "" : + %(
#{stats_html}
) + + html << <<~HTML +
+
+ #{mount} #{fstype} + #{pct}% +
+
+ #{source} + #{used_h} / #{size_h} +
+
+ #{stats_block} +
+ HTML + end + html << %(
) + end + + html << %() + + html << %(
) + if vms.any? running = vms.count { |v| v["state"].to_s == "running" } total = vms.size @@ -409,61 +466,6 @@ if cgi.params.key?("content") html << %(
) - if filesystems.any? - html << %(
) - html << %() - html << %(
) - filesystems.each do |entry| - mount = CGI.escapeHTML(entry["mount"].to_s) - source = CGI.escapeHTML(entry["source"].to_s) - fstype = CGI.escapeHTML(entry["fstype"].to_s) - size_b = entry["size"].to_i - used_b = entry["used"].to_i - pct_f = size_b > 0 ? (used_b * 100.0 / size_b) : 0.0 - pct = pct_f.round - 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| - %(#{CGI.escapeHTML(txt)}) - }.join - stats_block = fs_stats.empty? ? "" : - %(
#{stats_html}
) - - html << <<~HTML -
-
- #{mount} #{fstype} - #{pct}% -
-
- #{source} - #{used_h} / #{size_h} -
-
- #{stats_block} -
- HTML - end - html << %(
) - html << %(
) - end - cgi.out("type" => "text/html", "charset" => "UTF-8") do html end