The sar command is a powerful tool used to collect, report, and save activity information on UNIX and Linux systems. It stores the selected performance counters in the /var/log/sa/sadd file. From this data, you can gather valuable insights about your server's performance, including:
- CPU utilization
- Memory page usage and swapping
- Network I/O and transmission statistics
- Process creation activity
- Block device activities
- Interrupts per second, and more.
The output from the sar command can help identify potential bottlenecks in your system. However, interpreting the raw data can be challenging, which is why tools like kSar are useful. kSar provides a graphical interface that plots the sar output into easy-to-understand charts based on time cycles.
The sysstat package includes several utilities such as sar, sa1, and sa2. These tools are essential for monitoring and analyzing system performance on Linux systems.
sar: Displays collected system activity data.
sa1 and sa2: Collect and store data for later analysis. sa1 writes daily system activity logs in binary format, while sa2 generates a daily summary report.
sadc: The system activity data collector used by sa1 and sa2. You can configure various options by modifying these scripts, which are typically located in directories such as /usr/lib64/sa/sa1 (for 64-bit systems) or /usr/lib/sa/sa1 (for 32-bit systems).
To install sar on your system, especially on CentOS/RHEL-based distributions, you can use the following yum command:
yum install sysstat
After installation, the sysstat configuration file at /etc/sysconfig/sysstat allows you to set how many days of log files are retained (default is 7 days). For example, setting HISTORY=28 will keep logs for 28 days.
The default cron job for sysstat is found in /etc/cron.d/sysstat. It runs the sa1 script every 10 minutes and the sa2 script at 23:53 to generate a daily summary. To include disk and interrupt statistics, you can modify the cron entry to include options like -I and -d.
For CentOS/RHEL 7.x systems, you may need to pass the -S DISK or -S XALL option to collect detailed block device and interrupt statistics.
Once installed, you can start the sysstat service using commands like:
systemctl enable sysstat
systemctl start sysstat.service
To view system activity, use the sar command with different options. For example:
sar -u 3 10 # View CPU usage every 3 seconds for 10 times
sar -c 3 10 # View process creation statistics
sar -b 3 10 # View I/O and transfer rates
sar -d 3 10 # View block device activity
sar -n DEV 3 10 # View network device statistics
sar -P ALL # View all CPU statistics
sar -x PID # View statistics for a specific process
kSar is a Java-based tool that helps visualize sar data in an intuitive way. It supports exporting data to PDF, JPG, PNG, and CSV formats. You can load data from local files, remote servers via SSH, or directly from running commands.
To download and run kSar, visit its official GitHub page and use the following command:
wget https://github.com/vlsi/ksar/releases/download/v5.2.4-snapshot-652bf16/ksar-5.2.4-SNAPSHOT-all.jar
java -jar ksar-5.2.4-SNAPSHOT-all.jar
With kSar, you can easily analyze performance trends over time and identify potential issues in your system. It's especially helpful for users who are not familiar with the command-line interface of sar.
In addition to kSar, there's also isag, a simpler alternative that visualizes sar data stored in binary files. While it offers fewer features than kSar, it’s still a useful tool for quick visualizations.
By using these tools effectively, you can monitor your Linux servers, detect performance issues, and optimize resource usage. Whether you're managing a single server or a large cluster, understanding system activity through tools like sar and kSar is essential for maintaining high performance and reliability.
Temperature Sensor,Ambient Temperature Sensor,Air Temperature Sensor,Fuel Temperature Sensor
Xiaogan Yueneng Electronic Technology Co., Ltd. , https://www.xgsensor.com