1
0
mirror of https://github.com/DigitalDevices/octonet.git synced 2023-10-10 13:36:52 +02:00

Added fan readout to monitor

This commit is contained in:
mvoelkel 2016-08-31 17:57:15 +02:00
parent 54df76fd1e
commit 169d38705b
3 changed files with 63 additions and 6 deletions

View File

@ -59,6 +59,14 @@ if ddbridge then
ddbridge:close()
if devid == "0307dd01" then
fanstate = 1
ddbridge = io.open("/sys/class/ddbridge/ddbridge0/fanspeed1","r");
if ddbridge then
local fs = tonumber(ddbridge:read("*l"))
ddbridge:close()
if fs > 0 and fs < 17000 then
fanstate = -2
end
end
end
end

View File

@ -68,7 +68,16 @@ function myFunction(response) {
document.getElementById("TGraph").style.display = "none";
document.getElementById("NoSensor").style.display = "block";
}
if( Sensor.FanSpeed )
{
document.getElementById("FanStatus").firstChild.nodeValue = "Fan: "+ Sensor.FanSpeed + " rpm";
document.getElementById("FanStatus").style.display = "inline";
}
if( Sensor.FanState >= 0 )
{
document.getElementById("FanStatus").firstChild.nodeValue = "Fan: "+ ( Sensor.FanState > 0 ? "ON" : "OFF" );
document.getElementById("FanStatus").style.display = "inline";
}
}
function OnLoad()
@ -81,7 +90,7 @@ function OnLoad()
</head>
<body onload="OnLoad()">
<table class="maintable" align="center">
<table class="maintable">
<colgroup>
<col width="182px"/>
<col width="728px"/>
@ -106,12 +115,35 @@ function OnLoad()
</td>
</table>
-->
<h3 align="center">Frontend Temperature</h3>
<div id="NoSensor" align="center" style="display: none">
<table style="margin: auto; width: 100%; text-align: center">
<colgroup>
<col width="25%"/>
<col width="50%"/>
<col width="25%"/>
</colgroup>
<tr>
<td></td>
<td>
<p>
<h3 style="margin: auto; width: 100%; text-align: center">Frontend Temperature</h3>
</td>
<td>
<div id="FanStatus" style="display: none; margin: auto; width: 100%; margin-top: 0px; text-align: right; font-size:70%">
Fan: 2000 rpm
</div>
</td>
</tr>
</table>
<div id="NoSensor" style="display: none; margin: auto; width: 100%; text-align: center">
<p>
No temperature sensors available
</div>
<div id="TGraph" align="center" style="display: block">
<svg Id="svg" width="720px" height="330px">

View File

@ -33,7 +33,7 @@ function ReadLine(file)
if tmp then
local values = {}
local value
for value in string.gmatch(tmp,"(%d+)") do
for value in string.gmatch(tmp,"(%-?%d+)") do
table.insert(values,tonumber(value))
end
return values
@ -42,6 +42,18 @@ function ReadLine(file)
end
end
function ReadFanSpeed()
local f = io.open("/sys/class/ddbridge/ddbridge0/fanspeed1","r");
if f then
local fs = tonumber(f:read("*l"))
f:close()
if fs > 0 and fs < 17000 then
return fs
end
end
return nil
end
if method == "GET" then
data = ""
status = " 204"
@ -65,6 +77,11 @@ if method == "GET" then
data = data .. "\"Interval\":\""..Interval.."\",\n"
data = data .. "\"FanState\":\""..FanState.."\",\n"
local FanSpeed = ReadFanSpeed()
if FanSpeed then
data = data .. "\"FanSpeed\":\""..FanSpeed.."\",\n"
end
data = data .. "\"SensorData\": [\n"
local i,j
for i = 1,NumSensors,1 do