diff options
author | Florian Eckert <fe@dev.tdt.de> | 2019-09-17 10:09:23 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2019-09-17 10:09:23 +0200 |
commit | 0d06e3432bbcc30c79addbfba29dafc8dc8ed184 (patch) | |
tree | 9c775dbc6afd62c0d89218d3ee5b446d10d07067 | |
parent | 995322c55fb23c82a36ea3966219401b4fee6c77 (diff) | |
parent | b80ccb990b5a9256207a44bfdef359bd4d5c19c9 (diff) |
Merge pull request #3063 from TDT-AG/pr/20190908-luci-app-statistics
luci-app-statistics: Add new plugin options
7 files changed, 326 insertions, 60 deletions
diff --git a/applications/luci-app-statistics/luasrc/model/cbi/luci_statistics/cpu.lua b/applications/luci-app-statistics/luasrc/model/cbi/luci_statistics/cpu.lua index ee3fd254fb..56af1cc96a 100644 --- a/applications/luci-app-statistics/luasrc/model/cbi/luci_statistics/cpu.lua +++ b/applications/luci-app-statistics/luasrc/model/cbi/luci_statistics/cpu.lua @@ -12,4 +12,25 @@ s = m:section( NamedSection, "collectd_cpu", "luci_statistics" ) enable = s:option( Flag, "enable", translate("Enable this plugin") ) enable.default = 0 +-- collectd_cpu.reportbycpu (ReportByCpu) +reportbycpu = s:option( Flag, "ReportByCpu", + translate("Report by CPU"), + translate("By setting this, CPU is not aggregate of all processors on the system")) +reportbycpu.default = 1 +reportbycpu:depends( "enable", 1 ) + +-- collectd_cpu.reportbystate (ReportByState) +reportbystate = s:option( Flag, "ReportByState", + translate("Report by state"), + translate("When set to true, reports per-state metric (system, user, idle)")) +reportbystate.default = 1 +reportbystate:depends( "enable", 1 ) + +-- collectd_cpu.valuespercentage (ValuesPercentage) +valuespercentage = s:option( Flag, "ValuesPercentage", + translate("Report in percent"), + translate("When set to true, we request percentage values")) +valuespercentage.default = 0 +valuespercentage:depends({ enable = 1, ReportByCpu = 1, ReportByState = 1 }) + return m diff --git a/applications/luci-app-statistics/luasrc/model/cbi/luci_statistics/memory.lua b/applications/luci-app-statistics/luasrc/model/cbi/luci_statistics/memory.lua index fa677b8d12..e5f3360c05 100644 --- a/applications/luci-app-statistics/luasrc/model/cbi/luci_statistics/memory.lua +++ b/applications/luci-app-statistics/luasrc/model/cbi/luci_statistics/memory.lua @@ -10,4 +10,18 @@ s = m:section( NamedSection, "collectd_memory", "luci_statistics" ) enable = s:option( Flag, "enable", translate("Enable this plugin") ) enable.default = 0 +-- collectd_memory.valuesabsolute (ValuesAbsolute) +valuespercentage = s:option( Flag, "ValuesAbsolute", + translate("Absolute values"), + translate("When set to true, we request absolute values")) +valuespercentage.default = 1 +valuespercentage:depends( "enable", 1 ) + +-- collectd_memory.valuespercentage (ValuesPercentage) +valuespercentage = s:option( Flag, "ValuesPercentage", + translate("Percent values"), + translate("When set to true, we request percentage values")) +valuespercentage.default = 0 +valuespercentage:depends( "enable", 1 ) + return m diff --git a/applications/luci-app-statistics/luasrc/statistics/plugins/cpu.lua b/applications/luci-app-statistics/luasrc/statistics/plugins/cpu.lua index 004a450eec..bae325990e 100644 --- a/applications/luci-app-statistics/luasrc/statistics/plugins/cpu.lua +++ b/applications/luci-app-statistics/luasrc/statistics/plugins/cpu.lua @@ -1,7 +1,7 @@ return { legend = { { }, - { }, + { "ValuesPercentage" , "ReportByCpu", "ReportByState" }, { } }, label = _("Processor"), diff --git a/applications/luci-app-statistics/luasrc/statistics/plugins/memory.lua b/applications/luci-app-statistics/luasrc/statistics/plugins/memory.lua index 8dee2dafcd..9ad1b3f88d 100644 --- a/applications/luci-app-statistics/luasrc/statistics/plugins/memory.lua +++ b/applications/luci-app-statistics/luasrc/statistics/plugins/memory.lua @@ -1,7 +1,7 @@ return { - legend = { - { }, + legend = { { }, + { "ValuesPercentage", "ValuesAbsolute" }, { } }, label = _("Memory"), diff --git a/applications/luci-app-statistics/luasrc/statistics/rrdtool/definitions/cpu.lua b/applications/luci-app-statistics/luasrc/statistics/rrdtool/definitions/cpu.lua index 226c84ee96..3f8910722a 100644 --- a/applications/luci-app-statistics/luasrc/statistics/rrdtool/definitions/cpu.lua +++ b/applications/luci-app-statistics/luasrc/statistics/rrdtool/definitions/cpu.lua @@ -3,33 +3,167 @@ module("luci.statistics.rrdtool.definitions.cpu",package.seeall) +local uci = require("luci.model.uci").cursor() +local reportbystate = uci:get("luci_statistics", "collectd_cpu", "ReportByState") or "0" + function item() return luci.i18n.translate("Processor") end function rrdargs( graph, plugin, plugin_instance, dtype ) + local p = {} + + local title = "%H: Processor usage" + if #plugin_instance > 0 then + title = "%H: Processor usage on core #%pi" + end + + if reportbystate == "1" then + local cpu = { + title = title, + y_min = "0", + alt_autoscale_max = true, + vlabel = "Jiffies", + number_format = "%5.1lf", + data = { + instances = { + cpu = { + "idle", + "interrupt", + "nice", + "softirq", + "steal", + "system", + "user", + "wait" + } + }, + options = { + cpu_idle = { + color = "ffffff", + title = "Idle" + }, + cpu_interrupt = { + color = "a000a0", + title = "Interrupt" + }, + cpu_nice = { + color = "00e000", + title = "Nice" + }, + cpu_softirq = { + color = "ff00ff", + title = "Softirq" + }, + cpu_steal = { + color = "000000", + title = "Steal" + }, + cpu_system = { + color = "ff0000", + title = "System" + }, + cpu_user = { + color = "0000ff", + title = "User" + }, + cpu_wait = { + color = "ffb000", + title = "Wait" + } + } + } + } - return { - title = "%H: Processor usage on core #%pi", - y_min = "0", - alt_autoscale_max = true, - vlabel = "Percent", - number_format = "%5.1lf%%", - data = { - instances = { - cpu = { "user", "nice", "system", "softirq", "interrupt" } - }, - - options = { - cpu_idle = { color = "ffffff", title = "Idle" }, - cpu_nice = { color = "00e000", title = "Nice" }, - cpu_user = { color = "0000ff", title = "User" }, - cpu_wait = { color = "ffb000", title = "Wait" }, - cpu_system = { color = "ff0000", title = "System" }, - cpu_softirq = { color = "ff00ff", title = "Softirq" }, - cpu_interrupt = { color = "a000a0", title = "Interrupt" }, - cpu_steal = { color = "000000", title = "Steal" } + local percent = { + title = title, + y_min = "0", + alt_autoscale_max = true, + vlabel = "Percent", + number_format = "%5.1lf%%", + data = { + instances = { + percent = { + "idle", + "interrupt", + "nice", + "softirq", + "steal", + "system", + "user", + "wait" + } + }, + options = { + percent_idle = { + color = "ffffff", + title = "Idle" + }, + percent_interrupt = { + color = "a000a0", + title = "Interrupt" + }, + percent_nice = { + color = "00e000", + title = "Nice" + }, + percent_softirq = { + color = "ff00ff", + title = "Softirq" + }, + percent_steal = { + color = "000000", + title = "Steal" + }, + percent_system = { + color = "ff0000", + title = "System" + }, + percent_user = { + color = "0000ff", + title = "User" + }, + percent_wait = { + color = "ffb000", + title = "Wait" + } + } } } - } + + local types = graph.tree:data_types( plugin, plugin_instance ) + + for _, t in ipairs(types) do + if t == "cpu" then + p[#p+1] = cpu + end + + if t == "percent" then + p[#p+1] = percent + end + end + else + p = { + title = title, + y_min = "0", + alt_autoscale_max = true, + vlabel = "Percent", + number_format = "%5.1lf%%", + data = { + instances = { + percent = { + "active", + } + }, + options = { + percent_active = { + color = "00e000", + title = "Active" + } + } + } + } + end + + return p end diff --git a/applications/luci-app-statistics/luasrc/statistics/rrdtool/definitions/memory.lua b/applications/luci-app-statistics/luasrc/statistics/rrdtool/definitions/memory.lua index b05d31dc02..749c3e352c 100644 --- a/applications/luci-app-statistics/luasrc/statistics/rrdtool/definitions/memory.lua +++ b/applications/luci-app-statistics/luasrc/statistics/rrdtool/definitions/memory.lua @@ -1,13 +1,5 @@ ---[[ - -(c) 2011 Manuel Munz <freifunk at somakoma dot de> - -Licensed under the Apache License, Version 2.0 (the "License"); -you may not use this file except in compliance with the License. -You may obtain a copy of the License at - - http://www.apache.org/licenses/LICENSE-2.0 -]]-- +-- Copyright 2011 Manuel Munz <freifunk at somakoma dot de> +-- Licensed to the public under the Apache License 2.0. module("luci.statistics.rrdtool.definitions.memory",package.seeall) @@ -16,24 +8,92 @@ function item() end function rrdargs( graph, plugin, plugin_instance, dtype ) + local p = {} - return { + local memory = { title = "%H: Memory usage", vlabel = "MB", number_format = "%5.1lf%s", y_min = "0", alt_autoscale_max = true, data = { - instances = { - memory = { "free", "buffered", "cached", "used" } + instances = { + memory = { + "free", + "buffered", + "cached", + "used" + } }, options = { - memory_buffered = { color = "0000ff", title = "Buffered" }, - memory_cached = { color = "ff00ff", title = "Cached" }, - memory_used = { color = "ff0000", title = "Used" }, - memory_free = { color = "00ff00", title = "Free" } + memory_buffered = { + color = "0000ff", + title = "Buffered" + }, + memory_cached = { + color = "ff00ff", + title = "Cached" + }, + memory_used = { + color = "ff0000", + title = "Used" + }, + memory_free = { + color = "00ff00", + title = "Free" + } } } } + + local percent = { + title = "%H: Memory usage", + vlabel = "Percent", + number_format = "%5.1lf%%", + y_min = "0", + alt_autoscale_max = true, + data = { + instances = { + percent = { + "free", + "buffered", + "cached", + "used" + } + }, + options = { + percent_buffered = { + color = "0000ff", + title = "Buffered" + }, + percent_cached = { + color = "ff00ff", + title = "Cached" + }, + percent_used = { + color = "ff0000", + title = "Used" + }, + percent_free = { + color = "00ff00", + title = "Free" + } + } + } + } + + local types = graph.tree:data_types( plugin, plugin_instance ) + + for _, t in ipairs(types) do + if t == "percent" then + p[#p+1] = percent + end + + if t == "memory" then + p[#p+1] = memory + end + end + + return p end diff --git a/applications/luci-app-statistics/luasrc/statistics/rrdtool/definitions/ping.lua b/applications/luci-app-statistics/luasrc/statistics/rrdtool/definitions/ping.lua index e290af549a..b8d11c0759 100644 --- a/applications/luci-app-statistics/luasrc/statistics/rrdtool/definitions/ping.lua +++ b/applications/luci-app-statistics/luasrc/statistics/rrdtool/definitions/ping.lua @@ -9,25 +9,62 @@ end function rrdargs( graph, plugin, plugin_instance, dtype ) - return { - -- Ping roundtrip time - { title = "%H: ICMP Round Trip Time", - vlabel = "ms", - number_format = "%5.1lf ms", - data = { - sources = { ping = { "value" } }, - options = { ping__value = { - noarea = true, overlay = true, title = "%di" } } - } }, + local ping = { + title = "%H: ICMP Round Trip Time", + vlabel = "ms", + number_format = "%5.1lf ms", + data = { + sources = { + ping = { + "value" + } + }, + options = { + ping__value = { + noarea = true, + overlay = true, + title = "%di" + } + } + } + } + + local droprate = { + title = "%H: ICMP Drop Rate", + vlabel = "%", + number_format = "%5.2lf %%", + data = { + types = { + "ping_droprate" + }, + options = { + ping_droprate = { + noarea = true, + overlay = true, + title = "%di", + transform_rpn = "100,*" + } + } + } + } - -- Ping droprate - { title = "%H: ICMP Drop Rate", - vlabel = "%", - number_format = "%5.2lf %%", - data = { - types = { "ping_droprate" }, - options = { ping_droprate = { - noarea = true, overlay = true, title = "%di", transform_rpn = "100,*" } } - } } + local stddev = { + title = "%H: ICMP Standard Deviation", + vlabel = "ms", + number_format = "%5.1lf ms", + data = { + types = { + "ping_stddev" + }, + options = { + ping_stddev = { + noarea = true, + overlay = true, + title = "%di" + } + } + } } + + return { ping, droprate, stddev } end |