diff options
author | Lauri Ojansivu <x@xet7.org> | 2019-08-13 00:32:46 +0300 |
---|---|---|
committer | Lauri Ojansivu <x@xet7.org> | 2019-08-13 00:32:46 +0300 |
commit | 20294d833a2bf0bd1720444f4ffe018b025dacca (patch) | |
tree | e2ddd292e09cd14de344562cd7f63937d599388c /server/statistics.js | |
parent | ad09cdb1d135e8a5831d7526a0aeb93d7c2a749e (diff) | |
download | wekan-20294d833a2bf0bd1720444f4ffe018b025dacca.tar.gz wekan-20294d833a2bf0bd1720444f4ffe018b025dacca.tar.bz2 wekan-20294d833a2bf0bd1720444f4ffe018b025dacca.zip |
Add to Admin Panel / Version: Meteor version, MongoDB version, MongoDB storage engine,
MongoDB Oplog enabled.
Thanks to RocketChat developers for MongoDB detection code and xet7 for other code.
Diffstat (limited to 'server/statistics.js')
-rw-r--r-- | server/statistics.js | 48 |
1 files changed, 45 insertions, 3 deletions
diff --git a/server/statistics.js b/server/statistics.js index 1fbaecc9..288a5089 100644 --- a/server/statistics.js +++ b/server/statistics.js @@ -1,9 +1,13 @@ +import { MongoInternals } from 'meteor/mongo'; + Meteor.methods({ getStatistics() { const os = require('os'); const pjson = require('/package.json'); const statistics = {}; - statistics.version = pjson.version; + let wekanVersion = pjson.version; + wekanVersion = wekanVersion.replace('v', ''); + statistics.version = wekanVersion; statistics.os = { type: os.type(), platform: os.platform(), @@ -15,12 +19,50 @@ Meteor.methods({ freemem: os.freemem(), cpus: os.cpus(), }; + let nodeVersion = process.version; + nodeVersion = nodeVersion.replace('v', ''); statistics.process = { - nodeVersion: process.version, + nodeVersion: nodeVersion, pid: process.pid, uptime: process.uptime(), }; - + // Remove beginning of Meteor release text METEOR@ + let meteorVersion = Meteor.release; + meteorVersion = meteorVersion.replace('METEOR@', ''); + statistics.meteor = { + meteorVersion: meteorVersion, + }; + // Thanks to RocketChat for MongoDB version detection ! + // https://github.com/RocketChat/Rocket.Chat/blob/develop/app/utils/server/functions/getMongoInfo.js + let mongoVersion; + let mongoStorageEngine; + let mongoOplogEnabled; + try { + const { mongo } = MongoInternals.defaultRemoteCollectionDriver(); + oplogEnabled = Boolean( + mongo._oplogHandle && mongo._oplogHandle.onOplogEntry, + ); + const { version, storageEngine } = Promise.await( + mongo.db.command({ serverStatus: 1 }), + ); + mongoVersion = version; + mongoStorageEngine = storageEngine.name; + mongoOplogEnabled = oplogEnabled; + } catch (e) { + try { + const { version } = Promise.await(mongo.db.command({ buildinfo: 1 })); + mongoVersion = version; + mongoStorageEngine = 'unknown'; + } catch (e) { + mongoVersion = 'unknown'; + mongoStorageEngine = 'unknown'; + } + } + statistics.mongo = { + mongoVersion: mongoVersion, + mongoStorageEngine: mongoStorageEngine, + mongoOplogEnabled: mongoOplogEnabled, + }; return statistics; }, }); |