1
0
mirror of https://github.com/Ylianst/MeshAgent synced 2026-01-16 07:23:14 +00:00

GC reference update

This commit is contained in:
Bryan Roe
2021-03-18 11:43:49 -07:00
parent 4f4085d542
commit 577a59ea8e
6 changed files with 82 additions and 52 deletions

View File

@@ -22,6 +22,12 @@ function trimIdentifiers(val)
}
}
function stdparser(c)
{
if (this.str == null) { this.str = ''; }
this.str += c.toString();
}
function linux_identifiers()
{
var identifiers = {};
@@ -48,7 +54,7 @@ function linux_identifiers()
identifiers['product_uuid'] = ret['product_uuid'];
var child = require('child_process').execFile('/bin/sh', ['sh']);
child.stdout.str = ''; child.stdout.on('data', function (c) { this.str += c.toString(); });
child.stdout.str = ''; child.stdout.on('data', stdparser);
child.stdin.write('cat /proc/cpuinfo | grep "model name" | ' + "tr '\\n' ':' | awk -F: '{ print $2 }'\nexit\n");
child.waitExit();
identifiers['cpu_name'] = child.stdout.str.trim();
@@ -56,14 +62,14 @@ function linux_identifiers()
// Fetch GPU info
var child = require('child_process').execFile('/bin/sh', ['sh']);
child.stdout.str = ''; child.stdout.on('data', function (c) { this.str += c.toString(); });
child.stdout.str = ''; child.stdout.on('data', stdparser);
child.stdin.write("lspci | grep ' VGA ' | tr '\\n' '`' | awk '{ a=split($0,lines" + ',"`"); printf "["; for(i=1;i<a;++i) { split(lines[i],gpu,"r: "); printf "%s\\"%s\\"", (i==1?"":","),gpu[2]; } printf "]"; }\'\nexit\n');
child.waitExit();
try { identifiers['gpu_name'] = JSON.parse(child.stdout.str.trim()); } catch (xx) { }
// Fetch Storage Info
var child = require('child_process').execFile('/bin/sh', ['sh']);
child.stdout.str = ''; child.stdout.on('data', function (c) { this.str += c.toString(); });
child.stdout.str = ''; child.stdout.on('data', stdparser);
child.stdin.write("lshw -class disk | tr '\\n' '`' | awk '" + '{ len=split($0,lines,"*"); printf "["; for(i=2;i<=len;++i) { model=""; caption=""; size=""; clen=split(lines[i],item,"`"); for(j=2;j<clen;++j) { split(item[j],tokens,":"); split(tokens[1],key," "); if(key[1]=="description") { caption=substr(tokens[2],2); } if(key[1]=="product") { model=substr(tokens[2],2); } if(key[1]=="size") { size=substr(tokens[2],2); } } if(model=="") { model=caption; } if(caption!="" || model!="") { printf "%s{\\"Caption\\":\\"%s\\",\\"Model\\":\\"%s\\",\\"Size\\":\\"%s\\"}",(i==2?"":","),caption,model,size; } } printf "]"; }\'\nexit\n');
child.waitExit();
try { identifiers['storage_devices'] = JSON.parse(child.stdout.str.trim()); } catch (xx) { }
@@ -171,7 +177,7 @@ function windows_identifiers()
{
var ret = { windows: {}}; values = {}; var items; var i; var item;
var child = require('child_process').execFile(process.env['windir'] + '\\System32\\wbem\\wmic.exe', ['wmic', 'bios', 'get', '/VALUE']);
child.stdout.str = ''; child.stdout.on('data', function (c) { this.str += c.toString(); });
child.stdout.str = ''; child.stdout.on('data', stdparser);
child.waitExit();
var items = child.stdout.str.split('\r\r\n');
@@ -187,7 +193,7 @@ function windows_identifiers()
ret['identifiers']['bios_version'] = values['SMBIOSBIOSVersion'];
child = require('child_process').execFile(process.env['windir'] + '\\System32\\wbem\\wmic.exe', ['wmic', 'BASEBOARD', 'get', '/VALUE']);
child.stdout.str = ''; child.stdout.on('data', function (c) { this.str += c.toString(); });
child.stdout.str = ''; child.stdout.on('data', stdparser);
child.waitExit();
var items = child.stdout.str.split('\r\r\n');
@@ -202,7 +208,7 @@ function windows_identifiers()
ret['identifiers']['board_version'] = values['Version'];
child = require('child_process').execFile(process.env['windir'] + '\\System32\\wbem\\wmic.exe', ['wmic', 'CSProduct', 'get', '/VALUE']);
child.stdout.str = ''; child.stdout.on('data', function (c) { this.str += c.toString(); });
child.stdout.str = ''; child.stdout.on('data', stdparser);
child.waitExit();
var items = child.stdout.str.split('\r\r\n');
@@ -217,32 +223,32 @@ function windows_identifiers()
var CSV = '/FORMAT:"' + require('util-language').wmicXslPath + 'csv"';
child = require('child_process').execFile(process.env['windir'] + '\\System32\\wbem\\wmic.exe', ['wmic', 'MEMORYCHIP', 'LIST', CSV]);
child.stdout.str = ''; child.stdout.on('data', function (c) { this.str += c.toString(); });
child.stdout.str = ''; child.stdout.on('data', stdparser);
child.waitExit();
ret.windows.memory = windows_wmic_results(child.stdout.str);
child = require('child_process').execFile(process.env['windir'] + '\\System32\\wbem\\wmic.exe', ['wmic', 'OS', 'GET', CSV]);
child.stdout.str = ''; child.stdout.on('data', function (c) { this.str += c.toString(); });
child.stdout.str = ''; child.stdout.on('data', stdparser);
child.waitExit();
ret.windows.osinfo = windows_wmic_results(child.stdout.str)[0];
child = require('child_process').execFile(process.env['windir'] + '\\System32\\wbem\\wmic.exe', ['wmic', 'PARTITION', 'LIST', CSV]);
child.stdout.str = ''; child.stdout.on('data', function (c) { this.str += c.toString(); });
child.stdout.str = ''; child.stdout.on('data', stdparser);
child.waitExit();
ret.windows.partitions = windows_wmic_results(child.stdout.str);
child = require('child_process').execFile(process.env['windir'] + '\\System32\\wbem\\wmic.exe', ['wmic', 'CPU', 'LIST', 'BRIEF', CSV]);
child.stdout.str = ''; child.stdout.on('data', function (c) { this.str += c.toString(); });
child.stdout.str = ''; child.stdout.on('data', stdparser);
child.waitExit();
ret.windows.cpu = windows_wmic_results(child.stdout.str);
child = require('child_process').execFile(process.env['windir'] + '\\System32\\wbem\\wmic.exe', ['wmic', 'PATH', 'Win32_VideoController', 'GET', 'Name,CurrentHorizontalResolution,CurrentVerticalResolution', CSV]);
child.stdout.str = ''; child.stdout.on('data', function (c) { this.str += c.toString(); });
child.stdout.str = ''; child.stdout.on('data', stdparser);
child.waitExit();
ret.windows.gpu = windows_wmic_results(child.stdout.str);
child = require('child_process').execFile(process.env['windir'] + '\\System32\\wbem\\wmic.exe', ['wmic', 'diskdrive', 'LIST', 'BRIEF', CSV]);
child.stdout.str = ''; child.stdout.on('data', function (c) { this.str += c.toString(); });
child.stdout.str = ''; child.stdout.on('data', stdparser);
child.waitExit();
ret.windows.drives = windows_wmic_results(child.stdout.str);
@@ -261,6 +267,7 @@ function windows_identifiers()
}
try { ret.identifiers.cpu_name = ret.windows.cpu[0].Name; } catch (x) { }
child = null;
return (ret);
}
function macos_identifiers()
@@ -386,7 +393,7 @@ module.exports.isDocker = function isDocker()
if (process.platform != 'linux') { return (false); }
var child = require('child_process').execFile('/bin/sh', ['sh']);
child.stdout.str = ''; child.stdout.on('data', function (c) { this.str += c.toString(); });
child.stdout.str = ''; child.stdout.on('data', stdparser);
child.stdin.write("cat /proc/self/cgroup | tr '\n' '`' | awk -F'`' '{ split($1, res, " + '"/"); if(res[2]=="docker"){print "1";} }\'\nexit\n');
child.waitExit();
return (child.stdout.str != '');