statistics: site code statistics

configurable and documented!
This commit is contained in:
PetaByteBoy 2015-07-18 16:28:07 +02:00 committed by Milan Pässler
parent c0ab7afa15
commit 80967c6259
4 changed files with 62 additions and 0 deletions

View File

@ -130,3 +130,21 @@ Examples for `globalInfos` using Grafana server rendering:
"caption": "Bild mit Wochenstatistik" "caption": "Bild mit Wochenstatistik"
} }
] ]
## siteNames (array, optional)
In this array name definitions for site statistics and node info can be saved. This requires one object for each site code. This object must contain:
- `site` the site code
- `name` the defined written name for this site code
If neither `siteNames` nor `showSites` are set, site statistics and node info won't be displayed
Example for `siteNames`:
"siteNames": [
{ "site": "ffhl", "name": "Lübeck" },
{ "site": "ffeh", "name": "Entenhausen" ),
{ "site": "ffgt", "name": "Gothamcity" },
{ "site": "ffal", "name": "Atlantis" }
]

View File

@ -17,5 +17,11 @@
{ {
"name": "Stamen.TonerLite" "name": "Stamen.TonerLite"
} }
],
"siteNames": [
{ "site": "ffhl", "name": "Lübeck" },
{ "site": "ffeh", "name": "Entenhausen" },
{ "site": "ffgt", "name": "Gothamcity" },
{ "site": "ffal", "name": "Atlantis" }
] ]
} }

View File

@ -53,6 +53,17 @@ define(["moment", "numeral", "tablesort", "tablesort.numeric"],
return release + " / " + base return release + " / " + base
} }
function showSite(d, config) {
var site = dictGet(d.nodeinfo, ["system", "site_code"])
var rt = site
if (config.siteNames)
config.siteNames.forEach( function (t) {
if(site === t.site)
rt = t.name
})
return rt
}
function showUptime(d) { function showUptime(d) {
if (!("uptime" in d.statistics)) if (!("uptime" in d.statistics))
return undefined return undefined
@ -192,6 +203,7 @@ define(["moment", "numeral", "tablesort", "tablesort.numeric"],
attributeEntry(attributes, "Primäre MAC", dictGet(d.nodeinfo, ["network", "mac"])) attributeEntry(attributes, "Primäre MAC", dictGet(d.nodeinfo, ["network", "mac"]))
attributeEntry(attributes, "Node ID", dictGet(d.nodeinfo, ["node_id"])) attributeEntry(attributes, "Node ID", dictGet(d.nodeinfo, ["node_id"]))
attributeEntry(attributes, "Firmware", showFirmware(d)) attributeEntry(attributes, "Firmware", showFirmware(d))
attributeEntry(attributes, "Site", showSite(d, config))
attributeEntry(attributes, "Uptime", showUptime(d)) attributeEntry(attributes, "Uptime", showUptime(d))
attributeEntry(attributes, "Teil des Netzes", showFirstseen(d)) attributeEntry(attributes, "Teil des Netzes", showFirstseen(d))
attributeEntry(attributes, "Arbeitsspeicher", showRAM(d)) attributeEntry(attributes, "Arbeitsspeicher", showRAM(d))

View File

@ -26,6 +26,9 @@ define(["chroma-js", "virtual-dom", "numeral-intl", "filters/genericnode", "verc
var gwTable = document.createElement("table") var gwTable = document.createElement("table")
gwTable.classList.add("proportion") gwTable.classList.add("proportion")
var siteTable = document.createElement("table")
siteTable.classList.add("proportion")
function showStatGlobal(o) { function showStatGlobal(o) {
var content, caption var content, caption
@ -158,6 +161,16 @@ define(["chroma-js", "virtual-dom", "numeral-intl", "filters/genericnode", "verc
return d return d
}) })
var siteDict = count(onlineNodes, ["nodeinfo", "system", "site_code"], function (d) {
var rt = d
if (config.siteNames)
config.siteNames.forEach( function (t) {
if(d === t.site)
rt = t.name
})
return rt
})
fillTable("Status", statusTable, statusDict.sort(function (a, b) { return b[1] - a[1] })) fillTable("Status", statusTable, statusDict.sort(function (a, b) { return b[1] - a[1] }))
fillTable("Firmware", fwTable, fwDict.sort(function (a, b) { return vercomp(b[0], a[0]) })) fillTable("Firmware", fwTable, fwDict.sort(function (a, b) { return vercomp(b[0], a[0]) }))
fillTable("Hardware", hwTable, hwDict.sort(function (a, b) { return b[1] - a[1] })) fillTable("Hardware", hwTable, hwDict.sort(function (a, b) { return b[1] - a[1] }))
@ -165,6 +178,7 @@ define(["chroma-js", "virtual-dom", "numeral-intl", "filters/genericnode", "verc
fillTable("Autom. Updates", autoTable, autoDict.sort(function (a, b) { return b[1] - a[1] })) fillTable("Autom. Updates", autoTable, autoDict.sort(function (a, b) { return b[1] - a[1] }))
fillTable("Uplink", uplinkTable, uplinkDict.sort(function (a, b) { return b[1] - a[1] })) fillTable("Uplink", uplinkTable, uplinkDict.sort(function (a, b) { return b[1] - a[1] }))
fillTable("Gewähltes Gateway", gwTable, gwDict.sort(function (a, b) { return b[1] - a[1] })) fillTable("Gewähltes Gateway", gwTable, gwDict.sort(function (a, b) { return b[1] - a[1] }))
fillTable("Site", siteTable, siteDict.sort(function (a, b) { return b[1] - a[1] }))
} }
self.render = function (el) { self.render = function (el) {
@ -179,6 +193,13 @@ define(["chroma-js", "virtual-dom", "numeral-intl", "filters/genericnode", "verc
el.appendChild(h2) el.appendChild(h2)
el.appendChild(fwTable) el.appendChild(fwTable)
if(config.siteNames || config.showSites) {
h2 = document.createElement("h2")
h2.textContent = "Orte"
el.appendChild(h2)
el.appendChild(siteTable)
}
h2 = document.createElement("h2") h2 = document.createElement("h2")
h2.textContent = "Hardwaremodelle" h2.textContent = "Hardwaremodelle"
el.appendChild(h2) el.appendChild(h2)
@ -204,6 +225,11 @@ define(["chroma-js", "virtual-dom", "numeral-intl", "filters/genericnode", "verc
el.appendChild(h2) el.appendChild(h2)
el.appendChild(gwTable) el.appendChild(gwTable)
h2 = document.createElement("h2")
h2.textContent = "Site"
el.appendChild(h2)
el.appendChild(siteTable)
if (config.globalInfos) if (config.globalInfos)
config.globalInfos.forEach( function (globalInfo) { config.globalInfos.forEach( function (globalInfo) {
h2 = document.createElement("h2") h2 = document.createElement("h2")