• This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn more.

CPU Load data


OSNN Senior Addict
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:


Political User
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.


OSNN Senior Addict
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 :)


OSNN One Post Wonder

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]


Political User
FishBoy said:
can you attach the C script here :D i wanna see it just to get an idea


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 posts

Latest profile posts

Perris Calderon wrote on Electronic Punk's profile.
Ep, glad to see you come back and tidy up...did want to ask a one day favor, I want to enhance my resume , was hoping you could make me administrator for a day, if so, take me right off since I won't be here to do anything, and don't know the slightest about the board, but it would be nice putting "served administrator osnn", if can do, THANKS

Been running around Quora lately, luv it there https://tinyurl.com/ycpxl
Electronic Punk wrote on Perris Calderon's profile.
All good still mate?
Hello, is there anybody in there? Just nod if you can hear me ...
What a long strange trip it's been. =)

Forum statistics

Latest member