Advertisement
Guest User

Untitled

a guest
Mar 5th, 2015
253
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.77 KB | None | 0 0
  1. #!/bin/bash
  2. #
  3. # Script to get stress statistics#
  4.  
  5. echo "Enter the number of intervals (seconds) for the system statistics:"
  6. read int
  7. echo "enter the number of output lines (count) to process:"
  8. read cnt
  9. INT=$int
  10. CNT=$cnt
  11. echo "How many system components would you like to stress?"
  12.  
  13. echo -n "Number of system components being stressed: "
  14. read cores
  15. # the variable "cores" now has the value entered by keyboard
  16.  
  17.  
  18. echo "Enter the number of intervals (seconds) for running the stress statistics:"
  19.  
  20. read seconds_to_run
  21. # the variable "seconds_to_run" now has the value entered by keyboard
  22.  
  23. D=`/bin/date '+%B.%d'`
  24. #Variable to read the date that the command runs
  25.  
  26. while true; do
  27. clear
  28. echo "*******************************"
  29. echo "* Choose from the following: *"
  30. echo "*******************************"
  31. echo "* [1] Stress the I/O (Input/Output). *"
  32. echo "* [2] Stress the Memory(RAM). *"
  33. echo "* [3] Stress the CPU. *"
  34. echo "* [4] Stress the hard disk drive. *"
  35. echo "Press A to quit."
  36. echo "************************"
  37. echo -n "Enter your menu choice [1-4]: "
  38.  
  39. read choice
  40.  
  41.  
  42.  
  43. case $choice in
  44. 1) echo "Stressing the I/O"
  45. 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
  46. echo "This file will be saved to ioStressUbuntu_$D.log"
  47. sleep 5
  48. cat ioStressUbuntu_$D.log
  49. sleep 10;;
  50.  
  51. 2) echo "Stressing the RAM"
  52. 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
  53. echo "This file will be saved to vmStressUbuntu_$D.log"
  54. sleep 5
  55. cat vmStressUbuntu_$D.log
  56. sleep 10;;
  57.  
  58. 3) echo "Stressing the CPU"
  59. 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
  60. echo "This file will be saved to cpuStressUbuntu_$D.log"
  61. sleep 5
  62. cat cpuStressUbuntu_$D.log
  63. sleep 10;;
  64.  
  65. 4) echo "Stressing the HDD"
  66. 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
  67. echo "This file will be saved to diskStressUbuntu_$D.log"
  68. sleep 5
  69. cat diskStressUbuntu_$D.log
  70. sleep 10;;
  71.  
  72. A) #Quit option
  73. echo You have chosen to quit.
  74. exit;;
  75.  
  76. *) #Wildcard option in case user enters an invalid option.
  77. echo Invalid choice, please make another choice
  78. sleep 3;;
  79.  
  80.  
  81. esac
  82. done
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement