powerShell bugfix error handling

This commit is contained in:
Sebastian Hildebrandt 2019-01-17 20:13:15 +01:00
parent 71a140fa84
commit ee815ede84
3 changed files with 29 additions and 23 deletions

View File

@ -91,15 +91,16 @@ function getStaticData(callback) {
data.system = res[0];
data.bios = res[1];
data.baseboard = res[2];
data.os = res[3];
data.uuid = res[4];
data.versions = res[5];
data.cpu = res[6];
data.cpu.flags = res[7];
data.graphics = res[8];
data.net = res[9];
data.memLayout = res[10];
data.diskLayout = res[11];
data.chassis = res[3];
data.os = res[4];
data.uuid = res[5];
data.versions = res[6];
data.cpu = res[7];
data.cpu.flags = res[8];
data.graphics = res[9];
data.net = res[10];
data.memLayout = res[11];
data.diskLayout = res[12];
if (callback) { callback(data); }
resolve(data);
});
@ -107,6 +108,7 @@ function getStaticData(callback) {
});
}
// --------------------------
// get all dynamic data - e.g. for monitoring agents
// may take some seconds to get all data

View File

@ -527,7 +527,7 @@ function chassis(callback) {
result.manufacturer = util.getValue(lines, 'manufacturer', '=');
result.model = util.getValue(lines, 'model', '=');
const ctype = parseInt(util.getValue(lines, 'ChassisTypes', '='));
const ctype = parseInt(util.getValue(lines, 'ChassisTypes', '=').replace(/\D/g, ''));
result.type = (ctype && !isNaN(ctype) && ctype < chassisTypes.length) ? chassisTypes[ctype] : '';
result.version = util.getValue(lines, 'version', '=');
result.serial = util.getValue(lines, 'serialnumber', '=');

View File

@ -225,20 +225,24 @@ function powerShell(cmd) {
stdio: 'pipe'
});
child.stdout.on('data', function (data) {
result = result + data.toString('utf8');
});
child.stderr.on('data', function (data) {
child.kill();
reject(data);
});
child.on('close', function () {
child.kill();
resolve(result);
});
if (child) {
child.stdout.on('data', function (data) {
result = result + data.toString('utf8');
});
child.stderr.on('data', function (data) {
child.kill();
reject(data);
});
child.on('close', function () {
child.kill();
resolve(result);
});
child.stdin.write(cmd + '\n');
child.stdin.end();
child.stdin.write(cmd + '\n');
child.stdin.end();
} else {
reject(result);
}
});
});
}