mirror of
https://github.com/Ysurac/openmptcprouter-feeds.git
synced 2025-03-09 15:40:03 +00:00
Display core temp when available in all cases
This commit is contained in:
parent
0e383c542c
commit
6c2ffa6cf0
1 changed files with 7 additions and 1 deletions
|
@ -8,6 +8,11 @@ local net = require "luci.model.network".init()
|
||||||
local ucic = require "luci.model.uci".cursor()
|
local ucic = require "luci.model.uci".cursor()
|
||||||
local jsonc = require "luci.jsonc"
|
local jsonc = require "luci.jsonc"
|
||||||
|
|
||||||
|
function file_exists(name)
|
||||||
|
local f = io.open(name, "r")
|
||||||
|
return f ~= nil and io.close(f)
|
||||||
|
end
|
||||||
|
|
||||||
function interface_from_device(dev)
|
function interface_from_device(dev)
|
||||||
for _, iface in ipairs(net:get_networks()) do
|
for _, iface in ipairs(net:get_networks()) do
|
||||||
local ifacen = iface:name()
|
local ifacen = iface:name()
|
||||||
|
@ -1183,7 +1188,8 @@ function interfaces_status()
|
||||||
mArray.openmptcprouter['model'] = sys.exec("ubus call system board | jsonfilter -q -e '@.model' 2>/dev/null | tr -d '\n'")
|
mArray.openmptcprouter['model'] = sys.exec("ubus call system board | jsonfilter -q -e '@.model' 2>/dev/null | tr -d '\n'")
|
||||||
local board_name = sys.exec("ubus call system board | jsonfilter -q -e '@.board_name' 2>/dev/null | tr -d '\n'")
|
local board_name = sys.exec("ubus call system board | jsonfilter -q -e '@.board_name' 2>/dev/null | tr -d '\n'")
|
||||||
-- retrieve core temperature
|
-- retrieve core temperature
|
||||||
if board_name:match("^raspberrypi.*") then
|
--if board_name:match("^raspberrypi.*") then
|
||||||
|
if file_exists("/sys/class/thermal/thermal_zone0/temp") then
|
||||||
mArray.openmptcprouter["core_temp"] = sys.exec("cat /sys/class/thermal/thermal_zone0/temp 2>/dev/null"):match("%d+")
|
mArray.openmptcprouter["core_temp"] = sys.exec("cat /sys/class/thermal/thermal_zone0/temp 2>/dev/null"):match("%d+")
|
||||||
end
|
end
|
||||||
mArray.openmptcprouter["loadavg"] = sys.exec("cat /proc/loadavg 2>/dev/null"):match("[%d%.]+ [%d%.]+ [%d%.]+")
|
mArray.openmptcprouter["loadavg"] = sys.exec("cat /proc/loadavg 2>/dev/null"):match("[%d%.]+ [%d%.]+ [%d%.]+")
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue