Skip to content

Commit

Permalink
Fix showing partial cpu stats
Browse files Browse the repository at this point in the history
Signed-off-by: falkTX <falktx@falktx.com>
  • Loading branch information
falkTX committed Feb 20, 2024
1 parent 6615183 commit 0595788
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 6 deletions.
4 changes: 4 additions & 0 deletions html/js/host.js
Original file line number Diff line number Diff line change
Expand Up @@ -119,6 +119,10 @@ $('document').ready(function() {
$("#mod-cpu-stats").html(sprintf("%.1f GHz / %d &deg;C",
parseInt(cpufreq)/1000000,
parseInt(cputemp)/1000))
} else if (cpufreq !== "0") {
$("#mod-cpu-stats").html(sprintf("%.1f GHz", parseInt(cpufreq)/1000000))
} else if (cputemp !== "0") {
$("#mod-cpu-stats").html(sprintf("%d &deg;C", parseInt(cputemp)/1000))
}
return
}
Expand Down
13 changes: 8 additions & 5 deletions mod/host.py
Original file line number Diff line number Diff line change
Expand Up @@ -4774,11 +4774,14 @@ def get_free_memory_value(self):
def get_system_stats_message(self):
memload = self.get_free_memory_value()
cpufreq = read_file_contents(self.cpufreqfile, "0")
try:
cputemp = read_file_contents(self.thermalfile, "0")
except OSError:
cputemp = "0"
self.thermalfile = None
cputemp = "0"

if self.thermalfile is not None:
try:
cputemp = read_file_contents(self.thermalfile, "0")
except OSError:
self.thermalfile = None

return "sys_stats %s %s %s" % (memload, cpufreq, cputemp)

def memtimer_callback(self):
Expand Down
5 changes: 4 additions & 1 deletion mod/webserver.py
Original file line number Diff line number Diff line change
Expand Up @@ -1977,11 +1977,14 @@ def post(self):
index = freqs.index(cur_freq) + 1
if index >= len(freqs):
index = 0
next_freq = freqs[index]
if cur_freq == next_freq:
return self.write(True)
with open("/sys/devices/system/cpu/online", 'r') as fh:
num_start, num_end = tuple(int(i) for i in fh.read().strip().split("-"))
for num in range(num_start, num_end+1):
with open("/sys/devices/system/cpu/cpu%d/cpufreq/scaling_setspeed" % num, 'w') as fh:
fh.write(freqs[index])
fh.write(next_freq)
self.write(True)

class SaveSingleConfigValue(JsonRequestHandler):
Expand Down

0 comments on commit 0595788

Please sign in to comment.