oliverthered

zipio_awk.sh

Nov 9th, 2020
116
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Bash 0.74 KB | None | 0 0
  1. #!/bin/bash
  2. loadthreashold=0.05
  3. ioprocthreshold=20
  4. cpuprocthreashold=20.0
  5. cpuprocreset=5.0
  6. reniceto=10
  7. while true
  8. do
  9. i=$(cut -d ' ' -f 1 /proc/loadavg)
  10. if [[ $i > $loadthreashold ]]
  11. then
  12. echo "Load exceeds threshold of $loadthreashold"
  13. for i in $(./iotop -P -b -q -o -d 0.1 -n 5 | awk -F ' ' "{if ( \$1 ~/[0-9]/ && \$10 > $ioprocthreshold && \$2 == "be/0") print \$1}")
  14. do
  15. ionice -c 3 -p $i
  16. echo "process $i reniced to idle as it was hogging io"
  17. done
  18. for i in $(top -b -d 0.1 -n 5 | awk -F ' ' "{if ( \$1 ~ /[0-9]/ && \$4 == 0 && \$9 > $cpuprocthreashold) print \$1}")
  19. do
  20. renice -n $reniceto -p $i
  21. echo "process $i reniced to $reniceto as it was hogging cpu"
  22. </linux-improvements-bundle/zipio-0.3.sh" 30L, 884C           1,1           Top
  23.  
Advertisement
Add Comment
Please, Sign In to add comment