CentOS - linux related question

Nerigal

Verified User
Joined
Jul 6, 2009
Messages
124
hi,

here a technical question about execution / result of a command line in bash

i try to get the total CPU usage on my server by doing
echo top -n 1 -b | grep Cpu | tr -d '%id,' | awk '{print $5}'

but the result is always the same as the first time you use this command or what ever command. i tried sar, vmstat, iostat, sysstat, and i got the same problem.

any idea to get the result updated ?
 
What is your plan to do with this script? How are you going to use it.
 
using it in a script to send it by email by doing the revert result of idle % so 100 - idle % to give the total cpu usage and send it by email but i noticed the problem in command line execution so what ever pipe it to a file or email the result of the command is always the same as the first execution

the question is how get the result updated.
 
Last edited:
it is a good start but it's not enough accurate for my needs
i guess i will have to craft something myself from /proc/stat values.
 
Then ask on a linux forum. This is a forum for directadmin control panel...not programming...
 
Back
Top