Procházet zdrojové kódy

Add NodeJS statistics - part 1 - heap statistics

Ben0it-T před 3 roky
rodič
revize
790a82c4b1

+ 33 - 0
client/components/settings/informationBody.jade

@@ -65,3 +65,36 @@ template(name='statistics')
         tr
           th {{_ 'OS_Cpus'}}
           td {{statistics.os.cpus.length}}
+        tr
+          th {{_ 'Node_heap_total_heap_size'}}
+          td {{bytesToSize statistics.nodeHeapStats.totalHeapSize}}
+        tr
+          th {{_ 'Node_heap_total_heap_size_executable'}}
+          td {{bytesToSize statistics.nodeHeapStats.totalHeapSizeExecutable}}
+        tr
+          th {{_ 'Node_heap_total_physical_size'}}
+          td {{bytesToSize statistics.nodeHeapStats.totalPhysicalSize}}
+        tr
+          th {{_ 'Node_heap_total_available_size'}}
+          td {{bytesToSize statistics.nodeHeapStats.totalAvailableSize}}
+        tr
+          th {{_ 'Node_heap_used_heap_size'}}
+          td {{bytesToSize statistics.nodeHeapStats.usedHeapSize}}
+        tr
+          th {{_ 'Node_heap_heap_size_limit'}}
+          td {{bytesToSize statistics.nodeHeapStats.heapSizeLimit}}
+        tr
+          th {{_ 'Node_heap_malloced_memory'}}
+          td {{bytesToSize statistics.nodeHeapStats.mallocedMemory}}
+        tr
+          th {{_ 'Node_heap_peak_malloced_memory'}}
+          td {{bytesToSize statistics.nodeHeapStats.peakMallocedMemory}}
+        tr
+          th {{_ 'Node_heap_does_zap_garbage'}}
+          td {{statistics.nodeHeapStats.doesZapGarbage}}
+        tr
+          th {{_ 'Node_heap_number_of_native_contexts'}}
+          td {{statistics.nodeHeapStats.numberOfNativeContexts}}
+        tr
+          th {{_ 'Node_heap_number_of_detached_contexts'}}
+          td {{statistics.nodeHeapStats.numberOfDetachedContexts}}

+ 12 - 1
i18n/en.i18n.json

@@ -1098,5 +1098,16 @@
   "filter-card-title-label": "Filter by card title",
   "invite-people-success": "Invitation to register sent with success",
   "invite-people-error": "Error while sending invitation to register",
-  "can-invite-if-same-mailDomainName": "Email domain name"
+  "can-invite-if-same-mailDomainName": "Email domain name",
+  "Node_heap_total_heap_size": "Node heap : total heap size",
+  "Node_heap_total_heap_size_executable": "Node heap : total heap size executable",
+  "Node_heap_total_physical_size": "Node heap : total physical size",
+  "Node_heap_total_available_size": "Node heap : total available size",
+  "Node_heap_used_heap_size": "Node heap : used heap size",
+  "Node_heap_heap_size_limit": "Node heap : heap size limit",
+  "Node_heap_malloced_memory": "Node heap : malloced memory",
+  "Node_heap_peak_malloced_memory": "Node heap : peak malloced memory",
+  "Node_heap_does_zap_garbage": "Node heap : does zap garbage",
+  "Node_heap_number_of_native_contexts": "Node heap : number of native contexts",
+  "Node_heap_number_of_detached_contexts": "Node heap : number of detached contexts"
 }

+ 14 - 0
server/statistics.js

@@ -28,6 +28,20 @@ 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,
+        };
         // Remove beginning of Meteor release text METEOR@
         let meteorVersion = Meteor.release;
         meteorVersion = meteorVersion.replace('METEOR@', '');