Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #!/bin/bash
- #
- # Script to get stress statistics#
- echo "Enter the number of intervals (seconds) for the system statistics:"
- read int
- echo "enter the number of output lines (count) to process:"
- read cnt
- INT=$int
- CNT=$cnt
- echo "How many system components would you like to stress?"
- echo -n "Number of system components being stressed: "
- read cores
- # the variable "cores" now has the value entered by keyboard
- echo "Enter the number of intervals (seconds) for running the stress statistics:"
- read seconds_to_run
- # the variable "seconds_to_run" now has the value entered by keyboard
- D=`/bin/date '+%B.%d'`
- #Variable to read the date that the command runs
- while true; do
- clear
- echo "*******************************"
- echo "* Choose from the following: *"
- echo "*******************************"
- echo "* [1] Stress the I/O (Input/Output). *"
- echo "* [2] Stress the Memory(RAM). *"
- echo "* [3] Stress the CPU. *"
- echo "* [4] Stress the hard disk drive. *"
- echo "Press A to quit."
- echo "************************"
- echo -n "Enter your menu choice [1-4]: "
- read choice
- case $choice in
- 1) echo "Stressing the I/O"
- iostat -c $INT $CNT | awk '/^$/ || (/^avg-cpu:/ && a) {next}; NR>1 {a=1;print}'> ioStressUbuntu_$D.log & sleep 5 && stress --io $cores --timeout $seconds_to_run
- echo "This file will be saved to ioStressUbuntu_$D.log"
- sleep 5
- cat ioStressUbuntu_$D.log
- sleep 10;;
- 2) echo "Stressing the RAM"
- vmstat $INT $CNT | awk 'NR > 1 {printf "%4s%8s%8sn",$13,$14,$15}'> vmStressUbuntu_$D.log & sleep 5 && stress --vm $cores --timeout $seconds_to_run
- echo "This file will be saved to vmStressUbuntu_$D.log"
- sleep 5
- cat vmStressUbuntu_$D.log
- sleep 10;;
- 3) echo "Stressing the CPU"
- sar $INT $CNT | awk '/^$/ || (/^avg-cpu:/ && a) {next}; NR>1 {a=1;print}'> cpuStressUbuntu_$D.log & sleep 5 && stress --cpu $cores --timeout $seconds_to_run
- echo "This file will be saved to cpuStressUbuntu_$D.log"
- sleep 5
- cat cpuStressUbuntu_$D.log
- sleep 10;;
- 4) echo "Stressing the HDD"
- sar -d $INT $CNT | awk '/^$/ || (/^avg-cpu:/ && a) {next}; NR>1 {a=1;print}'> diskStressUbuntu_$D.log & sleep 5 && stress --hdd $cores --timeout $seconds_to_run
- echo "This file will be saved to diskStressUbuntu_$D.log"
- sleep 5
- cat diskStressUbuntu_$D.log
- sleep 10;;
- A) #Quit option
- echo You have chosen to quit.
- exit;;
- *) #Wildcard option in case user enters an invalid option.
- echo Invalid choice, please make another choice
- sleep 3;;
- esac
- done
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement