mirror of
https://github.com/Ylianst/MeshCentral.git
synced 2024-12-26 07:05:52 -05:00
Added task limiter to AMT manager
This commit is contained in:
parent
e7ceecca23
commit
b53cbc67a5
@ -2945,6 +2945,7 @@ function performAmtPowerActionEx2(stack, name, response, status) {
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
//
|
||||
// Get MEI state
|
||||
//
|
||||
@ -2964,11 +2965,19 @@ function getMeiState(flags, func) {
|
||||
amtMei.getEHBCState(function (result) { if ((result != null) && (result.EHBC == true)) { amtMeiTmpState.Flags += 1; } });
|
||||
amtMei.getControlMode(function (result) { if (result != null) { if (result.controlMode == 1) { amtMeiTmpState.Flags += 2; } if (result.controlMode == 2) { amtMeiTmpState.Flags += 4; } } }); // Flag 2 = CCM, 4 = ACM
|
||||
//amtMei.getMACAddresses(function (result) { if (result) { amtMeiTmpState.mac = result; } });
|
||||
if ((flags & 8) != 0) { amtMei.getLanInterfaceSettings(0, function (result) { if (result) { amtMeiTmpState.net0 = result; } }); }
|
||||
if ((flags & 8) != 0) { amtMei.getLanInterfaceSettings(1, function (result) { if (result) { amtMeiTmpState.net1 = result; } }); }
|
||||
if ((flags & 8) != 0) {
|
||||
amtMei.getLanInterfaceSettings(0, function (result) {
|
||||
if (result) {
|
||||
amtMeiTmpState.net0 = result;
|
||||
var fqdn = null, interfaces = require('os').networkInterfaces(); // Look for the DNS suffix for the Intel AMT Ethernet interface
|
||||
for (var i in interfaces) { for (var j in interfaces[i]) { if ((interfaces[i][j].mac == amtMeiTmpState.net0.mac) && (interfaces[i][j].fqdn != null) && (interfaces[i][j].fqdn != '')) { amtMeiTmpState.OsDnsSuffix = interfaces[i][j].fqdn; } } }
|
||||
}
|
||||
});
|
||||
amtMei.getLanInterfaceSettings(1, function (result) { if (result) { amtMeiTmpState.net1 = result; } });
|
||||
}
|
||||
amtMei.getUuid(function (result) { if ((result != null) && (result.uuid != null)) { amtMeiTmpState.UUID = result.uuid; } });
|
||||
if ((flags & 2) != 0) { amtMei.getLocalSystemAccount(function (x) { if ((x != null) && x.user && x.pass) { amtMeiTmpState.OsAdmin = { user: x.user, pass: x.pass }; } }); }
|
||||
amtMei.getDnsSuffix(function (result) { if (result != null) { amtMeiTmpState.DNS = result; } if ((flags & 4) == 0) { if (func != null) { func(amtMeiTmpState); } } });
|
||||
amtMei.getDnsSuffix(function (result) { if (result != null) { amtMeiTmpState.DnsSuffix = result; } if ((flags & 4) == 0) { if (func != null) { func(amtMeiTmpState); } } });
|
||||
if ((flags & 4) != 0) {
|
||||
amtMei.getHashHandles(function (handles) {
|
||||
if (handles != null) { amtMeiTmpState.Hashes = []; } else { func(amtMeiTmpState); }
|
||||
|
@ -3848,11 +3848,19 @@ function createMeshCore(agent) {
|
||||
amtMei.getEHBCState(function (result) { if ((result != null) && (result.EHBC == true)) { amtMeiTmpState.Flags += 1; } });
|
||||
amtMei.getControlMode(function (result) { if (result != null) { if (result.controlMode == 1) { amtMeiTmpState.Flags += 2; } if (result.controlMode == 2) { amtMeiTmpState.Flags += 4; } } }); // Flag 2 = CCM, 4 = ACM
|
||||
//amtMei.getMACAddresses(function (result) { if (result) { amtMeiTmpState.mac = result; } });
|
||||
if ((flags & 8) != 0) { amtMei.getLanInterfaceSettings(0, function (result) { if (result) { amtMeiTmpState.net0 = result; } }); }
|
||||
if ((flags & 8) != 0) { amtMei.getLanInterfaceSettings(1, function (result) { if (result) { amtMeiTmpState.net1 = result; } }); }
|
||||
if ((flags & 8) != 0) {
|
||||
amtMei.getLanInterfaceSettings(0, function (result) {
|
||||
if (result) {
|
||||
amtMeiTmpState.net0 = result;
|
||||
var fqdn = null, interfaces = require('os').networkInterfaces(); // Look for the DNS suffix for the Intel AMT Ethernet interface
|
||||
for (var i in interfaces) { for (var j in interfaces[i]) { if ((interfaces[i][j].mac == mestate.net0.mac) && (interfaces[i][j].fqdn != null) && (interfaces[i][j].fqdn != '')) { amtMeiTmpState.OsDnsSuffix = interfaces[i][j].fqdn; } } }
|
||||
}
|
||||
});
|
||||
amtMei.getLanInterfaceSettings(1, function (result) { if (result) { amtMeiTmpState.net1 = result; } });
|
||||
}
|
||||
amtMei.getUuid(function (result) { if ((result != null) && (result.uuid != null)) { amtMeiTmpState.UUID = result.uuid; } });
|
||||
if ((flags & 2) != 0) { amtMei.getLocalSystemAccount(function (x) { if ((x != null) && x.user && x.pass) { amtMeiTmpState.OsAdmin = { user: x.user, pass: x.pass }; } }); }
|
||||
amtMei.getDnsSuffix(function (result) { if (result != null) { amtMeiTmpState.DNS = result; } if ((flags & 4) == 0) { if (func != null) { func(amtMeiTmpState); } } });
|
||||
amtMei.getDnsSuffix(function (result) { if (result != null) { amtMeiTmpState.DnsSuffix = result; } if ((flags & 4) == 0) { if (func != null) { func(amtMeiTmpState); } } });
|
||||
if ((flags & 4) != 0) {
|
||||
amtMei.getHashHandles(function (handles) {
|
||||
if (handles != null) { amtMeiTmpState.Hashes = []; } else { func(amtMeiTmpState); }
|
||||
|
@ -86,6 +86,9 @@ module.exports.CreateAmtManager = function(parent) {
|
||||
|
||||
// Remove all Intel AMT devices for a given nodeid
|
||||
function removeDevice(nodeid) {
|
||||
// Remove from task limiter if needed
|
||||
if (dev.taskid != null) { obj.parent.taskLimiter.completed(dev.taskid); delete dev.taskLimiter; }
|
||||
|
||||
// Find the devices in the list
|
||||
var devices = obj.amtDevices[nodeid];
|
||||
if (devices == null) return false;
|
||||
@ -118,7 +121,18 @@ module.exports.CreateAmtManager = function(parent) {
|
||||
dev.controlMsg.conn = connection;
|
||||
parent.debug('amt', "Start Management", nodeid, connType);
|
||||
addAmtDevice(dev);
|
||||
fetchIntelAmtInformation(dev);
|
||||
|
||||
// Start the device manager the task limiter so not to flood the server. Low priority task
|
||||
obj.parent.taskLimiter.launch(function (dev, taskid, taskLimiterQueue) {
|
||||
if (isAmtDeviceValid(dev)) {
|
||||
// Start managing this device
|
||||
dev.taskid = taskid;
|
||||
fetchIntelAmtInformation(dev);
|
||||
} else {
|
||||
// Device is not valid anymore, do nothing
|
||||
obj.parent.taskLimiter.completed(taskid);
|
||||
}
|
||||
}, dev, 2);
|
||||
}
|
||||
|
||||
// Stop Intel AMT management
|
||||
@ -355,6 +369,10 @@ module.exports.CreateAmtManager = function(parent) {
|
||||
// See if we need to get hardware inventory
|
||||
attemptFetchHardwareInventory(dev, function () {
|
||||
dev.consoleMsg('Done.');
|
||||
|
||||
// Remove from task limiter if needed
|
||||
if (dev.taskid != null) { obj.parent.taskLimiter.completed(dev.taskid); delete dev.taskLimiter; }
|
||||
|
||||
if (dev.connType != 2) {
|
||||
// Start power polling if not connected to LMS
|
||||
var ppfunc = function powerPoleFunction() { fetchPowerState(powerPoleFunction.dev); }
|
||||
|
Loading…
Reference in New Issue
Block a user