luci-app-statistics: add initial support for collect-mod-sensors
Due to a lack of a test environment this support only covers thermal graphs so far. Please send the output of "rrdtool info /tmp/rrd/*/sensors-*/*.rrd" if your system happens to support voltage, power or fanspeed sensors. Signed-off-by: Jo-Philipp Wich <jow@openwrt.org>
This commit is contained in:
parent
56deb7b2cf
commit
cff2b99b4f
5 changed files with 160 additions and 1 deletions
|
@ -45,6 +45,7 @@ function index()
|
||||||
ping = _("Ping"),
|
ping = _("Ping"),
|
||||||
processes = _("Processes"),
|
processes = _("Processes"),
|
||||||
rrdtool = _("RRDTool"),
|
rrdtool = _("RRDTool"),
|
||||||
|
sensors = _("Sensors"),
|
||||||
splash_leases = _("Splash Leases"),
|
splash_leases = _("Splash Leases"),
|
||||||
tcpconns = _("TCP Connections"),
|
tcpconns = _("TCP Connections"),
|
||||||
unixsock = _("UnixSock"),
|
unixsock = _("UnixSock"),
|
||||||
|
@ -54,7 +55,7 @@ function index()
|
||||||
-- our collectd menu
|
-- our collectd menu
|
||||||
local collectd_menu = {
|
local collectd_menu = {
|
||||||
output = { "csv", "network", "rrdtool", "unixsock" },
|
output = { "csv", "network", "rrdtool", "unixsock" },
|
||||||
general = { "cpu", "df", "disk", "email", "entropy", "exec", "irq", "load", "memory", "nut", "processes", "uptime" },
|
general = { "cpu", "df", "disk", "email", "entropy", "exec", "irq", "load", "memory", "nut", "processes", "sensors", "uptime" },
|
||||||
network = { "conntrack", "dns", "interface", "iptables", "netlink", "olsrd", "ping", "splash_leases", "tcpconns", "iwinfo" }
|
network = { "conntrack", "dns", "interface", "iptables", "netlink", "olsrd", "ping", "splash_leases", "tcpconns", "iwinfo" }
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -0,0 +1,125 @@
|
||||||
|
-- Copyright 2015 Jo-Philipp Wich <jow@openwrt.org>
|
||||||
|
-- Licensed to the public under the Apache License 2.0.
|
||||||
|
|
||||||
|
require "luci.sys"
|
||||||
|
|
||||||
|
local m, s, o
|
||||||
|
local sensor_types = {
|
||||||
|
["12v"] = "voltage",
|
||||||
|
["2.0v"] = "voltage",
|
||||||
|
["2.5v"] = "voltage",
|
||||||
|
["3.3v"] = "voltage",
|
||||||
|
["5.0v"] = "voltage",
|
||||||
|
["5v"] = "voltage",
|
||||||
|
["ain1"] = "voltage",
|
||||||
|
["ain2"] = "voltage",
|
||||||
|
["cpu_temp"] = "temperature",
|
||||||
|
["fan1"] = "fanspeed",
|
||||||
|
["fan2"] = "fanspeed",
|
||||||
|
["fan3"] = "fanspeed",
|
||||||
|
["fan4"] = "fanspeed",
|
||||||
|
["fan5"] = "fanspeed",
|
||||||
|
["fan6"] = "fanspeed",
|
||||||
|
["fan7"] = "fanspeed",
|
||||||
|
["in0"] = "voltage",
|
||||||
|
["in10"] = "voltage",
|
||||||
|
["in2"] = "voltage",
|
||||||
|
["in3"] = "voltage",
|
||||||
|
["in4"] = "voltage",
|
||||||
|
["in5"] = "voltage",
|
||||||
|
["in6"] = "voltage",
|
||||||
|
["in7"] = "voltage",
|
||||||
|
["in8"] = "voltage",
|
||||||
|
["in9"] = "voltage",
|
||||||
|
["power1"] = "power",
|
||||||
|
["remote_temp"] = "temperature",
|
||||||
|
["temp1"] = "temperature",
|
||||||
|
["temp2"] = "temperature",
|
||||||
|
["temp3"] = "temperature",
|
||||||
|
["temp4"] = "temperature",
|
||||||
|
["temp5"] = "temperature",
|
||||||
|
["temp6"] = "temperature",
|
||||||
|
["temp7"] = "temperature",
|
||||||
|
["temp"] = "temperature",
|
||||||
|
["vccp1"] = "voltage",
|
||||||
|
["vccp2"] = "voltage",
|
||||||
|
["vdd"] = "voltage",
|
||||||
|
["vid1"] = "voltage",
|
||||||
|
["vid2"] = "voltage",
|
||||||
|
["vid3"] = "voltage",
|
||||||
|
["vid4"] = "voltage",
|
||||||
|
["vid5"] = "voltage",
|
||||||
|
["vid"] = "voltage",
|
||||||
|
["vin1"] = "voltage",
|
||||||
|
["vin2"] = "voltage",
|
||||||
|
["vin3"] = "voltage",
|
||||||
|
["vin4"] = "voltage",
|
||||||
|
["volt12"] = "voltage",
|
||||||
|
["volt5"] = "voltage",
|
||||||
|
["voltbatt"] = "voltage",
|
||||||
|
["vrm"] = "voltage"
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
m = Map("luci_statistics",
|
||||||
|
translate("Sensors Plugin Configuration"),
|
||||||
|
translate("The sensors plugin uses the Linux Sensors framework to gather environmental statistics."))
|
||||||
|
|
||||||
|
s = m:section( NamedSection, "collectd_sensors", "luci_statistics" )
|
||||||
|
|
||||||
|
|
||||||
|
o = s:option( Flag, "enable", translate("Enable this plugin") )
|
||||||
|
o.default = 0
|
||||||
|
|
||||||
|
|
||||||
|
o = s:option(Flag, "__all", translate("Monitor all sensors"))
|
||||||
|
o:depends("enable", 1)
|
||||||
|
o.default = 1
|
||||||
|
o.write = function() end
|
||||||
|
o.cfgvalue = function(self, sid)
|
||||||
|
local v = self.map:get(sid, "Sensor")
|
||||||
|
if v == nil or (type(v) == "table" and #v == 0) or (type(v) == "string" and #v == 0) then
|
||||||
|
return "1"
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
|
||||||
|
o = s:option(MultiValue, "Sensor", translate("Sensor list"), translate("Hold Ctrl to select multiple items or to deselect entries."))
|
||||||
|
o:depends({enable = 1, __all = "" })
|
||||||
|
o.widget = "select"
|
||||||
|
o.rmempty = true
|
||||||
|
o.size = 0
|
||||||
|
|
||||||
|
local sensorcli = io.popen("/usr/sbin/sensors -u -A")
|
||||||
|
if sensorcli then
|
||||||
|
local bus, sensor
|
||||||
|
|
||||||
|
while true do
|
||||||
|
local ln = sensorcli:read("*ln")
|
||||||
|
if not ln then
|
||||||
|
break
|
||||||
|
elseif ln:match("^[%w-]+$") then
|
||||||
|
bus = ln
|
||||||
|
elseif ln:match("^[%w-]+:$") then
|
||||||
|
sensor = ln:sub(0, -2):lower()
|
||||||
|
if bus and sensor_types[sensor] then
|
||||||
|
o:value("%s/%s-%s" %{ bus, sensor_types[sensor], sensor })
|
||||||
|
o.size = o.size + 1
|
||||||
|
end
|
||||||
|
elseif ln == "" then
|
||||||
|
bus = nil
|
||||||
|
sensor = nil
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
sensorcli:close()
|
||||||
|
end
|
||||||
|
|
||||||
|
|
||||||
|
o = s:option( Flag, "IgnoreSelected", translate("Monitor all except specified") )
|
||||||
|
o.default = 0
|
||||||
|
o.rmempty = true
|
||||||
|
o:depends({ enable = 1, __all = "" })
|
||||||
|
|
||||||
|
return m
|
|
@ -0,0 +1,24 @@
|
||||||
|
-- Copyright 2015 Jo-Philipp Wich <jow@openwrt.org>
|
||||||
|
-- Licensed to the public under the Apache License 2.0.
|
||||||
|
|
||||||
|
module("luci.statistics.rrdtool.definitions.sensors", package.seeall)
|
||||||
|
|
||||||
|
function rrdargs( graph, plugin, plugin_instance )
|
||||||
|
return {
|
||||||
|
{
|
||||||
|
per_instance = true,
|
||||||
|
title = "%H: %pi - %di",
|
||||||
|
vlabel = "\176C",
|
||||||
|
number_format = "%4.1lf\176C",
|
||||||
|
data = {
|
||||||
|
types = { "temperature" },
|
||||||
|
options = {
|
||||||
|
temperature__value = {
|
||||||
|
color = "ff0000",
|
||||||
|
title = "Temperature"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
end
|
|
@ -140,6 +140,9 @@ config statistics 'collectd_processes'
|
||||||
option enable '0'
|
option enable '0'
|
||||||
option Processes 'uhttpd dnsmasq dropbear'
|
option Processes 'uhttpd dnsmasq dropbear'
|
||||||
|
|
||||||
|
config statistics 'collectd_sensors'
|
||||||
|
option enable '0'
|
||||||
|
|
||||||
config statistics 'collectd_splash_leases'
|
config statistics 'collectd_splash_leases'
|
||||||
option enable '0'
|
option enable '0'
|
||||||
|
|
||||||
|
|
|
@ -393,6 +393,12 @@ plugins = {
|
||||||
{ "RRATimespans" }
|
{ "RRATimespans" }
|
||||||
},
|
},
|
||||||
|
|
||||||
|
sensors = {
|
||||||
|
{ },
|
||||||
|
{ "IgnoreSelected" },
|
||||||
|
{ "Sensor" }
|
||||||
|
},
|
||||||
|
|
||||||
splash_leases = {
|
splash_leases = {
|
||||||
{ },
|
{ },
|
||||||
{ },
|
{ },
|
||||||
|
|
Loading…
Reference in a new issue