监控安全容器

描述

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

用法

  1. kata-runtime events [command options] <container-id>

参数

  • -- interval value:设置查询周期。如果不使用该参数,默认查询周期为5秒。
  • --stats: 显示容器信息并退出查询。

前置条件

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

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

示例

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

    1. $ kata-runtime events --interval 3s 5779b2366f47
    2. {
    3. "data": {
    4. "blkio": {},
    5. "cpu": {
    6. "throttling": {},
    7. "usage": {
    8. "kernel": 130000000,
    9. "percpu": [
    10. 214098440
    11. ],
    12. "total": 214098440,
    13. "user": 10000000
    14. }
    15. },
    16. "hugetlb": {},
    17. "intel_rdt": {},
    18. "interfaces": [
    19. {
    20. "name": "lo",
    21. "rx_bytes": 0,
    22. "rx_dropped": 0,
    23. "rx_errors": 0,
    24. "rx_packets": 0,
    25. "tx_bytes": 0,
    26. "tx_dropped": 0,
    27. "tx_errors": 0,
    28. "tx_packets": 0
    29. }
    30. ],
    31. "memory": {
    32. "cache": 827392,
    33. "kernel": {
    34. "failcnt": 0,
    35. "limit": 9223372036854771712,
    36. "max": 421888,
    37. "usage": 221184
    38. },
    39. "kernelTCP": {
    40. "failcnt": 0,
    41. "limit": 0
    42. },
    43. "raw": {
    44. "active_anon": 49152,
    45. "active_file": 40960,
    46. "cache": 827392,
    47. "dirty": 0,
    48. "hierarchical_memory_limit": 9223372036854771712,
    49. "hierarchical_memsw_limit": 9223372036854771712,
    50. "inactive_anon": 0,
    51. "inactive_file": 839680,
    52. "mapped_file": 540672,
    53. "pgfault": 6765,
    54. "pgmajfault": 0,
    55. "pgpgin": 12012,
    56. "pgpgout": 11803,
    57. "rss": 4096,
    58. "rss_huge": 0,
    59. "shmem": 32768,
    60. "swap": 0,
    61. "total_active_anon": 49152,
    62. "total_active_file": 40960,
    63. "total_cache": 827392,
    64. "total_dirty": 0,
    65. "total_inactive_anon": 0,
    66. "total_inactive_file": 839680,
    67. "total_mapped_file": 540672,
    68. "total_pgfault": 6765,
    69. "total_pgmajfault": 0,
    70. "total_pgpgin": 12012,
    71. "total_pgpgout": 11803,
    72. "total_rss": 4096,
    73. "total_rss_huge": 0,
    74. "total_shmem": 32768,
    75. "total_swap": 0,
    76. "total_unevictable": 0,
    77. "total_writeback": 0,
    78. "unevictable": 0,
    79. "writeback": 0
    80. },
    81. "swap": {
    82. "failcnt": 0,
    83. "limit": 9223372036854771712,
    84. "max": 34201600,
    85. "usage": 1204224
    86. },
    87. "usage": {
    88. "failcnt": 0,
    89. "limit": 9223372036854771712,
    90. "max": 34201600,
    91. "usage": 1204224
    92. }
    93. },
    94. "pids": {
    95. "current": 1
    96. },
    97. "tcp": {},
    98. "tcp6": {},
    99. "udp": {},
    100. "udp6": {}
    101. },
    102. "id": "5779b2366f47cd1468ebb1ba7c52cbdde3c7d3a5f2af3eefadc8356700fc860b",
    103. "type": "stats"
    104. }
  • 显示容器状态并立即返回

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

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