mirror of
				https://github.com/Ylianst/MeshCentral.git
				synced 2025-03-09 15:40:18 +00:00 
			
		
		
		
	add hover title to temps and more sensors (#5434)
* 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>
This commit is contained in:
		
							parent
							
								
									47767e86a1
								
							
						
					
					
						commit
						58580beb96
					
				
					 3 changed files with 38 additions and 10 deletions
				
			
		| 
						 | 
				
			
			@ -225,17 +225,23 @@ 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);
 | 
			
		||||
| 
						 | 
				
			
			@ -243,13 +249,35 @@ function windows_thermals()
 | 
			
		|||
 | 
			
		||||
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("cat /sys/class/thermal/thermal_zone*/temp | awk '{ print $0 / 1000 }'\nexit\n");
 | 
			
		||||
    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();
 | 
			
		||||
    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[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("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();
 | 
			
		||||
    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);
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
| 
						 | 
				
			
			@ -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']);
 | 
			
		||||
| 
						 | 
				
			
			@ -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();
 | 
			
		||||
                }
 | 
			
		||||
            }
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -3202,6 +3202,7 @@ a {
 | 
			
		|||
    background-color: gold;
 | 
			
		||||
    margin-right: 6px;
 | 
			
		||||
    border-radius: 4px;
 | 
			
		||||
    margin-bottom: 5px;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
.night .thermalSensor {
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -11518,7 +11518,7 @@
 | 
			
		|||
            if (message != null) {
 | 
			
		||||
                if (Array.isArray(message.thermals) && (message.thermals.length > 0)) {
 | 
			
		||||
                    var x = ' ';
 | 
			
		||||
                    for (var i in message.thermals) { x += '<div class=thermalSensor>' +  parseFloat(message.thermals[i]).toFixed(2) + '°C / ' + parseFloat((message.thermals[i] * 1.8) + 32).toFixed(2) + '°F' + '</div>'; }
 | 
			
		||||
                    for (var i in message.thermals) { x += '<div class=thermalSensor title="'+message.thermals[i].InstanceName+'">' +  parseFloat(message.thermals[i].CurrentTemperature).toFixed(2) + '°C / ' + parseFloat((message.thermals[i].CurrentTemperature * 1.8) + 32).toFixed(2) + '°F' + '</div>'; }
 | 
			
		||||
                    QV('extraGraphValues', true);
 | 
			
		||||
                    QH('extraGraphValues', x);
 | 
			
		||||
                }
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue