linux压测脚本

2022-08-12  本文已影响0人  wuqingfeng

需要对linux进行压测,网上找了一些脚本,会报错。因此将好用的脚本整理记录一下。

#! /bin/bash
# filename killcpu.sh
endless_loop()
{
echo -ne "i=0;
while true
do
i=i+100;
i=100
done" | /bin/bash &
}

if [ $# != 1 ] ; then
  echo "USAGE: $0 <CPUs>"
  exit 1;
fi
for i in `seq $1`
do
  endless_loop
  pid_array[$i]=$! ;
done

for i in "${pid_array[@]}"; do
  echo 'kill ' $i ';';
done
#!/bin/bash
mkdir /tmp/memory
mount -t tmpfs -o size=300M tmpfs /tmp/memory
dd if=/dev/zero of=/tmp/memory/block
sleep 10s
rm /tmp/memory/block
umount /tmp/memory
rmdir /tmp/memory
上一篇下一篇

猜你喜欢

热点阅读