Rocky Linux 9に監視ツールSysStatをインストールする
環境
OSバージョンを確認します
# cat /etc/redhat-release
Rocky Linux release 9.0 (Blue Onyx)
操作方法
1.SysStat をインストールします。
# dnf -y install sysstat
自動起動を設定します
# systemctl enable --now sysstat
2.ステータスを確認します
# systemctl status sysstat
● sysstat.service - Resets System Activity Logs Loaded: loaded (/usr/lib/systemd/system/sysstat.service; enabled; vendor preset: enabled) Active: active (exited) since Sat 2022-10-29 10:35:22 JST; 26s ago Process: 226169 ExecStart=/usr/lib64/sa/sa1 --boot (code=exited, status=0/SUCCESS) Main PID: 226169 (code=exited, status=0/SUCCESS) CPU: 231ms 10月 29 10:35:22 localhost.localdomain systemd[1]: Starting Resets System Activity Logs... 10月 29 10:35:22 localhost.localdomain systemd[1]: Finished Resets System Activity Logs.
3.システムリソースの情報はデフォルトで10分間隔で取得されます
# grep -A 1 'Timer' /usr/lib/systemd/system/sysstat-collect.timer [Timer] OnCalendar=*:00/10
取得間隔を変更する場合は設定ファイルを新規作成してデフォルトをオーバーライドします
# systemctl edit sysstat-collect.timer
4.ログの保管期間等を変更します
# vi /etc/sysconfig/sysstat
ファイルの内容
# sysstat-12.5.4 configuration file. # How long to keep log files (in days). # If value is greater than 28, then use sadc's option -D to prevent older # data files from being overwritten. See sadc(8) and sysstat(5) manual pages. HISTORY=28 # Compress (using xz, gzip or bzip2) sa and sar files older than (in days): COMPRESSAFTER=31 # Parameters for the system activity data collector (see sadc manual page) # which are used for the generation of log files. SADC_OPTIONS=" -S DISK" # Directory where sa and sar files are saved. The directory must exist. SA_DIR=/var/log/sa # Compression program to use. ZIP="xz" # By default sa2 script generates yesterday's summary, since the cron job # usually runs right after midnight. If you want sa2 to generate the summary # of the same day (for example when cron job runs at 23:53) set this variable. #YESTERDAY=no # By default sa2 script generates reports files (the so called sarDD files). # Set this variable to false to disable reports generation. #REPORTS=false # Tell sa2 to wait for a random delay in the range 0 .. ${DELAY_RANGE} before # executing. This delay is expressed in seconds, and is aimed at preventing # a massive I/O burst at the same time on VM sharing the same storage area. # Set this variable to 0 to make sa2 generate reports files immediately. DELAY_RANGE=0 # The sa1 and sa2 scripts generate system activity data and report files in # the /var/log/sa directory. By default the files are created with umask 0022 # and are therefore readable for all users. Change this variable to restrict # the permissions on the files (e.g. use 0027 to adhere to more strict # security standards). UMASK=0022
説明
HISTORY ログの保管期間 COMPRESSAFTER 指定日数より古いログは圧縮する SA_DIR ログの保管場所 ZIP ログの圧縮方式