File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -42,17 +42,21 @@ const Helpers = {
4242 const usedMemoryPrefix = 'used_memory:' ;
4343 const lines = doc . split ( / \r ? \n / ) ;
4444
45- for ( let i = 0 ; i < lines . length ; i ++ ) {
46- if ( lines [ i ] . indexOf ( totalSystemMemoryPrefix ) === 0 ) {
47- stats . total_system_memory = formatBytes (
48- parseInt ( lines [ i ] . substr ( totalSystemMemoryPrefix . length ) , 10 )
49- ) ;
50- }
51-
52- if ( lines [ i ] . indexOf ( usedMemoryPrefix ) === 0 ) {
53- stats . used_memory = formatBytes (
54- parseInt ( lines [ i ] . substr ( usedMemoryPrefix . length ) , 10 )
55- ) ;
45+ for ( const line of lines ) {
46+ for ( const metric of Helpers . _usefulMetrics ) {
47+ const metricPrefix = metric + ':' ;
48+ if ( line . indexOf ( metricPrefix ) === 0 ) {
49+ if (
50+ metricPrefix === totalSystemMemoryPrefix ||
51+ metricPrefix === usedMemoryPrefix
52+ ) {
53+ stats [ metric ] = formatBytes (
54+ parseInt ( line . substr ( metricPrefix . length ) , 10 )
55+ ) ;
56+ } else {
57+ stats [ metric ] = line . substr ( metricPrefix . length ) ;
58+ }
59+ }
5660 }
5761 }
5862 }
You can’t perform that action at this time.
0 commit comments