Два способа расчитать iowait
1. Без «bc» (целое число без дробной части):
1 |
echo $(($(cat /proc/stat | grep -w cpu | awk {'print $6'})/(($(cat /proc/stat | grep -w cpu | awk {'print $2'})/$(cat /proc/stat | grep -w cpu | awk {'print $3'})+$(cat /proc/stat | grep -w cpu | awk {'print $4'})+$(cat /proc/stat | grep -w cpu | awk {'print $5'})+$(cat /proc/stat | grep -w cpu | awk {'print $6'})+$(cat /proc/stat | grep -w cpu | awk {'print $7'})+$(cat /proc/stat | grep -w cpu | awk {'print $8'})+$(cat /proc/stat | grep -w cpu | awk {'print $9'}))/100))) |
2. С «bc» покажет дробную часть:
1 |
echo "scale=2; $(cat /proc/stat | grep -w cpu | awk {'print $6'})/(($(cat /proc/stat | grep -w cpu | awk {'print $2'})+$(cat /proc/stat | grep -w cpu | awk {'print $3'})+$(cat /proc/stat | grep -w cpu | awk {'print $4'})+$(cat /proc/stat | grep -w cpu | awk {'print $5'})+$(cat /proc/stat | grep -w cpu | awk {'print $6'})+$(cat /proc/stat | grep -w cpu | awk {'print $7'})+$(cat /proc/stat | grep -w cpu | awk {'print $8'})+$(cat /proc/stat | grep -w cpu | awk {'print $9'}))/100)" | bc |