diff --git a/cgi-bin/malp.rb b/cgi-bin/malp.rb
index fe7e89a..bb21251 100755
--- a/cgi-bin/malp.rb
+++ b/cgi-bin/malp.rb
@@ -113,12 +113,13 @@ if cgi.params.key?("content")
filesystems = info.select { |e| e["type"] == "filesystem" }
vms = info.select { |e| e["type"] == "vm" }
+ html << %(
)
+
if vms.any?
running = vms.count { |v| v["state"].to_s == "running" }
total = vms.size
hdr_cls = running == total ? "ok" : running == 0 ? "bad" : "warn"
- html << %(
)
html << %(
Virtual Machines
)
html << <<~HTML
@@ -202,7 +203,6 @@ if cgi.params.key?("content")
end
html << %(
)
- html << %(
)
end
thousands = ->(n) { n.to_s.gsub(/(\d)(?=(\d{3})+$)/, '\1,') }
@@ -253,8 +253,13 @@ if cgi.params.key?("content")
stats
end
+ upses = info.select { |e| e["type"] == "ups" }
+ if drives.any? || upses.any?
+ html << %()
+ end
+
if drives.any?
- html << %(
)
+ html << %(
)
html << %(
Storage Drives
)
html << %(
)
drives.each do |entry|
@@ -291,6 +296,61 @@ if cgi.params.key?("content")
html << %(
)
end
+ upses.each do |ups|
+ status = ups["status"].to_s
+ online = status.include?("ONLINE")
+ card_cls = online ? "ok" : "bad"
+
+ model = ups["model"] ? "APC " + CGI.escapeHTML(ups["model"]) : "UPS"
+
+ stats = []
+ stats << [online ? "ok" : "bad", CGI.escapeHTML(status)] unless status.empty?
+
+ if (charge = ups["charge"])
+ cls = charge >= 80 ? "ok" : charge >= 50 ? "warn" : "bad"
+ stats << [cls, "Charge #{charge.round}%"]
+ end
+ if (timeleft = ups["timeleft"])
+ cls = timeleft >= 10 ? "ok" : timeleft >= 5 ? "warn" : "bad"
+ stats << [cls, "#{timeleft.round(1)} min left"]
+ end
+ if (load = ups["load"])
+ cls = load >= 90 ? "bad" : load >= 70 ? "warn" : "ok"
+ stats << [cls, "Load #{load.round}%"]
+ end
+ if (lv = ups["line_voltage"])
+ stats << ["ok", "Line #{lv.round} V"]
+ end
+ if (bv = ups["battery_voltage"])
+ stats << ["ok", "Batt #{bv.round(1)} V"]
+ end
+
+ stats_html = stats.map { |c, txt|
+ %(
#{txt})
+ }.join
+ stats_block = stats.empty? ? "" :
+ %(
#{stats_html}
)
+
+ html << %(
)
+ html << %(
UPS
)
+ html << <<~HTML
+
+
+ #{stats_block}
+
+ HTML
+ html << %(
)
+ end
+
+ if drives.any? || upses.any?
+ html << %(
)
+ end
+
+ html << %(
)
+
if filesystems.any?
html << %(
)
html << %(
File Systems
)
@@ -346,56 +406,6 @@ if cgi.params.key?("content")
html << %(
)
end
- upses = info.select { |e| e["type"] == "ups" }
- upses.each do |ups|
- status = ups["status"].to_s
- online = status.include?("ONLINE")
- card_cls = online ? "ok" : "bad"
-
- model = ups["model"] ? "APC " + CGI.escapeHTML(ups["model"]) : "UPS"
-
- stats = []
- stats << [online ? "ok" : "bad", CGI.escapeHTML(status)] unless status.empty?
-
- if (charge = ups["charge"])
- cls = charge >= 80 ? "ok" : charge >= 50 ? "warn" : "bad"
- stats << [cls, "Charge #{charge.round}%"]
- end
- if (timeleft = ups["timeleft"])
- cls = timeleft >= 10 ? "ok" : timeleft >= 5 ? "warn" : "bad"
- stats << [cls, "#{timeleft.round(1)} min left"]
- end
- if (load = ups["load"])
- cls = load >= 90 ? "bad" : load >= 70 ? "warn" : "ok"
- stats << [cls, "Load #{load.round}%"]
- end
- if (lv = ups["line_voltage"])
- stats << ["ok", "Line #{lv.round} V"]
- end
- if (bv = ups["battery_voltage"])
- stats << ["ok", "Batt #{bv.round(1)} V"]
- end
-
- stats_html = stats.map { |c, txt|
- %(
#{txt})
- }.join
- stats_block = stats.empty? ? "" :
- %(
#{stats_html}
)
-
- html << %(
)
- html << %(
UPS
)
- html << <<~HTML
-
-
- #{stats_block}
-
- HTML
- html << %(
)
- end
-
cgi.out("type" => "text/html", "charset" => "UTF-8") do
html
end