أدوات أداء الذاكرة ووحدة المعالجة المركزية
استخدم أدوات مثل `vmstat` و`sar` و`mpstat` لتشخيص مشكلات الأداء المرتبطة بوحدة المعالجة المركزية والذاكرة.
أدوات أداء الذاكرة ووحدة المعالجة المركزية درس مجاني في Linux Command Line Mastery على CoddyKit. هذا هو الدرس 2 من أصل 4. يمكنك قراءة الدرس كاملاً أدناه مجاناً — ثم تمرن عليه مباشرة في المتصفح باستخدام محرر أكواد مدمج ومدرس ذكاء اصطناعي متاح 24/7. هذا الدرس جزء من مسار التعلم في Linux Command Line Mastery، وتقدمك يتزامن عبر الويب وتطبيق CoddyKit. تتضمن دورة Linux Command Line Mastery 4 دروس في المجموع.
بعض أجزاء هذا الدرس لم تُترجم بعد وتظهر باللغة الإنجليزية.
Diagnose Performance Issues
Understanding system performance is key to troubleshooting slow applications or an unresponsive server. CPU and memory are often the first resources to check.
In this lesson, we'll explore powerful command-line tools to monitor and diagnose issues related to your system's CPU and memory usage.
Meet `vmstat`
The vmstat (virtual memory statistics) command provides a quick, real-time snapshot of your system's activity. It reports on processes, memory, paging, block I/O, traps, and CPU activity.
It's excellent for observing current system behavior and identifying immediate bottlenecks.
`vmstat` Memory Overview
Let's run vmstat 1 1 to see a single report, then we'll break down the memory-related output. This command shows a report every 1 second, for 1 iteration.
- swpd: amount of virtual memory used.
- free: amount of idle memory.
- buff: memory used as buffers.
- cache: memory used as cache.
vmstat 1 1`vmstat` CPU Details
Now, let's look at the CPU section of vmstat. Run the command again if you like, and focus on the 'cpu' columns:
- us (user): time spent running non-kernel code.
- sy (system): time spent running kernel code.
- id (idle): time spent idle.
- wa (wait): time spent waiting for I/O.
High wa often indicates disk bottlenecks.
vmstat 1 1Introducing `sar`
The sar (System Activity Reporter) command is part of the sysstat package. Unlike vmstat, sar can collect and report historical system activity data.
This makes it invaluable for long-term analysis, identifying trends, and diagnosing intermittent problems that might not be visible with real-time tools.
`sar` for CPU Usage
To view CPU utilization with sar, we use the -u option. Run sar -u 1 1 to get a single report.
- %user: CPU usage by user-level applications.
- %system: CPU usage by kernel-level tasks.
- %iowait: Time CPU spent waiting for I/O.
- %idle: Time CPU was idle.
sar -u 1 1`sar` for Memory Usage
To get detailed memory utilization reports with sar, use the -r option. Try sar -r 1 1.
- kbmemfree: Amount of free memory.
- kbmemused: Amount of used memory.
- %memused: Percentage of used memory.
- kbbuffers: Memory used by kernel buffers.
- kbcached: Memory used by page cache.
sar -r 1 1Understanding `mpstat`
The mpstat (multi-processor statistics) command is also part of the sysstat package. Its main advantage is providing per-processor or per-core CPU activity.
This is crucial for systems with multiple CPU cores, as it helps identify if a specific core is overloaded while others are idle.
`mpstat` Per-Core Activity
To see statistics for all individual CPU cores, use mpstat -P ALL 1 1. You'll see a separate line for each core (CPU 0, CPU 1, etc.) and an 'all' line for the average.
This helps pinpoint if a single-threaded application is maxing out one core, even if overall CPU usage seems low.
mpstat -P ALL 1 1Performance Tool Check
Which of the following statements about Linux performance tools are TRUE?
Recap: CPU & Memory Tools
In this lesson, you learned about three essential tools for monitoring CPU and memory performance:
vmstat: For real-time system activity snapshots.sar: For collecting and reporting historical system activity data.mpstat: For detailed per-processor/per-core CPU usage.
Mastering these commands will significantly boost your ability to diagnose and troubleshoot Linux system performance issues.
الأسئلة الشائعة
هل درس «أدوات أداء الذاكرة ووحدة المعالجة المركزية» مجاني؟
نعم — نص درس «أدوات أداء الذاكرة ووحدة المعالجة المركزية» كامل متاح مجاناً هنا على الويب. لتمرينه بشكل تفاعلي (محرر أكواد مدمج ومدرس ذكاء اصطناعي متاح 24/7) وفتح باقي دورة Linux Command Line Mastery، انتقل إلى CoddyKit PRO. تتضمن دورة Linux Command Line Mastery 4 دروس في المجموع.
ماذا ستتعلم في «أدوات أداء الذاكرة ووحدة المعالجة المركزية»؟
استخدم أدوات مثل `vmstat` و`sar` و`mpstat` لتشخيص مشكلات الأداء المرتبطة بوحدة المعالجة المركزية والذاكرة. تتمرن على Linux Command Line Mastery مع أكواد عملية تشغلها مباشرة في المتصفح، ومدرس ذكاء اصطناعي متاح 24/7 يجيب على أسئلتك أثناء عملك.
هل أحتاج إلى خبرة سابقة لأبدأ Linux Command Line Mastery؟
لا تُشترط خبرة سابقة. Linux Command Line Mastery على CoddyKit منظم للمبتدئين حتى المتقدمين، لذا يمكنك البدء من هنا أو من البداية والتقدم بسرعتك الخاصة. هذا هو الدرس 2 من أصل 4.
كم من الوقت يستغرق درس «أدوات أداء الذاكرة ووحدة المعالجة المركزية»؟
معظم دروس CoddyKit تستغرق حوالي 5–10 دقائق. كل منها موجز وتفاعلي، لذا تحرز تقدماً مستمراً وتستأنف من حيث توقفت عبر الويب والتطبيق.
هل يمكنني كتابة وتشغيل أكواد في درس Linux Command Line Mastery هذا؟
نعم. كل درس في Linux Command Line Mastery يتضمن محرر أكواد مدمج، لذا تكتب وتشغل أكواداً حقيقية مباشرة في متصفحك وتحصل على تعليقات فورية من الذكاء الاصطناعي — بدون إعداد محلي.
جميع الدروس في هذه الدورة
- مراقبة إدخال/إخراج القرص: `iostat` و`iotop`
- أدوات أداء الذاكرة ووحدة المعالجة المركزية
- تقنيات متقدمة للتسجيل واستكشاف الأخطاء وإصلاحها
- تتبّع استدعاءات النظام باستخدام strace وltrace