CPU Load data

onimkron

OSNN Senior Addict
Joined
17 Jan 2004
Messages
414
Hi all,

Just starting to get to grips with shell scripting...even though my knowledge of linux is pretty poor itself!

I want to output the cpu load into terminal, showing user, system, nice and idle. proc/stat contains the data I need, but it's in jiffes- I need the output to be in percentages, similarly to 'top' (but I'm trying not to use that command). I think I need to do some equations to convert the numbers into percentages, but I'm not entirely too sure. Following from that, I'm not even too sure how I could implement that into the script :squareeye:

Any help will be appreciated :nervous:
 
top :p

Then use grep to grab the parts you want from it.

man top
man grep
man uptime

uptime can be used for just the CPU load, and the current uptime.
 
I'm trying not to use that command, but instead, to just get the data from the proc/ directory. I know it sounds odd, but I'm trying to stay as far away as possible from top and ps :)
 
Hi,

Im not too sure exactly what you want here but I can give you a simple 'C' script that will convert the jiffies into percentages if you would like.[size=-1]
[/size]
 
can you attach the C script here :D i wanna see it just to get an idea
 
FishBoy said:
can you attach the C script here :D i wanna see it just to get an idea


google:

uptime for Linux

Find the source for it, and look at the code, this is a C program, which you can compile with gcc.
 

Members online

No members online now.

Latest profile posts

Also Hi EP and people. I found this place again while looking through a oooollllllldddd backup. I have filled over 10TB and was looking at my collection of antiques. Any bids on the 500Mhz Win 95 fix?
Any of the SP crew still out there?
Xie wrote on Electronic Punk's profile.
Impressed you have kept this alive this long EP! So many sites have come and gone. :(

Just did some crude math and I apparently joined almost 18yrs ago, how is that possible???
hello peeps... is been some time since i last came here.
Electronic Punk wrote on Sazar's profile.
Rest in peace my friend, been trying to find you and finally did in the worst way imaginable.

Forum statistics

Threads
62,015
Messages
673,494
Members
5,621
Latest member
naeemsafi
Back