因為CPU數變化導致執行sar命令報錯:Invalid system activity file: /var/log/sa/saxx

guocun09發表於2018-07-30

29號早上9點對一臺Linux redhat 6 的VM(虛擬機器)在調整CPU數(2->8)後發現,sar 檢視當天CPU loading時,報錯:


[root@vswhInd4DBt ~]# sar

Invalid system activity file: /var/log/sa/sa29


檢視SYSSTAT官網

主要說可能是因為sysstat版本變化照成saxx檔案(/var/log/sa/sa29)格式的變化,不相容導致不可讀sarxx檔案

Invalid system activity file: ... 

You are trying to use a file which is not a system activity file, or whose format is no longer compatible with that of files created by current version of sar.
If you were trying to use the standard system activity files located in the /var/log/sa directory then the solution is easy: Just log in as root and remove by hand all the files located in the /var/log/sa directory: 

rm /var/log/sa/sa??  

If you are using sysstat 11.1.1 and later, you can also use the sadf command to convert an old system activity binary datafile (version 9.1.6 and later) to current up-to-date format. Use the following syntax:

sadf -c old_datafile > new_datafile

Note: Starting with sysstat version 8.1.1 and later, it is possible to know which version of sar or sadc has been used to create a data file. Just enter the following command:

sadf -H /your/datafile | grep sysstat
File created using sar/sadc from sysstat version 8.1.7


回到我的環境,sysstat版本並沒有變化。

懷疑因為CPU數的變化,導致saxx檔案記錄及運算的變化,使saxx檔案寫入失敗sar不可讀。


準備等30號再看是否正常,果然命令顯示正常:

[root@vswhInd4DBt ~]# sar

Linux 2.6.32-504.el6.x86_64 (vswhInd4DBt)       07/30/2018      _x86_64_        (8 CPU)


12:00:01 AM     CPU     %user     %nice   %system   %iowait    %steal     %idle

12:10:01 AM     all      0.48      0.00      0.11      0.12      0.00     99.29

12:20:01 AM     all      0.27      0.00      0.10      0.06      0.00     99.57

12:30:02 AM     all      0.21      0.00      0.08      0.02      0.00     99.68

...

當然,在29號對CPU調整後rm -rf /var/log/sa/sa29 ,sar命令應該也能顯示出調整後的資訊

來自 “ ITPUB部落格 ” ,連結:http://blog.itpub.net/25583515/viewspace-2168585/,如需轉載,請註明出處,否則將追究法律責任。

相關文章