@@ -2691,6 +2691,35 @@ def compose_kill(compose, args):
2691
2691
compose .podman .run ([], "kill" , podman_args )
2692
2692
2693
2693
2694
+ @cmd_run (
2695
+ podman_compose , "stats" , "Display percentage of CPU, memory, network I/O, block I/O and PIDs for services."
2696
+ )
2697
+ def compose_stats (compose , args ):
2698
+ container_names_by_service = compose .container_names_by_service
2699
+ if not args .services :
2700
+ args .services = container_names_by_service .keys ()
2701
+ targets = []
2702
+ podman_args = []
2703
+ if args .interval :
2704
+ podman_args .extend (["--interval" , args .interval ])
2705
+ if args .format :
2706
+ podman_args .extend (["--format" , args .format ])
2707
+ if args .no_reset :
2708
+ podman_args .append ("--no-reset" )
2709
+ if args .no_stream :
2710
+ podman_args .append ("--no-stream" )
2711
+
2712
+ for service in args .services :
2713
+ targets .extend (container_names_by_service [service ])
2714
+ for target in targets :
2715
+ podman_args .append (target )
2716
+
2717
+ try :
2718
+ compose .podman .run ([], "stats" , podman_args )
2719
+ except KeyboardInterrupt :
2720
+ pass
2721
+
2722
+
2694
2723
###################
2695
2724
# command arguments parsing
2696
2725
###################
@@ -3141,6 +3170,35 @@ def compose_kill_parse(parser):
3141
3170
)
3142
3171
3143
3172
3173
+ @cmd_parse (podman_compose , ["stats" ])
3174
+ def compose_stats_parse (parser ):
3175
+ parser .add_argument (
3176
+ "services" , metavar = "services" , nargs = "*" , default = None , help = "service names"
3177
+ )
3178
+ parser .add_argument (
3179
+ "-i" ,
3180
+ "--interval" ,
3181
+ type = int ,
3182
+ help = "Time in seconds between stats reports (default 5)" ,
3183
+ )
3184
+ parser .add_argument (
3185
+ "-f" ,
3186
+ "--format" ,
3187
+ type = str ,
3188
+ help = "Pretty-print container statistics to JSON or using a Go template" ,
3189
+ )
3190
+ parser .add_argument (
3191
+ "--no-reset" ,
3192
+ help = "Disable resetting the screen between intervals" ,
3193
+ action = "store_true" ,
3194
+ )
3195
+ parser .add_argument (
3196
+ "--no-stream" ,
3197
+ help = "Disable streaming stats and only pull the first result" ,
3198
+ action = "store_true" ,
3199
+ )
3200
+
3201
+
3144
3202
def main ():
3145
3203
podman_compose .run ()
3146
3204
0 commit comments