Support for collectd-mod-contextswitch
authorfantom-x <fantom-x@users.noreply.github.com>
Sat, 29 Apr 2017 15:26:16 +0000 (11:26 -0400)
committerHannu Nyman <hannu.nyman@iki.fi>
Sat, 29 Apr 2017 20:42:22 +0000 (23:42 +0300)
Signed-off-by: Marc Benoit marcb6218@gmail.com
(cherry picked from commit 5bf636732efab13fdd92dabfd746cafb156dd4f6)

applications/luci-app-statistics/luasrc/controller/luci_statistics/luci_statistics.lua
applications/luci-app-statistics/luasrc/model/cbi/luci_statistics/contextswitch.lua [new file with mode: 0644]
applications/luci-app-statistics/luasrc/statistics/rrdtool/definitions/contextswitch.lua [new file with mode: 0644]
applications/luci-app-statistics/root/etc/config/luci_statistics
applications/luci-app-statistics/root/usr/bin/stat-genconfig

index 36c5554d35b167b1a9ca2095ebb556ba7c3785c3..1bc0714de809c2f3b24122b0f2f2ffa80dba3752 100644 (file)
@@ -24,6 +24,7 @@ function index()
                s_network       = _("Network plugins"),
 
                conntrack       = _("Conntrack"),
+               contextswitch   = _("Context Switches"),
                cpu                     = _("Processor"),
                cpufreq         = _("CPU Frequency"),
                csv                     = _("CSV Output"),
@@ -58,7 +59,7 @@ function index()
        -- our collectd menu
        local collectd_menu = {
                output  = { "csv", "network", "rrdtool", "unixsock" },
-               general = { "cpu", "cpufreq", "df", "disk", "email",
+               general = { "contextswitch", "cpu", "cpufreq", "df", "disk", "email",
                        "entropy", "exec", "irq", "load", "memory",
                        "nut", "processes", "sensors", "thermal", "uptime" },
                network = { "conntrack", "dns", "interface", "iptables",
diff --git a/applications/luci-app-statistics/luasrc/model/cbi/luci_statistics/contextswitch.lua b/applications/luci-app-statistics/luasrc/model/cbi/luci_statistics/contextswitch.lua
new file mode 100644 (file)
index 0000000..7ae6b24
--- /dev/null
@@ -0,0 +1,14 @@
+-- Licensed to the public under the Apache License 2.0.
+
+m = Map("luci_statistics",
+       translate("CPU Context Switches Plugin Configuration"),
+       translate("This plugin collects statistics about the processor context switches."))
+
+-- collectd_contextswitch config section
+s = m:section( NamedSection, "collectd_contextswitch", "luci_statistics" )
+
+-- collectd_contextswitch.enable
+enable = s:option( Flag, "enable", translate("Enable this plugin") )
+enable.default = 0
+
+return m
diff --git a/applications/luci-app-statistics/luasrc/statistics/rrdtool/definitions/contextswitch.lua b/applications/luci-app-statistics/luasrc/statistics/rrdtool/definitions/contextswitch.lua
new file mode 100644 (file)
index 0000000..6826e12
--- /dev/null
@@ -0,0 +1,23 @@
+-- Licensed to the public under the Apache License 2.0.
+
+module("luci.statistics.rrdtool.definitions.contextswitch",package.seeall)
+
+function rrdargs( graph, plugin, plugin_instance, dtype )
+
+       return {
+               title = "%H: Context switches",
+               alt_autoscale = true,
+               vlabel = "Switches/s",
+               number_format = "%5.0lf",
+               data = {
+                       types = { "contextswitch" },
+                       sources = {
+                               contextswitch = { "value" }
+                       },
+                       options = {
+                               contextswitch = { color = "0000ff", title = "Context switches", noarea=true, overlay=true }
+                       }
+               }
+       }
+end
+
index 774a8382e20df4c7bc35bd3e582294761d1ec959..4a11ebc3e81048cb04cfd48a3f80a8b28f20ba28 100644 (file)
@@ -162,3 +162,6 @@ config statistics 'collectd_thermal'
 config statistics 'collectd_uptime'
        option enable '0'
 
+config statistics 'collectd_contextswitch'
+        option enable '0'
+
index df9af1526101c49307a288d146c46e1c6346a2a7..93f071e3f7578add8d0f302e6f20bfd365110e7a 100755 (executable)
@@ -279,6 +279,12 @@ plugins = {
                { }
        },
 
+        contextswitch = {
+                { },
+                { },
+                { }
+        },
+
        csv     = {
                { "DataDir" },
                { "StoreRates" },