FreeBSD安装和配置系统活动报告程序(SAR)

如何在FreeBSD下安装sar命令来收集,报告或保存系统活动信息?

bsdsar是FreeBSD系统的系统活动报告程序(SAR)。它每隔一段时间就记录网络,CPU,内存,交换和NFS使用情况的信息。

sa命令查看系统统计信息

编辑/etc/rc.conf文件:

# vi /etc/rc.conf

打开记账功能:

accounting_enable="YES"

启动服务

# /etc/rc.d/accounting start

如何查看统计信息

查看列出所有命令资源使用情况:

# sa -a

查看每个命令的磁盘I/O操作平均数:

# sa -d

查看磁盘I/O操作总数,请输入:

# sa -D

配置bsdsar

打开配置文件/usr/local/etc/bsdsar.conf:

# vi /usr/local/etc/bsdsar.conf

配置要搜集的数据,例如,关闭收集nfs数据:

nfs = off

配置文件示例:

log_directory = /var/log
max_data_file_size = 4096000
cpu = on
disk = on
memory_swap = on
net = on
nfs = off
cpu_mem_processes = on

bsdsar_gather命令

bsdsar_gather用于收集数据。

在/etc/crontab文件中看到下面计划任务,用于收集数据:

20,40   8-18    *       *       *       root    /usr/local/bin/bsdsar_gather
0       *       *       *       *       root    /usr/local/bin/bsdsar_gather

在Linux如何查看资源的使用情况?

查看网络接口数据:

# bsdsar -i

输出示例:

Time       In Pkts    In Errors     In Bytes     Out Pkts   Out Errors    Out Bytes    Coll  Interface
00:00      5930140            0   8741522861      3096503            0    250130450       0    em0
01:00      5965075            0   8792550130      3114793            0    252111930       0    em0
02:00      5965075            0   8792550130      3114793            0    252111930       0    em0
03:00      5965078            0   8792550507      3114796            0    252112134       0    em0
04:00      5965184            0   8792569021      3114902            0    252121128       0    em0
05:00      6004005            0   8849450350      3135235            0    254298106       0    em0


Time       In Pkts    In Errors     In Bytes     Out Pkts   Out Errors    Out Bytes    Coll  Interface
00:00     87328207            0 124968895768     76277756            0   5447644061       0    em1
01:00     87683130            0 125477348559     76595358            0   5470522718       0    em1
02:00     88052370            0 126006376581     76926305            0   5494392360       0    em1
03:00     88293028            0 126350982635     77142146            0   5509979199       0    em1

查看CPU使用情况数据,请输入:

# bsdsar -u

输出示例:

Time     % User  % Sys  % Nice  % Intrpt  % Idle  
00:00       1      1       0         0      98
01:00       0      0       0         0     100
02:00       0      0       0         0     100
03:00       0      0       0         0     100
04:00       3      7       0         0      89
05:00       0      1       0         0      99

查看前5个cpu进程,请输入:

# bsdsar -s

要查看前5个内存进程,请输入:

# bsdsar -S

要获取帮助,请输入:

# bsdsar -h

安装bsdsar

执行以下命令来安装bsdsar:

# portsnap fetch update
# cd /usr/ports/sysutils/bsdsar
# make install clean
日期:2019-11-20 08:53:58 来源:oir作者:oir