交叉编译sysstat工具(mpstat、iostat、sar等)

24 篇文章 3 订阅

linux下经常需要分析cpu占用率、io使用情况、内存使用情况等系统相关状态,sysstat是一个工具包,里面集成了很多条工具命令。有的嵌入式设备中不带sysstat里面的命令,这个时候就需要我们根据开发板的编译链手动编译一下就可以使用了。

  • iostat - 提供CPU统计,存储I/O统计(磁盘设备,分区及网络文件系统)
  • mpstat - 提供单个或组合CPU相关统计
  • pidstat - 提供Linux进程级别统计:I/O、CPU、内存等
  • sar - 收集、报告、保存系统活动信息:CPU、内存、磁盘、中断、网络接口、TTY、内核表等
  • sadc - 系统活动数据收集器,作为sar后端使用
  • sa1 - 收集系统活动日常数据,并二进制格式存储,它作为sadc的工具的前端,可以通过cron来调用
  • sa2 - 生成系统每日活动报告,同样可作为sadc的工具的前端,可以通过cron来调用
  • sadf - 可以以CSV、XML格式等显示sar收集的性能数据,这样非常方便的将系统数据导入到数据库中,或导入到Excel中来生成图表
  • nfsiostat-sysstat: 提供NFS I/O统计
  • cifsiostat: 提供CIFS统计

准备工作
1、sysstat主页下载源码
http://pagesperso-orange.fr/sebastien.godard/download.html

在这里插入图片描述
2、编译链准备,本文工具链为:gcc-linaro-6.3.1-2017.05-x86_64_arm-linux-gnueabihf

编译
1、配置configure
解压sysstat包后执行

CC=arm-linux-gnueabihf-gcc ./configure --host=arm --cache-file=/home/tt/Music/sysstat-12.2.0/tmp/cache --prefix=/home/tt/Music/sysstat-12.2.0/tmp/out --exec-prefix=/home/tt/Music/sysstat-12.2.0/tmp/exe

CC=arm-linux-gnueabihf-gcc 设置交叉编译工具,这个必须放到./configure 之前,且CC=arm不能含有空格

–host=arm 设置主机类型,这个必须设置,否则会出现configure 错误

–cache-file=/home/tt/Music/sysstat-12.2.0/tmp/cache 设置缓存文件

–prefix=/home/tt/Music/sysstat-12.2.0/tmp/out 设置输出文件目录,需使用绝对路径

–exec-prefix=/home/tt/Music/sysstat-12.2.0/tmp/exe 设置可执行文件目录,需使用绝对路径

执行完上面语句,会生成Makefile文件
相关打印如下:

Check programs: . checking for arm-gcc… arm-linux-gnueabihf-gcc
checking whether the C compiler works… yes checking for C compiler
default output file name… a.out checking for suffix of
executables… checking whether we are cross compiling… yes
。。。省略
config.status: creating man/sar.1 config.status: creating
man/sysstat.5 config.status: creating man/iostat.1 config.status:
creating man/cifsiostat.1 config.status: creating tests/variables
config.status: creating Makefile

Sysstat version: 12.2.0 Installation
prefix: /home/pengwei/Music/sysstat-12.2.0/tmp/out rc
directory: /etc Init directory: /etc/init.d Systemd unit
dir: /lib/systemd/system Configuration
file: /etc/sysconfig/sysstat Man pages
directory: ${datarootdir}/man Compiler: arm-linux-gnueabihf-gcc
Compiler flags: -g -O2

2、执行make 编译
3、sudo make install,即可在configure配置的目录中看到相关工具了,直接放到开发板上使用
在这里插入图片描述

ps:有些可执行文件可以直接使用,有些需要打开sysstat功能,比如sar
打开方法是:

[root@localhost ~]# chkconfig --level 35 sysstat on
[root@localhost ~]# chkconfig |grep sysstat
sysstat         0:off   1:on    2:on    3:on    4:on    5:on    6:off
  • 5
    点赞
  • 10
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值