LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Newbie (https://www.linuxquestions.org/questions/linux-newbie-8/)
-   -   CPU usage (https://www.linuxquestions.org/questions/linux-newbie-8/cpu-usage-506490/)

meniscus 12-01-2006 05:47 AM

CPU usage
 
Someone told me the following line to get the CPU temperature from the hardware monitoring command "sensors"

Code:

sensors | perl -ne 'if ( /CPU Temp:\s*\+(\d+)/ ) { print $1 . "\n"; }'



Im trying to get the the command line to show me just the CPU usage from the command "top"


Code:

top | perl ...............


I dont know what the code given to me means so cant modify it. Can anyone explain?








(This was received in another thread so i hope im not committing the crime of duplication here!
Its just that other thread gave me such cronic grief i gave up on it and hope to start afresh..)

matthewg42 12-01-2006 06:09 AM

You could try this:
Code:

top -n 1 |grep Cpu
There are probably better ways to get CPU usage than top though - top is quite heavy itself. One good measure of system load is the load average. See the uptime manual page.

I guess you're trying to write a system monitor eh? There are a lot already out there - maybe you can find some tips on how best to gather system info from their code. I like the name of this one. :D

meniscus 12-01-2006 06:47 AM

Yes. Thanks for that link. I didnt know there was a comprehensive one for linux.

Ive used speedfan and systems monitor in windows. Im tryin to get a similiar one up and running. Are ther any other good ones you know in linux?


All times are GMT -5. The time now is 04:05 AM.