sar Cannot open /var/log/sa/sa*: No such file or directory

sar命令Cannot open /var/log/sa/sa*: No such file or directory
發現/var/log下沒有sa文件夾,建了一個,再運行#sar -o 24(24爲當天日期) 就OK了。

該任務是由root的cron進程來建立的。
1.建立文件/etc/cron.d/sysstat
2.寫入以下配置內容:

# run system activity accounting tool every 10 minutes
*/10 * * * * root /usr/lib64/sa/sa1 1 1
# generate a daily summary of process accounting at 23:53
53 23 * * * root /usr/lib64/sa/sa2 -A

另附sar使用參考:(引用網絡摘抄)
[quote]
/**
* sar man手冊簡譯, 歡迎大家補充、指正
* Author: cnscn
* Time : 2006-10-17 09:10
*
*/

sar --- 收集、報告或保存系統活動信息 Collect, report, or save system activity information

Options:
-A 列出保存的當天的所有活動的文件內容, 等同於-bBcdqrRuvwWy -I SUM -n FULL -P ALL

-b 報告I/O和傳送速率統計。這個參數僅用於2.5及以後內核。可顯示以下字段
tps 每秒從物理磁盤I/O的次數。多個邏輯請求會被合併爲一個I/O磁盤請求。一次傳輸的大小是不確定的
rtps 每秒的讀請求數
wtps 每秒的寫請求數
bread/s 每秒讀磁盤的數據塊數(in blocks 1 block = 512B, 2.4以後內核)
bwrtn/s 每秒寫磁盤的數據塊數(in blocks 1 block = 512B, 2.4以後內核)

-B 顯示內核頁統計。 可顯示如下字段
pgpgin/s
pgpgout/s
fault/s
majflt/s

-c 顯示進程創建活動, 顯示如下字段
proc/s 每秒進程創建數

-d m n 報告每個塊設備的活動情況(2.4及以後內核)
m 每m秒採樣一次
n 共採樣n次
sar -d 30 5
Average: DEV tps rd_sec/s wr_sec/s avgrq-sz avgqu-sz await svctm %util
dev8-0 2.39 16.37 35.99 21.88 0.00 0.85 0.66 0.16
tps 顯示指定設備的每秒I/O流量,多個邏輯請求可以合併爲一個物理請求,流量爲不確定大小
rd_sec/s 從設備讀取的扇區數,(1扇區=512B)
wr_sec/s 寫入設備的扇區數
avgrq-sz 流出設備的扇區數
avgqu-sz 流出設備的平均隊列長度
await 從設備流出的平均I/O請時間,包括請求在隊列和服務時的時間
svctm 平均I/O請求的服務時間
%util I/O請求的CPU時間百分比,當數字接近100%時,設備出現飽和

-H
-h
-i interval 選取儘可能接近interval所標識的數量的記錄數 (Select data records at seconds as close as possible to the number specified by the interval parameter)

-q 報告隊列長度和平均負載,可列出下列字段
runq-sz 執行中的隊列長度(等待運行的進程數)
plist-sz 進程列表中的進程數
ldavg-1 最後一分鐘的系統負載
ldavg-5 最後5分鐘的系統負載
ldavg-15 最後15�種擁南低掣涸�

-r 報告memory和swap使用統計,可列出如下字段
kbmemfree 可用的內存數(kB)
kbmemused 應用中的內存數,但不包括內核使用的內存(kB)
%memused 內存的使用百分比
kbcached 內核用於cache的內存數(kB)
kbswpfree
kbswpused
%swpused
kbswpcad 用於cache的swap內存數(kB)

-R 報告內存活動,可列出如下字段
frmpg/s 每秒空閒的內存頁數,負值表示系統已經分配了的內存頁數。注意:依據機器體系的不同,內存頁的大小有4kB或8kB
bufpg/s 每秒系統用於buffers的附加的內存頁數。負值表示較少的頁數用於系統buffers
campg/s 每秒系統用於cached的附加的內存頁數。負值表示較少的頁數用於系統cached

