Monitoring System Performance in CentOS 7
Key Objectives of Performance Monitoring:
Monitor statistics such as:
Memory usage
CPU usage
Input/Output (I/O) usage
Delay times
Queuing
/proc File System:
CentOS 7 uses the /proc file system for monitoring system performance.
Access via the
catcommand with various kernel parameters.Definition: A pseudo-file system that interfaces directly with the kernel and exists in memory.
Kernel Parameters Sample:
Table 12-2 provides a partial listing of kernel values. For full listings, check
procman page.
Common Kernel System Values:
Entry Descriptions:
iomem: Memory input/output statisticsmounts: Mounted file system statisticsstat: Process status in readable format, detailing process resource usage.diskstats: Disk statistics providing read/write performance metrics.swaps: Swap file statistics (similar to virtual memory in Windows 10), indicating swap memory usage.loadavg: Average number of processes ready to run over the last 1, 5, and 15 minutes.
Using /proc for System-Related Tasks:
System-related tasks include:
Viewing performance and memory info for optimization purposes.
Viewing or modifying runtime parameters, allowing for dynamic resource adjustment.
Viewing hardware information for diagnostics.
Viewing network parameters to monitor traffic and connectivity.
Viewing statistical information to help in resource planning.
Command Overview:
Navigate to /proc directory:
bash cd /procList files in /proc:
bash lsRetrieve performance information:
System and file system stats:
bash cat stat cat mountsDisk stats:
bash cat diskstatsSwap, load averages, and I/O memory usage:
bash cat swaps cat loadavg cat iomem
Using the top Command:
Functionality: Displays system statistics in real-time (default 5-second update).
Basic Usage:
Command:
topDisplays top CPU processes and their resource utilization.
Key Fields in top Output:
uptime: System up time and average loads for 1, 5, and 15 minutes.processes: Total processes running and their resource demands.CPU states: Breakdown of CPU time across modes:User mode
System mode
Nice tasks
iowait (waiting for I/O)
Idle time
Mem: Total, free, used memory, shared memory, buffers providing a snapshot of memory health.Swap: Total, available, used swap space.PID: Process ID for ongoing tasks.PPID: Parent process ID for hierarchical process management.UID: User ID of the task’s owner.USER: Username of the task's owner, facilitating accountability.SHARE: Shared memory used by the task.To start top with custom iterations:
Command:
top -n 5 -d 10.00Note: This command uses significant memory; use it judiciously for troubleshooting. Press
qto exit and return to command prompt.
Using the free Command:
Functionality: Displays amounts of free and used memory, including swap, crucial for memory management.
Output shows in kilobytes by default; use
-mto view in megabytes for easier interpretation.Command:
free
Using the watch Command:
Functionality: Repeatedly runs
freeto show real-time memory statistics and system health.Default refresh every two seconds; can control the interval for flexibility.
Command:
watch free
Terminate with
Ctrl+C. This allows users to monitor changes continuously and adapt to performance needs.
Using the vmstat Command:
Overview: Reports on process status, memory consumption, paging activity, I/O operations, and CPU usage, providing a comprehensive view of system performance.
Execution: For average stats since last reboot or specific intervals, aiding in detailed performance analysis:
Command syntax:
vmstat [time] [iterations]Example:
vmstat 5 10(reporting every 5 seconds for 10 iterations) to track system performance trends over time.
Key Fields in vmstat Output:
procs: Running and sleeping processes for overall system workload.swap: Amount of memory paged for I/O, signifying active memory management.us: Percentage of CPU time used in user space, indicating application performance.sy: Percentage of CPU time used by the kernel, reflecting the system's operational workload.wa: Percentage of CPU time spent in I/O wait, highlighting bottleneck areas.id: Percentage of CPU time spent idle, giving insight into overall system utilization.
Using the uptime Command:
Functionality: Displays system uptime, CPU average load for 1, 5, and 15 minutes, active user