INFOBOX - Show Load avg at sidebar
Show the average load in the sidebar under a load 1.0 it is colored green above its red
This commit is contained in:
parent
6aab7aec7d
commit
2dc989ab63
|
@ -134,6 +134,40 @@ define(["moment", "numeral", "tablesort", "tablesort.numeric"],
|
|||
return span
|
||||
}
|
||||
|
||||
function showLoadBar(className, v) {
|
||||
var span = document.createElement("span")
|
||||
span.classList.add("bar")
|
||||
span.classList.add(className)
|
||||
|
||||
var bar = document.createElement("span")
|
||||
if (v >= 1) {
|
||||
bar.style.width = ((v * 100) % 100) + "%"
|
||||
bar.style.background = "rgba(255, 50, 50, 0.9)"
|
||||
span.style.background = "rgba(255, 50, 50, 0.6)"
|
||||
span.appendChild(bar)
|
||||
}
|
||||
else
|
||||
{
|
||||
bar.style.width = (v * 100) + "%"
|
||||
span.appendChild(bar)
|
||||
}
|
||||
|
||||
var label = document.createElement("label")
|
||||
label.textContent = (v)
|
||||
span.appendChild(label)
|
||||
|
||||
return span
|
||||
}
|
||||
|
||||
function showLOAD(d) {
|
||||
if (!("loadavg" in d.statistics))
|
||||
return undefined
|
||||
|
||||
return function (el) {
|
||||
el.appendChild(showLoadBar("load-avg", d.statistics.loadavg))
|
||||
}
|
||||
}
|
||||
|
||||
function showRAM(d) {
|
||||
if (!("memory_usage" in d.statistics))
|
||||
return undefined
|
||||
|
@ -206,6 +240,7 @@ define(["moment", "numeral", "tablesort", "tablesort.numeric"],
|
|||
attributeEntry(attributes, "Site", showSite(d, config))
|
||||
attributeEntry(attributes, "Uptime", showUptime(d))
|
||||
attributeEntry(attributes, "Teil des Netzes", showFirstseen(d))
|
||||
attributeEntry(attributes, "Load - avg", showLOAD(d))
|
||||
attributeEntry(attributes, "Arbeitsspeicher", showRAM(d))
|
||||
attributeEntry(attributes, "IP Adressen", showIPs(d))
|
||||
attributeEntry(attributes, "Gewähltes Gateway", dictGet(d.statistics, ["gateway"]))
|
||||
|
|
Loading…
Reference in a new issue