@ -1,5 +1,10 @@
import { MongoInternals } from 'meteor/mongo' ;
// Sandstorm context is detected using the METEOR_SETTINGS environment variable
// in the package definition.
const isSandstorm =
Meteor . settings && Meteor . settings . public && Meteor . settings . public . sandstorm ;
if ( Meteor . isServer ) {
Meteor . methods ( {
getStatistics ( ) {
@ -28,27 +33,35 @@ if (Meteor.isServer) {
pid : process . pid ,
uptime : process . uptime ( ) ,
} ;
const v8 = require ( 'v8' ) ; // Import the v8 module
statistics . nodeHeapStats = {
totalHeapSize : v8 . getHeapStatistics ( ) . total _heap _size ,
totalHeapSizeExecutable : v8 . getHeapStatistics ( ) . total _heap _size _executable ,
totalPhysicalSize : v8 . getHeapStatistics ( ) . total _physical _size ,
totalAvailableSize : v8 . getHeapStatistics ( ) . total _available _size ,
usedHeapSize : v8 . getHeapStatistics ( ) . used _heap _size ,
heapSizeLimit : v8 . getHeapStatistics ( ) . heap _size _limit ,
mallocedMemory : v8 . getHeapStatistics ( ) . malloced _memory ,
peakMallocedMemory : v8 . getHeapStatistics ( ) . peak _malloced _memory ,
doesZapGarbage : v8 . getHeapStatistics ( ) . does _zap _garbage ,
numberOfNativeContexts : v8 . getHeapStatistics ( ) . number _of _native _contexts ,
numberOfDetachedContexts : v8 . getHeapStatistics ( ) . number _of _detached _contexts ,
} ;
let memoryUsage = process . memoryUsage ( ) ;
statistics . nodeMemoryUsage = {
rss : memoryUsage . rss ,
heapTotal : memoryUsage . heapTotal ,
heapUsed : memoryUsage . heapUsed ,
external : memoryUsage . external ,
} ;
// Start: Show Nodejs heap stats at Standalone WeKan.
//
// Not shown at Sandstorm WeKan, because there's a bunch of machine performance data
// Sandstorm doesn't expose to apps to prevent side channel attacks.
if ( ! isSandstorm ) {
const v8 = require ( 'v8' ) ; // Import the v8 module
statistics . nodeHeapStats = {
totalHeapSize : v8 . getHeapStatistics ( ) . total _heap _size ,
totalHeapSizeExecutable : v8 . getHeapStatistics ( ) . total _heap _size _executable ,
totalPhysicalSize : v8 . getHeapStatistics ( ) . total _physical _size ,
totalAvailableSize : v8 . getHeapStatistics ( ) . total _available _size ,
usedHeapSize : v8 . getHeapStatistics ( ) . used _heap _size ,
heapSizeLimit : v8 . getHeapStatistics ( ) . heap _size _limit ,
mallocedMemory : v8 . getHeapStatistics ( ) . malloced _memory ,
peakMallocedMemory : v8 . getHeapStatistics ( ) . peak _malloced _memory ,
doesZapGarbage : v8 . getHeapStatistics ( ) . does _zap _garbage ,
numberOfNativeContexts : v8 . getHeapStatistics ( ) . number _of _native _contexts ,
numberOfDetachedContexts : v8 . getHeapStatistics ( ) . number _of _detached _contexts ,
} ;
let memoryUsage = process . memoryUsage ( ) ;
statistics . nodeMemoryUsage = {
rss : memoryUsage . rss ,
heapTotal : memoryUsage . heapTotal ,
heapUsed : memoryUsage . heapUsed ,
external : memoryUsage . external ,
} ;
}
// End: Show Nodejs heap stats at Standalone WeKan.
//
// Remove beginning of Meteor release text METEOR@
let meteorVersion = Meteor . release ;
meteorVersion = meteorVersion . replace ( 'METEOR@' , '' ) ;