监控安全容器

描述

kata events命令用于显示指定容器状态。包括但不限于容器内存、CPU、Pid、 Blkio、大页内存、网络等信息。

用法

  1. kata-runtime metrics <sandbox id>

前置条件

要查询的容器状态必须为running,否则报错:Container ID () does not exist。

该命令只支持查询监控一个容器的状态

示例

  • 每隔三秒显示容器状态。

    1. $ kata-runtime metrics b1ea31830b57d08e1782e2bdb19cf9162908445cc283d371aa1e4923a91e0d0b
    2. # HELP go_gc_duration_seconds A summary of the pause duration of garbage collection cycles.
    3. # TYPE go_gc_duration_seconds summary
    4. go_gc_duration_seconds{quantile="0"} 2.717e-05
    5. go_gc_duration_seconds{quantile="0.25"} 3.7e-05
    6. go_gc_duration_seconds{quantile="0.5"} 4.043e-05
    7. go_gc_duration_seconds{quantile="0.75"} 4.633e-05
    8. go_gc_duration_seconds{quantile="1"} 0.00019117
    9. go_gc_duration_seconds_sum 0.00229451
    10. go_gc_duration_seconds_count 51
    11. # HELP go_goroutines Number of goroutines that currently exist.
    12. # TYPE go_goroutines gauge
    13. go_goroutines 29
    14. # HELP go_info Information about the Go environment.
    15. # TYPE go_info gauge
    16. go_info{version="go1.15.7"} 1
    17. # HELP go_memstats_alloc_bytes Number of bytes allocated and still in use.
    18. # TYPE go_memstats_alloc_bytes gauge
    19. go_memstats_alloc_bytes 2.487136e+06
    20. # HELP go_memstats_heap_idle_bytes Number of heap bytes waiting to be used.
    21. # TYPE go_memstats_heap_idle_bytes gauge
    22. go_memstats_heap_idle_bytes 6.2185472e+07
    23. # HELP go_memstats_heap_inuse_bytes Number of heap bytes that are in use.
    24. # TYPE go_memstats_heap_inuse_bytes gauge
    25. go_memstats_heap_inuse_bytes 4.333568e+06
    26. ...
    27. kata_guest_diskstat{disk="ram5",item="writes_merged"} 0
    28. kata_guest_diskstat{disk="ram6",item="discards"} 0
    29. kata_guest_diskstat{disk="ram6",item="discards_merged"} 0
    30. kata_guest_diskstat{disk="ram6",item="flushes"} 0
    31. kata_guest_diskstat{disk="ram6",item="in_progress"} 0
    32. kata_guest_diskstat{disk="ram6",item="merged"} 0
    33. kata_guest_diskstat{disk="ram6",item="reads"} 0
    34. kata_guest_diskstat{disk="ram6",item="sectors_discarded"} 0
    35. kata_guest_diskstat{disk="ram6",item="sectors_read"} 0
    36. kata_guest_diskstat{disk="ram6",item="sectors_written"} 0
    37. kata_guest_diskstat{disk="ram6",item="time_discarding"} 0
    38. kata_guest_diskstat{disk="ram6",item="time_flushing"} 0
    39. kata_guest_diskstat{disk="ram6",item="time_in_progress"} 0
    40. kata_guest_diskstat{disk="ram6",item="time_reading"} 0
    41. kata_guest_diskstat{disk="ram6",item="time_writing"} 0
    42. kata_guest_diskstat{disk="ram6",item="weighted_time_in_progress"} 0
    43. kata_guest_diskstat{disk="ram6",item="writes"} 0
    44. ...
    45. kata_shim_proc_status{item="vmlib"} 1.835008e+06
    46. kata_shim_proc_status{item="vmpeak"} 1.49815296e+09
    47. kata_shim_proc_status{item="vmpin"} 0
    48. kata_shim_proc_status{item="vmpmd"} 0
    49. kata_shim_proc_status{item="vmpte"} 655360
    50. kata_shim_proc_status{item="vmrss"} 3.2768e+07
    51. kata_shim_proc_status{item="vmsize"} 1.431044096e+09
    52. kata_shim_proc_status{item="vmstk"} 196608
    53. kata_shim_proc_status{item="vmswap"} 0
    54. kata_shim_proc_status{item="voluntary_ctxt_switches"} 43
    55. # HELP kata_shim_rpc_durations_histogram_milliseconds RPC latency distributions.
    56. # TYPE kata_shim_rpc_durations_histogram_milliseconds histogram
    57. kata_shim_rpc_durations_histogram_milliseconds_bucket{action="create",le="1"} 0
    58. kata_shim_rpc_durations_histogram_milliseconds_bucket{action="create",le="2"} 0
    59. kata_shim_rpc_durations_histogram_milliseconds_bucket{action="create",le="4"} 0
    60. kata_shim_rpc_durations_histogram_milliseconds_bucket{action="create",le="8"} 0
    61. kata_shim_rpc_durations_histogram_milliseconds_bucket{action="create",le="16"} 0
    62. kata_shim_rpc_durations_histogram_milliseconds_bucket{action="create",le="32"} 0
    63. ...
    64. kata_guest_netdev_stat{interface="eth0",item="recv_bytes"} 0
    65. kata_guest_netdev_stat{interface="eth0",item="recv_compressed"} 0
    66. kata_guest_netdev_stat{interface="eth0",item="recv_drop"} 0
    67. kata_guest_netdev_stat{interface="eth0",item="recv_errs"} 0
    68. kata_guest_netdev_stat{interface="eth0",item="recv_fifo"} 0
    69. kata_guest_netdev_stat{interface="eth0",item="recv_frame"} 0
    70. kata_guest_netdev_stat{interface="eth0",item="recv_multicast"} 0
    71. kata_guest_netdev_stat{interface="eth0",item="recv_packets"} 0
    72. kata_guest_netdev_stat{interface="eth0",item="sent_bytes"} 0
    73. kata_guest_netdev_stat{interface="eth0",item="sent_carrier"} 0
    74. kata_guest_netdev_stat{interface="eth0",item="sent_colls"} 0
    75. kata_guest_netdev_stat{interface="eth0",item="sent_compressed"} 0
    76. kata_guest_netdev_stat{interface="eth0",item="sent_drop"} 0
    77. kata_guest_netdev_stat{interface="eth0",item="sent_errs"} 0
    78. kata_guest_netdev_stat{interface="eth0",item="sent_fifo"} 0
    79. kata_guest_netdev_stat{interface="eth0",item="sent_packets"} 0
    80. kata_guest_netdev_stat{interface="eth1",item="recv_bytes"} 0
    81. kata_guest_netdev_stat{interface="eth1",item="recv_compressed"} 0
  • 显示容器状态并立即返回

    1. kata-runtime events --stats <container_id>

    该命令返回内容的格式与上一条相同,区别为只显示一次信息后便退出。