mirror of
https://github.com/Ylianst/MeshCentral.git
synced 2025-03-09 15:40:18 +00:00
Split SMBIOS information into seperate collection.
This commit is contained in:
parent
0865403772
commit
5d1423cbaf
36 changed files with 41 additions and 11 deletions
14
db.js
14
db.js
|
@ -113,6 +113,8 @@ module.exports.CreateDB = function (parent) {
|
|||
}
|
||||
});
|
||||
|
||||
// Setup MongoDB smbios collection, no indexes needed
|
||||
obj.smbiosfile = db.collection('smbios'); // Collection containing all smbios information
|
||||
} else {
|
||||
// Use NeDB (The default)
|
||||
obj.databaseType = 1;
|
||||
|
@ -162,6 +164,9 @@ module.exports.CreateDB = function (parent) {
|
|||
obj.powerfile.persistence.setAutocompactionInterval(36000);
|
||||
obj.powerfile.ensureIndex({ fieldName: 'nodeid' });
|
||||
obj.powerfile.ensureIndex({ fieldName: 'time', expireAfterSeconds: 60 * 60 * 24 * 10 }); // Limit the power event log to 10 days (Seconds * Minutes * Hours * Days)
|
||||
|
||||
// Setup the SMBIOS collection
|
||||
obj.smbiosfile = new Datastore({ filename: obj.parent.getConfigFilePath('meshcentral-smbios.db'), autoload: true });
|
||||
}
|
||||
|
||||
obj.SetupDatabase = function (func) {
|
||||
|
@ -193,10 +198,10 @@ module.exports.CreateDB = function (parent) {
|
|||
// TODO: Remove all mesh links to invalid users
|
||||
// TODO: Remove all meshes that dont have any links
|
||||
|
||||
// Remote all the events and power events from the main collection.
|
||||
// They are all in two seperate collections now.
|
||||
// Remove all events, power events and SMBIOS data from the main collection. They are all in seperate collections now.
|
||||
obj.file.remove({ type: 'event' }, { multi: true });
|
||||
obj.file.remove({ type: 'power' }, { multi: true });
|
||||
obj.file.remove({ type: 'smbios' }, { multi: true });
|
||||
|
||||
// Remove all objects that have a "meshid" that no longer points to a valid mesh.
|
||||
obj.GetAllType('mesh', function (err, docs) {
|
||||
|
@ -294,6 +299,11 @@ module.exports.CreateDB = function (parent) {
|
|||
obj.getPowerTimeline = function (nodeid, func) { if (obj.databaseType == 1) { obj.powerfile.find({ nodeid: { $in: ['*', nodeid] } }, { _id: 0, nodeid: 0, s: 0 }).sort({ time: 1 }).exec(func); } else { obj.powerfile.find({ nodeid: { $in: ['*', nodeid] } }, { _id: 0, nodeid: 0, s: 0 }).sort({ time: 1 }, func); } };
|
||||
obj.removeAllPowerEvents = function (domain) { obj.powerfile.remove({ }, { multi: true }); };
|
||||
|
||||
// Database actions on the SMBIOS collection
|
||||
obj.SetSMBIOS = function (smbios, func) { obj.smbiosfile.update({ _id: smbios._id }, smbios, { upsert: true }, func); };
|
||||
obj.RemoveSMBIOS = function (id) { obj.smbiosfile.remove({ _id: id }); };
|
||||
obj.GetSMBIOS = function (id, func) { obj.smbiosfile.find({ _id: id }, func); };
|
||||
|
||||
// Read a configuration file from the database
|
||||
obj.getConfigFile = function (path, func) { obj.Get('cfile/' + path, func); }
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue