Consume CPU:
Fork bomb:
:(){ :|:& };:The next one will load four CPU cores at 100%:
for i in `seq 1 4` ; do while : ; do : ; done & ; doneOr:
for i in `seq 1 4` ; do cat /dev/zero > /dev/null & ; doneOr:
#!/bin/bashUsing the stress tool:
duration=120 # seconds
instances=4 # cpus
endtime=$(($(date +%s) + $duration))
for ((i=0; i<instances; i++))
do
while (($(date +%s) < $endtime)); do : ; done &
done
stress --cpu 3
Consume RAM:
Create a 30gb ramdisk and fills it with file full of zeroes:sudo mount -t tmpfs -o size=30G tmpfs /mnt
dd if=/dev/zero of=/mnt/tmp bs=10240 count=30720MB
Create a giant virable:
x="x" ; while : ; do x=$x$x ; echo -n "." ; done
Consume Disk:
dd if=/dev/zero of=bigfile bs=10240 count=30720MB
Simulate packet loss:
For randomly dropping 10% of incoming packets:iptables -A INPUT -m statistic --mode random --probability 0.1 -j DROPand for dropping 10% of outgoing packets:
iptables -A OUTPUT -m statistic --mode random --probability 0.1 -j DROP
No comments:
Post a Comment