Attachment size, changed calculation to npm filesize (Version Info)

This commit is contained in:
Martin Filser 2022-04-29 12:02:51 +02:00
parent 464bc2f87b
commit 20c2679dc8
2 changed files with 18 additions and 21 deletions

View file

@ -58,38 +58,38 @@ template(name='statistics')
td {{numFormat statistics.os.loadavg.[0]}}, {{numFormat statistics.os.loadavg.[1]}}, {{numFormat statistics.os.loadavg.[2]}} td {{numFormat statistics.os.loadavg.[0]}}, {{numFormat statistics.os.loadavg.[1]}}, {{numFormat statistics.os.loadavg.[2]}}
tr tr
th {{_ 'OS_Totalmem'}} th {{_ 'OS_Totalmem'}}
td {{bytesToSize statistics.os.totalmem}} td {{fileSize statistics.os.totalmem}}
tr tr
th {{_ 'OS_Freemem'}} th {{_ 'OS_Freemem'}}
td {{bytesToSize statistics.os.freemem}} td {{fileSize statistics.os.freemem}}
tr tr
th {{_ 'OS_Cpus'}} th {{_ 'OS_Cpus'}}
td {{statistics.os.cpus.length}} td {{statistics.os.cpus.length}}
unless isSandstorm unless isSandstorm
tr tr
th {{_ 'Node_heap_total_heap_size'}} th {{_ 'Node_heap_total_heap_size'}}
td {{bytesToSize statistics.nodeHeapStats.totalHeapSize}} td {{fileSize statistics.nodeHeapStats.totalHeapSize}}
tr tr
th {{_ 'Node_heap_total_heap_size_executable'}} th {{_ 'Node_heap_total_heap_size_executable'}}
td {{bytesToSize statistics.nodeHeapStats.totalHeapSizeExecutable}} td {{fileSize statistics.nodeHeapStats.totalHeapSizeExecutable}}
tr tr
th {{_ 'Node_heap_total_physical_size'}} th {{_ 'Node_heap_total_physical_size'}}
td {{bytesToSize statistics.nodeHeapStats.totalPhysicalSize}} td {{fileSize statistics.nodeHeapStats.totalPhysicalSize}}
tr tr
th {{_ 'Node_heap_total_available_size'}} th {{_ 'Node_heap_total_available_size'}}
td {{bytesToSize statistics.nodeHeapStats.totalAvailableSize}} td {{fileSize statistics.nodeHeapStats.totalAvailableSize}}
tr tr
th {{_ 'Node_heap_used_heap_size'}} th {{_ 'Node_heap_used_heap_size'}}
td {{bytesToSize statistics.nodeHeapStats.usedHeapSize}} td {{fileSize statistics.nodeHeapStats.usedHeapSize}}
tr tr
th {{_ 'Node_heap_heap_size_limit'}} th {{_ 'Node_heap_heap_size_limit'}}
td {{bytesToSize statistics.nodeHeapStats.heapSizeLimit}} td {{fileSize statistics.nodeHeapStats.heapSizeLimit}}
tr tr
th {{_ 'Node_heap_malloced_memory'}} th {{_ 'Node_heap_malloced_memory'}}
td {{bytesToSize statistics.nodeHeapStats.mallocedMemory}} td {{fileSize statistics.nodeHeapStats.mallocedMemory}}
tr tr
th {{_ 'Node_heap_peak_malloced_memory'}} th {{_ 'Node_heap_peak_malloced_memory'}}
td {{bytesToSize statistics.nodeHeapStats.peakMallocedMemory}} td {{fileSize statistics.nodeHeapStats.peakMallocedMemory}}
tr tr
th {{_ 'Node_heap_does_zap_garbage'}} th {{_ 'Node_heap_does_zap_garbage'}}
td {{statistics.nodeHeapStats.doesZapGarbage}} td {{statistics.nodeHeapStats.doesZapGarbage}}
@ -101,13 +101,13 @@ template(name='statistics')
td {{statistics.nodeHeapStats.numberOfDetachedContexts}} td {{statistics.nodeHeapStats.numberOfDetachedContexts}}
tr tr
th {{_ 'Node_memory_usage_rss'}} th {{_ 'Node_memory_usage_rss'}}
td {{bytesToSize statistics.nodeMemoryUsage.rss}} td {{fileSize statistics.nodeMemoryUsage.rss}}
tr tr
th {{_ 'Node_memory_usage_heap_total'}} th {{_ 'Node_memory_usage_heap_total'}}
td {{bytesToSize statistics.nodeMemoryUsage.heapTotal}} td {{fileSize statistics.nodeMemoryUsage.heapTotal}}
tr tr
th {{_ 'Node_memory_usage_heap_used'}} th {{_ 'Node_memory_usage_heap_used'}}
td {{bytesToSize statistics.nodeMemoryUsage.heapUsed}} td {{fileSize statistics.nodeMemoryUsage.heapUsed}}
tr tr
th {{_ 'Node_memory_usage_external'}} th {{_ 'Node_memory_usage_external'}}
td {{bytesToSize statistics.nodeMemoryUsage.external}} td {{fileSize statistics.nodeMemoryUsage.external}}

View file

@ -1,4 +1,5 @@
import { TAPi18n } from '/imports/i18n'; import { TAPi18n } from '/imports/i18n';
const filesize = require('filesize');
BlazeComponent.extendComponent({ BlazeComponent.extendComponent({
onCreated() { onCreated() {
@ -39,12 +40,8 @@ BlazeComponent.extendComponent({
return parseFloat(number).toFixed(2); return parseFloat(number).toFixed(2);
}, },
bytesToSize(bytes) { fileSize(size) {
const sizes = ['Bytes', 'KB', 'MB', 'GB', 'TB']; const ret = filesize(size);
if (bytes === 0) { return ret;
return '0 Byte';
}
const i = parseInt(Math.floor(Math.log(bytes) / Math.log(1024)), 10);
return `${Math.round(bytes / Math.pow(1024, i), 2)} ${sizes[i]}`;
}, },
}).register('statistics'); }).register('statistics');