Skip to content

Commit

Permalink
add hover title to temps and more sensors (#5434)
Browse files Browse the repository at this point in the history
* add hover title to temperatures

Signed-off-by: Simon Smith <simonsmith5521@gmail.com>

* fix temp trim

Signed-off-by: Simon Smith <simonsmith5521@gmail.com>

* add extra linux sensors

Signed-off-by: Simon Smith <simonsmith5521@gmail.com>

* add padding for temps on multi lines

Signed-off-by: Simon Smith <simonsmith5521@gmail.com>

---------

Signed-off-by: Simon Smith <simonsmith5521@gmail.com>
  • Loading branch information
si458 authored Oct 21, 2023
1 parent 47767e8 commit 58580be
Show file tree
Hide file tree
Showing 3 changed files with 38 additions and 10 deletions.
45 changes: 36 additions & 9 deletions agents/modules_meshcore/sysinfo.js
Original file line number Diff line number Diff line change
Expand Up @@ -225,31 +225,59 @@ function macos_memUtilization()
function windows_thermals()
{
var ret = [];
child = require('child_process').execFile(process.env['windir'] + '\\System32\\wbem\\wmic.exe', ['wmic', '/namespace:\\\\root\\wmi', 'PATH', 'MSAcpi_ThermalZoneTemperature', 'get', 'CurrentTemperature']);
child = require('child_process').execFile(process.env['windir'] + '\\System32\\wbem\\wmic.exe', ['wmic', '/namespace:\\\\root\\wmi', 'PATH', 'MSAcpi_ThermalZoneTemperature', 'get', 'CurrentTemperature,InstanceName', '/FORMAT:CSV']);
child.stdout.str = ''; child.stdout.on('data', function (c) { this.str += c.toString(); });
child.stderr.str = ''; child.stderr.on('data', function (c) { this.str += c.toString(); });
child.waitExit();

if(child.stdout.str.trim!='')
if(child.stdout.str.trim()!='')
{
var lines = child.stdout.str.trim().split('\r\n');
var keys = lines[0].trim().split(',');
for (var i = 1; i < lines.length; ++i)
{
if (lines[i].trim() != '') { ret.push(((parseFloat(lines[i]) / 10) - 273.15).toFixed(2)); }
var obj = {};
var tokens = lines[i].trim().split(',');
for (var key = 0; key < keys.length; ++key)
{
if (tokens[key]) { obj[keys[key]] = key==1 ? ((parseFloat(tokens[key]) / 10) - 273.15).toFixed(2) : tokens[key]; }
}
ret.push(obj);
}
}
return (ret);
}

function linux_thermals()
{
var ret = [];
child = require('child_process').execFile('/bin/sh', ['sh']);
child.stdout.str = ''; child.stdout.on('data', function (c) { this.str += c.toString(); });
child.stderr.str = ''; child.stderr.on('data', function (c) { this.str += c.toString(); });
child.stdin.write("for folder in /sys/class/thermal/thermal_zone*/; do [ -e \"$folder/temp\" ] && echo \"$(cat \"$folder/temp\"),$(cat \"$folder/type\")\"; done\nexit\n");
child.waitExit();
if(child.stdout.str.trim()!='')
{
var lines = child.stdout.str.trim().split('\n');
for (var i = 0; i < lines.length; ++i)
{
var line = lines[i].trim().split(',');
ret.push({CurrentTemperature: (parseFloat(line[0])/1000), InstanceName: line[1]});
}
}
child = require('child_process').execFile('/bin/sh', ['sh']);
child.stdout.str = ''; child.stdout.on('data', function (c) { this.str += c.toString(); });
child.stderr.str = ''; child.stderr.on('data', function (c) { this.str += c.toString(); });
child.stdin.write("cat /sys/class/thermal/thermal_zone*/temp | awk '{ print $0 / 1000 }'\nexit\n");
child.stdin.write("for mon in /sys/class/hwmon/hwmon*; do for label in \"$mon\"/temp*_label; do if [ -f $label ]; then echo $(cat \"$label\")___$(cat \"${label%_*}_input\"); fi; done; done;\nexit\n");
child.waitExit();
var ret = child.stdout.str.trim().split('\n');
if (ret.length == 1 && ret[0] == '') { ret = []; }
if(child.stdout.str.trim()!='')
{
var lines = child.stdout.str.trim().split('\n');
for (var i = 0; i < lines.length; ++i)
{
var line = lines[i].trim().split('___');
ret.push({ CurrentTemperature: (parseFloat(line[1])/1000), InstanceName: line[0] });
}
}
return (ret);
}

Expand All @@ -261,7 +289,6 @@ function macos_thermals()
child.stderr.on('data', function () { });
child.stdin.write('powermetrics --help | grep SMC\nexit\n');
child.waitExit();

if (child.stdout.str.trim() != '')
{
child = require('child_process').execFile('/bin/sh', ['sh']);
Expand All @@ -273,7 +300,7 @@ function macos_thermals()
{
if (tokens[i].split(' die temperature: ').length > 1)
{
ret.push(tokens[i].split(' ')[3]);
ret.push({CurrentTemperature: tokens[i].split(' ')[3], InstanceName: tokens[i].split(' ')[0]});
this.parent.kill();
}
}
Expand Down
1 change: 1 addition & 0 deletions public/styles/style.css
Original file line number Diff line number Diff line change
Expand Up @@ -3202,6 +3202,7 @@ a {
background-color: gold;
margin-right: 6px;
border-radius: 4px;
margin-bottom: 5px;
}

.night .thermalSensor {
Expand Down
2 changes: 1 addition & 1 deletion views/default.handlebars
Original file line number Diff line number Diff line change
Expand Up @@ -11518,7 +11518,7 @@
if (message != null) {
if (Array.isArray(message.thermals) && (message.thermals.length > 0)) {
var x = '&nbsp;';
for (var i in message.thermals) { x += '<div class=thermalSensor>' + parseFloat(message.thermals[i]).toFixed(2) + '&deg;C / ' + parseFloat((message.thermals[i] * 1.8) + 32).toFixed(2) + '&deg;F' + '</div>'; }
for (var i in message.thermals) { x += '<div class=thermalSensor title="'+message.thermals[i].InstanceName+'">' + parseFloat(message.thermals[i].CurrentTemperature).toFixed(2) + '&deg;C / ' + parseFloat((message.thermals[i].CurrentTemperature * 1.8) + 32).toFixed(2) + '&deg;F' + '</div>'; }
QV('extraGraphValues', true);
QH('extraGraphValues', x);
}
Expand Down

0 comments on commit 58580be

Please sign in to comment.