Hello All,
I wanted to write a script that will report me the idle percentage of the cpu. For this I was planning on using "iostat".
When I run iostat with its -w parameter, the cpu idle values change ("iostate -t proc -w 1"). This is ok. It continuously prints the proc parameters every second. The values show change in the cpu idle percentage. As can be seen below
tty cpu
tin tout us ni sy in id
3 56 8 0 3 0 88
1 81 4 0 3 0 93
0 27 3 0 2 0 95
0 27 3 0 3 0 94
1 27 3 0 2 0 94
But when I do this in a loop, the values do not change. I have created a loop like so...
while test "1"=="1"; do iostat -t proc; sleep 0.8; done
This does invoke iostat. But the values do now change. Here is the output
tty cpu
tin tout us ni sy in id
2 61 8 0 3 0 88
tty cpu
tin tout us ni sy in id
2 61 8 0 3 0 88
tty cpu
tin tout us ni sy in id
2 61 8 0 3 0 88
tty cpu
tin tout us ni sy in id
2 61 8 0 3 0 88
tty cpu
tin tout us ni sy in id
2 61 8 0 3 0 88
tty cpu
tin tout us ni sy in id
2 61 8 0 3 0 88
Why would the values not change? I am confused on this behavior...
Regards
I wanted to write a script that will report me the idle percentage of the cpu. For this I was planning on using "iostat".
When I run iostat with its -w parameter, the cpu idle values change ("iostate -t proc -w 1"). This is ok. It continuously prints the proc parameters every second. The values show change in the cpu idle percentage. As can be seen below
tty cpu
tin tout us ni sy in id
3 56 8 0 3 0 88
1 81 4 0 3 0 93
0 27 3 0 2 0 95
0 27 3 0 3 0 94
1 27 3 0 2 0 94
But when I do this in a loop, the values do not change. I have created a loop like so...
while test "1"=="1"; do iostat -t proc; sleep 0.8; done
This does invoke iostat. But the values do now change. Here is the output
tty cpu
tin tout us ni sy in id
2 61 8 0 3 0 88
tty cpu
tin tout us ni sy in id
2 61 8 0 3 0 88
tty cpu
tin tout us ni sy in id
2 61 8 0 3 0 88
tty cpu
tin tout us ni sy in id
2 61 8 0 3 0 88
tty cpu
tin tout us ni sy in id
2 61 8 0 3 0 88
tty cpu
tin tout us ni sy in id
2 61 8 0 3 0 88
Why would the values not change? I am confused on this behavior...
Regards