fix linux csv output (#5661)
Signed-off-by: si458 <simonsmith5521@gmail.com>
Simon Smith committed
Jan 3, 2024 at 15:20 UTC
45722c70d4e4f48b9a0ad4ba57557fe5a8dee060
1 file changed
+16
-4
meshuser.js
+16
-4
@@ -4977,7 +4977,7 @@ module.exports.CreateMeshUser = function (parent, db, ws, req, args, domain, use
4977
}
4978
4979
// System infomation
4980
- if ((nodeinfo.sys) && (nodeinfo.sys.hardware) && (nodeinfo.sys.hardware.windows) && (nodeinfo.sys.hardware.windows)) {
4980
+ if ((nodeinfo.sys) && (nodeinfo.sys.hardware) && (nodeinfo.sys.hardware.windows)) {
4981
// Windows
4982
output += ',';
4983
if (nodeinfo.sys.hardware.windows.cpu && (nodeinfo.sys.hardware.windows.cpu.length > 0) && (typeof nodeinfo.sys.hardware.windows.cpu[0].Name == 'string')) { output += csvClean(nodeinfo.sys.hardware.windows.cpu[0].Name); }
@@ -5042,11 +5042,11 @@ module.exports.CreateMeshUser = function (parent, db, ws, req, args, domain, use
5042
output += ',';
5043
output += ',';
5044
output += ',';
5045
- } else if ((nodeinfo.sys) && (nodeinfo.sys.hardware) && (nodeinfo.sys.hardware.windows) && (nodeinfo.sys.hardware.linux)) {
5045
+ } else if ((nodeinfo.sys) && (nodeinfo.sys.hardware) && (nodeinfo.sys.hardware.linux)) {
5046
// Linux
5047
output += ',';
5048
- output += ',';
5049
- output += ',';
5048
+ if (nodeinfo.sys.hardware.identifiers && (nodeinfo.sys.hardware.identifiers.cpu_name)) { output += csvClean(nodeinfo.sys.hardware.identifiers.cpu_name); }
5049
+ output += ',,';
5050
if (nodeinfo.sys.hardware.linux && (nodeinfo.sys.hardware.linux.bios_date)) { output += csvClean(nodeinfo.sys.hardware.linux.bios_date); }
5051
output += ',';
5052
if (nodeinfo.sys.hardware.linux && (nodeinfo.sys.hardware.linux.bios_vendor)) { output += csvClean(nodeinfo.sys.hardware.linux.bios_vendor); }
@@ -5073,6 +5073,18 @@ module.exports.CreateMeshUser = function (parent, db, ws, req, args, domain, use
5073
output += ',';
5074
if (nodeinfo.sys.hardware.tpm && nodeinfo.sys.hardware.tpm.IsOwned) { output += csvClean(nodeinfo.sys.hardware.tpm.IsOwned ? 'true' : 'false'); }
5075
output += ',';
5076
+ if (nodeinfo.sys.hardware.linux.memory) {
5077
+ if (nodeinfo.sys.hardware.linux.memory.Memory_Device) {
5078
+ var totalMemory = 0;
5079
+ for (var j in nodeinfo.sys.hardware.linux.memory.Memory_Device) {
5080
+ if (nodeinfo.sys.hardware.linux.memory.Memory_Device[j].Size) {
5081
+ if (typeof nodeinfo.sys.hardware.linux.memory.Memory_Device[j].Size == 'number') { totalMemory += nodeinfo.sys.hardware.linux.memory.Memory_Device[j].Size; }
5082
+ if (typeof nodeinfo.sys.hardware.linux.memory.Memory_Device[j].Size == 'string') { totalMemory += parseInt(nodeinfo.sys.hardware.linux.memory.Memory_Device[j].Size); }
5083
+ }
5084
+ }
5085
+ output += csvClean('' + (totalMemory * Math.pow(1024, 3)));
5086
+ }
5087
+ }
5088
} else {
5089
output += ',,,,,,,,,,,,,,,,';
5090
}