پرش به مطلب اصلی

نمایش اطلاعات منابع کانتینر

این دستور برای زمانی است که بخواهیم منابع کانتینر ها را بررسی و زیر نظر داشته باشیم که این اطلاعات با جزییات بسیار است و شامل حافظه و پردازش ها و I/O خواهد بود که به تفکیک میتوان آن ها را به دست آورد.

🧩 دستور کلی

k3 container usage [options] <containerId>

⚙️ گزینه‌ها (Options)

گزینه کوتاهگزینه بلندتوضیح
-m--memory نمایش اطلاعات مربوط به حافظه
-c--cpuنمایش اطلاعات مربوط به پردازش
-a--allنمایش همه جزییات درباره منابع
-i--ioنمایش اطلاعات مربوط به IO

📥 مثال‌های کاربردی

✅ نمایش منابع کانتینر با شناسه:

k3 container usage cont5

⏱ نمایش منابع کل کانتینر کانتینر با تمام جزییات

k3 container usage --all cont5
--------------------------------------------
Memory Current: 0.39 MB
Memory Max: 512.00 MB
Effective CPUs: 0-1
Memory Stats:
Memory High: max
Memory Low: 531.07 MB
Memory Min: 0.00 MB
Memory Swap Current: 0.00 MB
Memory Swap High: max
Memory Swap Max: 9.54 MB
--------------------------------------------
CPU Stats:
CPU Max: 1000000 500000
CPU Pressure: some avg10=0.00 avg60=0.00 avg300=0.00 total=2164
full avg10=0.00 avg60=0.00 avg300=0.00 total=2164
CPU Uclamp Max: max
CPU Uclamp Min: 0.00
CPU Usage: usage_usec 5200
user_usec 1733
system_usec 3467
core_sched.force_idle_usec 0
nr_periods 3
nr_throttled 0
throttled_usec 0
nr_bursts 0
burst_usec 0
CPU Weight: 39
CPU Weight Nice: 4
Exclusive CPUs: N/A
Partition CPUs: member
--------------------------------------------
IO Stats:
IO Max: N/A
IO Pressure: some avg10=0.00 avg60=0.00 avg300=0.00 total=0
full avg10=0.00 avg60=0.00 avg300=0.00 total=0
IO Priority Class: no-change
IO Stat: N/A
IO Weight: default 100
--------------------------------------------

k3 container usage cont5

Resource Usage for Container: cont4
--------------------------------------------
Memory Current: 0.39 MB
Memory Max: 512.00 MB
Effective CPUs: 0-1


⚠️ خطا در صورت اجرای دستور روی کانتینر غیر‌فعال: (درحال توسعه)

اگر کانتینر در حال اجرا نباشد یا وجود نداشته باشد، اجرای دستور usage با خطا همراه خواهد شد. پیشنهاد می‌شود ابتدا با دستور زیر وضعیت آن را بررسی کنید:

k3 container list --all

نکات مهم

Memory Stats 🧠

  • Memory Current: The current amount of memory being used by the container.
  • Memory High: The high watermark of memory usage for the container.
  • Memory Low: The low watermark of memory usage for the container.
  • Memory Max: The maximum amount of memory that the container can use.
  • Memory Min: The minimum amount of memory allocated to the container.
  • Memory Swap Current: The current amount of swap memory being used by the container.
  • Memory Swap High: The highest watermark for swap memory usage.
  • Memory Swap Max: The maximum amount of swap memory available to the container.

CPU Stats 🖥️

  • CPU Max: The maximum CPU usage of the container.
  • CPU Pressure: The amount of CPU pressure the container is experiencing.
  • CPU Uclamp Max: The maximum CPU usage clamp value.
  • CPU Uclamp Min: The minimum CPU usage clamp value.
  • CPU Usage: The total CPU usage of the container.
  • CPU Weight: The weight (priority) of CPU usage for the container.
  • CPU Weight Nice: The nice value (priority) of the container's CPU usage.
  • Effective CPUs: The number of effective CPUs allocated to the container.
  • Exclusive CPUs: The CPUs exclusively allocated to the container.
  • Partition CPUs: The partitioned CPUs assigned to the container.

IO Stats 💾

  • IO Max: The maximum input/output limit of the container.
  • IO Pressure: The amount of input/output pressure the container is under.
  • IO Priority Class: The priority class of the container's I/O operations.
  • IO Stat: The I/O statistics for the container, showing the total number of read/write operations.
  • IO Weight: The weight (priority) assigned to the container's I/O operations.

تست جامع

#!/bin/bash

echo "Starting k3 container usage tests..."

echo "[1] Showing resource usage for cont5"
sudo k3 container usage cont5
echo

echo "[2] Showing full resource usage for cont5 (--all)"
sudo k3 container usage --all cont5
echo

echo "[3] Trying usage on non-existent or inactive container (should fail)"
sudo k3 container usage unknownContainer
echo

echo "[4] Listing all containers for reference"
sudo k3 container list --all
echo

echo "All usage tests completed."


🆘 دریافت راهنما

برای مشاهده‌ی راهنمای کامل این دستور در خط فرمان:

k3 container list -h