mirror of
https://github.com/Ylianst/MeshCentral.git
synced 2025-01-12 07:23:21 -05:00
Added thermal support for linux and macos
This commit is contained in:
parent
a4a6a5d44f
commit
cdd5153b93
@ -234,17 +234,60 @@ function windows_thermals()
|
|||||||
return (ret);
|
return (ret);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function linux_thermals()
|
||||||
|
{
|
||||||
|
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.waitExit();
|
||||||
|
var ret = child.stdout.str.trim().split('\n');
|
||||||
|
if (ret.length == 1 && ret[0] == '') { ret = []; }
|
||||||
|
return (ret);
|
||||||
|
}
|
||||||
|
|
||||||
|
function macos_thermals()
|
||||||
|
{
|
||||||
|
var ret = [];
|
||||||
|
var child = require('child_process').execFile('/bin/sh', ['sh']);
|
||||||
|
child.stdout.str = ''; child.stdout.on('data', function (c) { this.str += c.toString(); });
|
||||||
|
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']);
|
||||||
|
child.stdout.str = ''; child.stdout.on('data', function (c)
|
||||||
|
{
|
||||||
|
this.str += c.toString();
|
||||||
|
var tokens = this.str.trim().split('\n');
|
||||||
|
for (var i in tokens)
|
||||||
|
{
|
||||||
|
if (tokens[i].split(' die temperature: ').length > 1)
|
||||||
|
{
|
||||||
|
ret.push(tokens[i].split(' ')[3]);
|
||||||
|
this.parent.kill();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
});
|
||||||
|
child.stderr.str = ''; child.stderr.on('data', function (c) { this.str += c.toString(); });
|
||||||
|
child.stdin.write('powermetrics -s smc\n');
|
||||||
|
child.waitExit(5000);
|
||||||
|
}
|
||||||
|
return (ret);
|
||||||
|
}
|
||||||
|
|
||||||
switch(process.platform)
|
switch(process.platform)
|
||||||
{
|
{
|
||||||
case 'linux':
|
case 'linux':
|
||||||
module.exports = { cpuUtilization: linux_cpuUtilization, memUtilization: linux_memUtilization };
|
module.exports = { cpuUtilization: linux_cpuUtilization, memUtilization: linux_memUtilization, thermals: linux_thermals };
|
||||||
break;
|
break;
|
||||||
case 'win32':
|
case 'win32':
|
||||||
module.exports = { cpuUtilization: windows_cpuUtilization, memUtilization: windows_memUtilization, thermals: windows_thermals };
|
module.exports = { cpuUtilization: windows_cpuUtilization, memUtilization: windows_memUtilization, thermals: windows_thermals };
|
||||||
break;
|
break;
|
||||||
case 'darwin':
|
case 'darwin':
|
||||||
module.exports = { cpuUtilization: macos_cpuUtilization, memUtilization: macos_memUtilization };
|
module.exports = { cpuUtilization: macos_cpuUtilization, memUtilization: macos_memUtilization, thermals: macos_thermals };
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -234,17 +234,60 @@ function windows_thermals()
|
|||||||
return (ret);
|
return (ret);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function linux_thermals()
|
||||||
|
{
|
||||||
|
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.waitExit();
|
||||||
|
var ret = child.stdout.str.trim().split('\n');
|
||||||
|
if (ret.length == 1 && ret[0] == '') { ret = []; }
|
||||||
|
return (ret);
|
||||||
|
}
|
||||||
|
|
||||||
|
function macos_thermals()
|
||||||
|
{
|
||||||
|
var ret = [];
|
||||||
|
var child = require('child_process').execFile('/bin/sh', ['sh']);
|
||||||
|
child.stdout.str = ''; child.stdout.on('data', function (c) { this.str += c.toString(); });
|
||||||
|
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']);
|
||||||
|
child.stdout.str = ''; child.stdout.on('data', function (c)
|
||||||
|
{
|
||||||
|
this.str += c.toString();
|
||||||
|
var tokens = this.str.trim().split('\n');
|
||||||
|
for (var i in tokens)
|
||||||
|
{
|
||||||
|
if (tokens[i].split(' die temperature: ').length > 1)
|
||||||
|
{
|
||||||
|
ret.push(tokens[i].split(' ')[3]);
|
||||||
|
this.parent.kill();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
});
|
||||||
|
child.stderr.str = ''; child.stderr.on('data', function (c) { this.str += c.toString(); });
|
||||||
|
child.stdin.write('powermetrics -s smc\n');
|
||||||
|
child.waitExit(5000);
|
||||||
|
}
|
||||||
|
return (ret);
|
||||||
|
}
|
||||||
|
|
||||||
switch(process.platform)
|
switch(process.platform)
|
||||||
{
|
{
|
||||||
case 'linux':
|
case 'linux':
|
||||||
module.exports = { cpuUtilization: linux_cpuUtilization, memUtilization: linux_memUtilization };
|
module.exports = { cpuUtilization: linux_cpuUtilization, memUtilization: linux_memUtilization, thermals: linux_thermals };
|
||||||
break;
|
break;
|
||||||
case 'win32':
|
case 'win32':
|
||||||
module.exports = { cpuUtilization: windows_cpuUtilization, memUtilization: windows_memUtilization, thermals: windows_thermals };
|
module.exports = { cpuUtilization: windows_cpuUtilization, memUtilization: windows_memUtilization, thermals: windows_thermals };
|
||||||
break;
|
break;
|
||||||
case 'darwin':
|
case 'darwin':
|
||||||
module.exports = { cpuUtilization: macos_cpuUtilization, memUtilization: macos_memUtilization };
|
module.exports = { cpuUtilization: macos_cpuUtilization, memUtilization: macos_memUtilization, thermals: macos_thermals };
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user