使用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
已标记关键词 清除标记
相关推荐
©️2020 CSDN 皮肤主题: 技术黑板 设计师:CSDN官方博客 返回首页