updated on Tue Jan 10 08:08:34 UTC 2012
[aur-mirror.git] / ioniced / iops.sh
blob5c403354e11bfe25c941a7105ee0f92621b26817
1 #!/bin/bash
2 version=1.0
3 # This script shows the ionice value for all processes by adding this value
4 # to the output of ps.
5 type ionice &>/dev/null || { echo "ionice not available" >&2; exit 1; }
6 export i=0
7 /bin/ps -e -o pid,nice,args |
8 while read pid nice rest
9 do
10 if [ $i -eq 0 ]
11 then
12 #printf %5s' ' "$pid"
13 #printf %13s' ' IONICE
14 #echo "$rest"
15 echo " PID IONICE NI COMMAND"
16 else
17 ionice_value=$(ionice -p "$pid" 2>/dev/null | sed -n 's/:.* /\//p')
18 if [ -z "$ionice_value" ]
19 then
20 ionice_value=exited
22 printf %5i' ' $pid
23 printf %13s' ' $ionice_value
24 printf %3i' ' $nice
25 echo "$rest"
27 ((i++))
28 done