-t
-u 列出cpu的使用情況,可列出下列字段
%user 用戶層
%nice   用戶層
%system  系統層
%iowait  系統有外部磁盤I/O請求時的cpu(s)的空閒時間百分不(Percentage of %time that the CPU or CPUs were idle during which the system had an outstanding disk I/O request)
%idle 系統沒有外部磁盤I/O請求時的cpu(s)的空閒時間百分不(Percentage of time that the CPU or CPUs were idle and the system did not have an outstanding disk I/O request)


-v 報告文件或其它內核表的inode的狀態,可列出如下字段
dentunusd Number of unused cache entries in the directory cache.
file-sz 已經使用了的文件句柄數 Number of used file handles
inode-sz Number of allocated disk quota entries.
super-sz 內核已經分配了的超級塊的句柄 Number of super block handlers allocated by the kernel
%super-sz Percentage of allocated super block handlers with regard to the maximum number of super block handlers that Linux can allocate.
dquot-sz 已經分配了的磁盤限額入口數 Number of allocated disk quota entries.
%dquot-sz Percentage of allocated disk quota entries with regard to the maximum number of cached disk quota entries that can be allocated.
rtsig-sz 隊列中RT信號數 Number of queued RT signals.
%rtsig-sz Percentage of queued RT signals with regard to the maximum number of RT signals that can be queued.

-V 列出版本號和用法
-w 報告系統交換活動,列出如下字段
  cswch/s 系統每秒交換活動的次數 Total number of context switches per second

-W 報告swapping活動信息,可列出如下字段
  pswpin/s 每秒系統帶來的交換頁數 Total number of swap pages the system brought in per second.
pswpout/s 系統每秒帶出、拿出的交換頁數

-y
-n {DEV|EDEV|SOCK|FULL}
報告網絡活動統計
DEV 指定列出所有網絡設備的活動統計,可列出如下字段
IFACE 網絡接口卡設備名,如eth0
rxpck/s 每秒收到的包數
txpck/s 每秒傳輸的包數

rxbyt/s 每秒收到的數據字節數
txbyt/s 每秒傳輸的數據字節數

rxcmp/s 每秒收到的壓縮包數
txcmp/s 每秒傳輸的壓縮包數

rxmcst/s 每秒收到的多播包數


EDEV 指定列出所有網設備失敗包的情況,可列出如下字段
IFACE 網絡接口卡設備名
rxerr/s 每秒收到的總的失敗包數
txerr/s 每秒鐘傳輸時的錯誤包數
coll/s 每秒鐘傳輸時的衝突包數
rxdrop/s 每秒鐘收到的包中由於Linux空間缺乏而丟棄的包數
txdrop/s 每秒鐘傳輸過程中由於Linux空間缺乏而丟棄的包數
txcarr/s 每秒鐘傳輸過程中的carrier-errors的數目
rxfram/s 每秒鐘收到的幀序列錯誤數
rxfifo/s 每秒鐘FIFO氾濫錯誤包數
txfifo/s 每秒鐘傳輸時FIFO氾濫的錯誤包數

NFS 列出NFS客戶端活動報告。 列出如下字段
call/s 每秒成功的RPC請求數
retrans/s (由於server超時)每秒需重新傳輸的RPC請求數
read/s 每秒成功的RPC的read請求數
write/s 每秒成功的RPC的write請求數
access/s 每秒成功的RPC的access請求數
getatt/s 每秒成功的RPC的getattr請求數

NFSD 列出NFS服務端活動報告。列出如下字段
totsck 總的socktes數
tcpsck 當前應用中的tcp sockets數
udpsck 當前應用中的udp sockets數
rawsck 當前應用中的RAW sockets數
ip-frag 當前應用中的IP幀數

FULL 等於指定-n選項的所有參數

-x {pid|SELF|ALL}
-X {pid|SELF|ALL}
-I {irq|SUM|ALL|XALL}
報告中斷統計資料。
irq 是中斷號,指定多個-I irq參數可以觀看到多個相關中斷的情況
SUM 指定顯示每秒中接收到的所有中斷情況
ALL 指定顯示所有中斷的前16箇中斷情況
XALL 指定顯示所有中斷包括潛在的APIC中斷源


