File tree Expand file tree Collapse file tree 1 file changed +17
-0
lines changed
Expand file tree Collapse file tree 1 file changed +17
-0
lines changed Original file line number Diff line number Diff line change @@ -35,6 +35,20 @@ def display_ip(args):
3535 print (detail ['NetworkSettings' ]['IPAddress' ])
3636
3737
38+ def display_memory (args ):
39+ detail = c .inspect_container (args .container )
40+ if bool (detail ["State" ]["Running" ]):
41+ container_id = detail ['Id' ]
42+ with open ('/sys/fs/cgroup/memory/docker/' + container_id + '/memory.stat' , 'r' ) as f :
43+ for line in f :
44+ m = re .search (r"total_rss\s+(\d+)" , line )
45+ if m :
46+ print (m .group (1 ))
47+ return
48+
49+ print (0 )
50+
51+
3852def display_network (args ):
3953 detail = c .inspect_container (args .container )
4054 if bool (detail ["State" ]["Running" ]):
@@ -78,6 +92,9 @@ def display_status(args):
7892ip_parser = subparsers .add_parser ("ip" , help = "Display IP Address" )
7993ip_parser .set_defaults (func = display_ip )
8094
95+ memory_parser = subparsers .add_parser ("memory" , help = "Display memory usage" )
96+ memory_parser .set_defaults (func = display_memory )
97+
8198network_parser = subparsers .add_parser ("network" , help = "Display network usage" )
8299network_parser .add_argument ("direction" , choices = ["in" , "out" ])
83100network_parser .set_defaults (func = display_network )
You can’t perform that action at this time.
0 commit comments