使用stress在Ubuntu Server模拟占用CPU,和内存

使用stress在Ubuntu Server模拟占用CPU,和内存;可在k8s pod,或docker,或主机系统下执行。

  • Stress - tool to impose load on and stress test systems
`stress' imposes certain types of compute stress on your system

       -?, --help
              show this help statement

       --version
              show version statement

       -v, --verbose
              be verbose

       -q, --quiet
              be quiet

       -n, --dry-run
              show what would have been done

       -t, --timeout N
              timeout after N seconds

       --backoff N
              wait factor of N microseconds before work starts

       -c, --cpu N
              spawn N workers spinning on sqrt()

       -i, --io N
              spawn N workers spinning on sync()

       -m, --vm N
              spawn N workers spinning on malloc()/free()

       --vm-bytes B
              malloc B bytes per vm worker (default is 256MB)

       --vm-stride B
              touch a byte every B bytes (default is 4096)

       --vm-hang N
              sleep N secs before free (default none, 0 is inf)

       --vm-keep
              redirty memory instead of freeing and reallocating

       -d, --hdd N
              spawn N workers spinning on write()/unlink()

       --hdd-bytes B
              write B bytes per hdd worker (default is 1GB)

       Example: stress --cpu 8 --io 4 --vm 2 --vm-bytes 128M --timeout 10s

       Note: Numbers may be suffixed with s,m,h,d,y (time) or B,K,M,G (size).
  • 示例脚本:
#! /bin/sh 
# filename STRESS_POD_USAGE.sh

# Test POD Max Usages: CPU,MEM,IO
# Editor: Thomas
# Date: 2021-01-30 
# 请在worker节点执行 
# analysis tools: perf  


# Install tools
sudo apt-get update && sudo apt-get install -y stress nmon linux-tools-common linux-tools-generic linux-tools-`uname -r`
# counts cpu cores, `nproc` ,`grep -Pc '^processor\t' /proc/cpuinfo`
echo "TOTAL CPU CORES: "
cat /proc/cpuinfo | grep processor | wc -l
# count mem size
echo "TOTAL MEM SIZE: "
free -m

uptime 
# stress http://manpages.ubuntu.com/manpages/bionic/man1/stress.1.html
stress --cpu 190 --io 190 --vm 750 --vm-bytes 1024M -d 750 --vm-keep --timeout 3600s 
uptime

*或尝试 tload

` tload -s 750 -d 750`
  • 更美观的查看工具
  • matrix
  • htop
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值