-P {cpu|ALL}
如果缺省-P則報告系統內的所有CPU的統計。如果參數爲ALL,則報告每一個CPU和所有CPU的統計數據
# sar -P 0
Linux 2.6.17-1.2187_FC5smp (localhost.localdomain) 2006年10月17日
08時30分01秒 CPU %user %nice %system %iowait %idle
08時40分01秒 0 6.24 0.00 0.64 0.02 93.10

# sar -P 1
Linux 2.6.17-1.2187_FC5smp (localhost.localdomain) 2006年10月17日
08時30分01秒 CPU %user %nice %system %iowait %idle
08時40分01秒 1 7.66 0.00 0.60 0.03 91.71


-o [filename]
把報告輸出到文件,否則顯示到屏幕. 如果忽略filename,那麼系統將把輸出添加到/var/log/sa/sadd定時生成文件內(dd代表當前日期)

-f [filename]
從filename中提取預先保存在文件內的記錄,並顯示到屏幕上. 缺省filename則從/var/log/sa/sadd內提取

-s [hh:mm:ss]
設置報告的開始時間, Set the starting time of the data, causing the sar command to extract records time-tagged at, or following, the time specified. The default starting time is 08:00. Hours must be given in 24-hour format. This option can be used only when data are read from a file (option -f )

-e [hh:mm:ss]
設置報告的結束時間, The default ending time is 18:00:00.This option can be used only when data are read from or written to a file (options -f or -o )


[interval] 選擇記錄的時間間隔(秒)

[count] <默認爲1>

sar 向標準輸出列出選擇的活動的累積數量。在多帳戶系�襯冢ǜ嬉�ount(數量)和interval(時間間隔)參數,以指定秒數爲時間間隔的指定的次數信息.
如果interval參數指定爲0,則sar顯示系統啓動以來的平均時間統計。
如果count參數指定爲0,則報告將不連續不斷的進行。

如果不指定參數,則僅顯示CPU的活動,如果CPU使用率接近100% (user + nice + system), 則顯示出CPU侷限
# sar
08時26分00秒 LINUX RESTART
08時30分02秒 CPU %user %nice %system %iowait %idle
08時40分01秒 all 6.07 0.00 33.86 7.94 52.13
08時50分01秒 all 2.26 0.00 28.32 0.77 68.66
09時00分01秒 all 0.44 0.00 26.75 0.29 72.52
09時10分01秒 all 0.97 0.00 26.87 0.05 72.12
09時20分01秒 all 1.39 0.00 27.13 0.06 71.43
Average: all 2.22 0.00 28.58 1.82 67.38


如果需要多個樣本和報告,那麼可以如下所做
sar -o data.file interval count >/dev/null 2>&1 &

# sar -u 2 5 報告CPU的使用情況,每2秒鐘一次共輸出5行
09時01分53秒 CPU %user %nice %system %iowait %idle
09時01分55秒 all 36.41 0.00 2.49 47.38 13.72
09時01分57秒 all 38.40 0.00 18.20 36.91 6.48
09時01分59秒 all 32.50 0.00 4.50 52.00 11.00
09時02分01秒 all 44.00 0.00 48.50 7.25 0.25
09時02分03秒 all 36.91 0.00 30.42 27.93 4.74
Average: all 37.64 0.00 20.82 34.30 7.24

sar -I 14 -o int14.file 2 10
每2秒報告一次14號中斷的情況,共輸出10行,並把結果保存到文件int14.file內
Report statistics on IRQ 14 for each 2 seconds. 10 lines are displayed. Data are stored in a file called int14.file.

sar -r -n DEV -f /var/log/sa/sa16
列出每天保存在/var/log/sa/sa16內的內存、交換分區、網絡活動情況
Display memory, swap space and network statistics saved in daily data file ’sa16’.

sar -A
列出保存的當天的活動文件內容
Display all the statistics saved in current daily data file.
[/quote]
發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章