File tree 2 files changed +37
-1
lines changed
2 files changed +37
-1
lines changed Original file line number Diff line number Diff line change @@ -5,7 +5,7 @@ function get(req, res) {
5
5
exit : function ( code , stdout , stderr ) {
6
6
if ( stderr ) {
7
7
return res . send ( {
8
- status : 'Error ' ,
8
+ status : 'error ' ,
9
9
message : stderr
10
10
} ) ;
11
11
}
Original file line number Diff line number Diff line change 1
1
var ssh = require ( '../utils/ssh' ) ;
2
2
3
3
function get ( req , res ) {
4
+ ssh . create ( ) . exec ( 'ps ' + req . query . app , {
5
+ exit : function ( code , stdout , stderr ) {
6
+ var lines = stdout . split ( '\n' ) ;
4
7
8
+ // Parse container id
9
+ var containerTokens = lines [ 0 ] . split ( ' ' ) ;
10
+ var containerId = containerTokens [ containerTokens . length - 1 ] ;
11
+
12
+ // Isolated the lines that have process info
13
+ lines = lines . slice ( 2 , lines . length - 1 ) ;
14
+ var processes = [ ] ;
15
+ for ( var i = 0 ; i < lines . length ; i ++ ) {
16
+ processes . push ( parseProcess ( lines [ i ] ) ) ;
17
+ }
18
+ res . send ( {
19
+ containerId : containerId ,
20
+ processes : processes
21
+ } ) ;
22
+ }
23
+ } ) . start ( ) ;
24
+ }
25
+
26
+ function parseProcess ( line ) {
27
+ var tokens = line . split ( / \s + / ) ;
28
+ return {
29
+ user : tokens [ 0 ] ,
30
+ pid : tokens [ 1 ] ,
31
+ cpu : tokens [ 2 ] ,
32
+ mem : tokens [ 3 ] ,
33
+ vsz : tokens [ 4 ] ,
34
+ rss : tokens [ 5 ] ,
35
+ tty : tokens [ 6 ] ,
36
+ stat : tokens [ 7 ] ,
37
+ start : tokens [ 8 ] ,
38
+ time : tokens [ 9 ] ,
39
+ command : tokens . splice ( 10 ) . join ( ' ' )
40
+ }
5
41
}
6
42
7
43
function rebuildall ( req , res ) {
You can’t perform that action at this time.
0 commit comments