linux的CPU占用脚本、内存占用脚本和硬盘IO测试代码,2024年最新软件测试组件化入门

本文介绍了如何在Linux系统中进行内存占用和硬盘IO的测试,包括使用`free`命令查看内存状态,通过`dd`命令进行硬盘读写速度测试,以及如何释放内存和缓存。此外,还提到了rpm包下载安装和占用测试的步骤,适用于服务器运维和监控。
摘要由CSDN通过智能技术生成

If executed ctrl+C,Please execute the following lines manually

execute: rm -rf /tmp/memory/block

execute: umount /tmp/memory

execute: rmdir /tmp/memory

Please wait 120 seconds

  • 这个占用的是 shared共享内存,可以看到数量已经有变化了,并且free可用内存也相应减少了

在这里插入图片描述

  • 等待120秒以后呢,该脚本运行结束,并且占用的内存也会被释放

[root@centos-76-qcow2-50g-3 ~]# sh free.sh 20480 120

total used free shared buff/cache available

Mem: 64264 451 63559 16 253 63300

Swap: 0 0 0

dd: writing to ‘/tmp/memory/block’: No space left on device

41943041+0 records in

41943040+0 records out

21474836480 bytes (21 GB) copied, 67.0879 s, 320 MB/s

total used free shared buff/cache available

Mem: 64264 451 43033 20496 20779 42797

Swap: 0 0 0

If executed ctrl+C,Please execute the following lines manually

execute: rm -rf /tmp/memory/block

execute: umount /tmp/memory

execute: rmdir /tmp/memory

Please wait 120 seconds

[root@centos-76-qcow2-50g-3 ~]#

[root@centos-76-qcow2-50g-3 ~]# free -m

total used free shared buff/cache available

Mem: 64264 451 63559 16 253 63300

Swap: 0 0 0

[root@centos-76-qcow2-50g-3 ~]#

rpm包的方式


rpm包下载安装

下载好以后上传到linux主机上,然后通过下面方法安装好。

[root@ccx ~]# ls /opt

memload-7.0-1.r29766.x86_64.rpm

[root@ccx ~]# rpm -ivh /opt/memload-7.0-1.r29766.x86_64.rpm

Preparing… ################################# [100%]

Updating / installing…

1:memload-7.0-1.r29766 ################################# [100%]

[root@ccx ~]#

占用测试

  • 基本环境弄好了,我们现在开始消耗内存看看【占用内存不要超过总内存】

我下面是在多个窗口中,注意看主机名 的变化

可以看到node2现在消耗了1G内存

[root@ccx ~]# free -

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值