@@ -9,8 +9,8 @@ const configuration = require('../lib/settings')();
99
1010program
1111 . arguments ( '[name]' )
12- . option ( '-f, --nofollow' , 'Do not follow stream ' )
13- . option ( '-a, --all' , 'Show online and offline deployments.' )
12+ . option ( '-f, --nofollow' , 'Disable live updates. ' )
13+ . option ( '-a, --all' , 'Show all deployments.' )
1414 . action ( name => metricsLive ( {
1515 name : name ,
1616 all : program . all ,
@@ -30,13 +30,13 @@ function metrics({name, all}){
3030 . then ( response => response . json ( ) ) )
3131 . then ( data => Boolean ( data . message ) ? Promise . reject ( new Error ( data . message ) ) : data )
3232 . then ( data => {
33- console . log ( chalk . green ( `Summary - ${ pad ( 16 , `Requests: ${ methodCounts ( data . methods ) } ` , ' ' ) } ${ pad ( 20 , `Incoming: ${ ( data . inBytes / ( 1024 * 1024 ) ) . toFixed ( 2 ) || 0 } MB` , ' ' ) } ${ pad ( 20 , `Outgoing: ${ ( data . outBytes / ( 1024 * 1024 ) ) . toFixed ( 2 ) || 0 } MB` , ' ' ) } \n` ) ) ;
33+ console . log ( chalk . green ( `Summary - ${ pad ( 16 , `Requests: ${ methodCounts ( data . methods ) } ` , ' ' ) } ${ pad ( 20 , `Incoming: ${ ( data . inBytes / ( 1024 * 1024 ) ) . toFixed ( 2 ) || 0 } MB` , ' ' ) } ${ pad ( 20 , `Outgoing: ${ ( data . outBytes / ( 1024 * 1024 ) ) . toFixed ( 2 ) || 0 } MB` , ' ' ) } \n` ) ) ;
3434
3535 Object . keys ( data . services )
3636 . map ( x => data . services [ x ] )
3737 . filter ( x => name ? x . name === name : true )
38- . filter ( x => ! all ? x . active : true )
39- . forEach ( x => console . log ( chalk . gray ( `${ x . active ? chalk . green ( 'online ' ) : chalk . red ( 'offline ' ) } - ${ x . active ? chalk . green ( x . name ) : chalk . gray ( x . name ) } - ${ pad ( 16 , `Requests: ${ methodCounts ( x . methods ) } ` , ' ' ) } ${ pad ( 20 , `Incoming: ${ ( x . inBytes / ( 1024 * 1024 ) ) . toFixed ( 2 ) || 0 } MB` , ' ' ) } ${ pad ( 20 , `Outgoing: ${ ( x . outBytes / ( 1024 * 1024 ) ) . toFixed ( 2 ) || 0 } MB` , ' ' ) } ` ) ) ) ;
38+ . filter ( x => ! all & ! name ? x . active : true )
39+ . forEach ( x => console . log ( chalk . gray ( `${ x . active ? chalk . green ( 'active ' ) : chalk . red ( 'inactive ' ) } - ${ x . active ? chalk . green ( x . name ) : chalk . gray ( x . name ) } - ${ pad ( 16 , `Requests: ${ methodCounts ( x . methods ) } ` , ' ' ) } ${ pad ( 20 , `Incoming: ${ ( x . inBytes / ( 1024 * 1024 ) ) . toFixed ( 2 ) || 0 } MB` , ' ' ) } ${ pad ( 20 , `Outgoing: ${ ( x . outBytes / ( 1024 * 1024 ) ) . toFixed ( 2 ) || 0 } MB` , ' ' ) } ` ) ) ) ;
4040 } )
4141 . catch ( err => {
4242 process . stderr . write ( '\x1B[?25h' ) ; //show terminal cursor
@@ -88,19 +88,20 @@ function metricsLive({name, all, nofollow}){
8888
8989 process . stdout . cursorTo ( 0 ) ;
9090 process . stdout . clearLine ( ) ;
91- console . log ( chalk . green ( `Summary - ${ pad ( 16 , `Requests: ${ methodCounts ( data . methods ) } ` , ' ' ) } ${ pad ( 20 , `Incoming: ${ ( data . inBytes / ( 1024 * 1024 ) ) . toFixed ( 2 ) || 0 } MB` , ' ' ) } ${ pad ( 20 , `Outgoing: ${ ( data . outBytes / ( 1024 * 1024 ) ) . toFixed ( 2 ) || 0 } MB` , ' ' ) } \n` ) ) ;
91+ console . log ( chalk . green ( `Summary - ${ pad ( 16 , `Requests: ${ methodCounts ( data . methods ) } ` , ' ' ) } ${ pad ( 20 , `Incoming: ${ ( data . inBytes / ( 1024 * 1024 ) ) . toFixed ( 2 ) || 0 } MB` , ' ' ) } ${ pad ( 20 , `Outgoing: ${ ( data . outBytes / ( 1024 * 1024 ) ) . toFixed ( 2 ) || 0 } MB` , ' ' ) } \n` ) ) ;
9292
9393 const services = Object . keys ( data . services ) . map ( x => data . services [ x ] )
9494 . filter ( x => name ? x . name === name : true )
95- . filter ( x => ! all ? x . active : true ) ;
95+ . filter ( x => ! all & ! name ? x . active : true ) ;
9696
9797 services
9898 . forEach ( x => {
9999 process . stdout . cursorTo ( 0 ) ;
100100 process . stdout . clearLine ( ) ;
101- console . log ( chalk . gray ( `${ x . active ? chalk . green ( 'online ' ) : chalk . red ( 'offline ' ) } - ${ x . active ? chalk . green ( x . name ) : chalk . gray ( x . name ) } - ${ pad ( 16 , `Requests: ${ methodCounts ( x . methods ) } ` , ' ' ) } ${ pad ( 20 , `Incoming: ${ ( x . inBytes / ( 1024 * 1024 ) ) . toFixed ( 2 ) || 0 } MB` , ' ' ) } ${ pad ( 20 , `Outgoing: ${ ( x . outBytes / ( 1024 * 1024 ) ) . toFixed ( 2 ) || 0 } MB` , ' ' ) } ` ) ) ;
101+ console . log ( chalk . gray ( `${ x . active ? chalk . green ( 'active ' ) : chalk . red ( 'inactive ' ) } - ${ x . active ? chalk . green ( x . name ) : chalk . gray ( x . name ) } - ${ pad ( 16 , `Requests: ${ methodCounts ( x . methods ) } ` , ' ' ) } ${ pad ( 20 , `Incoming: ${ ( x . inBytes / ( 1024 * 1024 ) ) . toFixed ( 2 ) || 0 } MB` , ' ' ) } ${ pad ( 20 , `Outgoing: ${ ( x . outBytes / ( 1024 * 1024 ) ) . toFixed ( 2 ) || 0 } MB` , ' ' ) } ` ) ) ;
102102 } ) ;
103- process . stdout . moveCursor ( 0 , ( services . length + 2 ) * - 1 ) ;
103+
104+ process . stdout . moveCursor ( 0 , ( services . length + 2 ) * - 1 ) ;
104105 } ;
105106
106107 es . onerror = ( ) => {
0 commit comments