Linux Console CPU Load Monitor?

Linux Console CPU Load Monitor?

Author
Discussion

TheExcession

Original Poster:

11,669 posts

251 months

Wednesday 8th September 2004
quotequote all
Any Linux bods out there know how I can run a CPU load monitor from a console?

I need to stream out the current time and cpu load to a text file about 10 times per second.

Can top do this?

Ideally I'd also like to dump the names of say the busiest 5 processes at the same time.

thanks
Ex

rebelstar

1,146 posts

245 months

Wednesday 8th September 2004
quotequote all
10 times per second? top is probably the wrong tool for the job, although if you want to go down that route top -n 1 is the first step (only displays the information once, then exits). You can also do -d

You might find the information you're looking for in /proc somewhere.

JamieBeeston

9,294 posts

266 months

Wednesday 8th September 2004
quotequote all
w

this will show the current uptime, load and time.

combine this with 'time' and you have what you need.

10 times a second, .. just write a perl / bash script.

be warned, simply by doing this,you will increase your load


7:24PM up 1 day, 1:20, 2 users, load averages: 748.94, 663.73, 358.47

rebelstar

1,146 posts

245 months

Wednesday 8th September 2004
quotequote all
JamieBeeston said:
7:24PM up 1 day, 1:20, 2 users, load averages: 748.94, 663.73, 358.47


JamieBeeston

9,294 posts

266 months

Wednesday 8th September 2004
quotequote all
rebelstar said:

JamieBeeston said:
7:24PM up 1 day, 1:20, 2 users, load averages: 748.94, 663.73, 358.47





Who says you cant run linux on a Wrist Watch :P

rebelstar

1,146 posts

245 months

Wednesday 8th September 2004
quotequote all
JamieBeeston said:

rebelstar said:


JamieBeeston said:
7:24PM up 1 day, 1:20, 2 users, load averages: 748.94, 663.73, 358.47







Who says you cant run linux on a Wrist Watch :P


I know IBM/Citizen did one (loved the xclock display!). IIRC, battery life was around 2 hours.

Bodo

12,375 posts

267 months

Wednesday 8th September 2004
quotequote all
TheExcession said:
Any Linux bods out there know how I can run a CPU load monitor from a console?

I need to stream out the current time and cpu load to a text file about 10 times per second.

Can top do this?

Oh

bodo@bulldog:~> top -b -d 00.10 -n 10 >top.txt

this generated a 121.1kb-text file (called top.txt in the home dir) in one second, because there are 101 processes on my desktop-pc. Find explaining stuff to the options below.
man top said:
-b : Batch mode operation
Starts top in 'Batch mode', which could be useful for sending output from
top to other programs or to a file. In this mode, top will not accept
input and runs until the iterations limit you've set with the '-n'
command-line option or until killed.


-d : Delay time interval as: -d ss.tt (seconds.tenths)
Specifies the delay between screen updates, and overrides the correspond­
ing value in one's personal configuration file or the startup default.
Later this can be changed with the 'd' or 's' interactive commands.

Fractional seconds are honored, but a negative number is not allowed. In
all cases, however, such changes are prohibited if top is running in
'Secure mode', except for root (unless the 's' command-line option was
used). For additional information on 'Secure mode' see topic 5a. SYSTEM
Configuration File.

-n : Number of iterations limit as: -n number
Specifies the maximum number of iterations, or frames, top should produce
before ending.


TheExcession said:

Ideally I'd also like to dump the names of say the busiest 5 processes at the same time.

thanks
Ex
I'm sure this is possible too, but I couldn't be arsed to read the entire manual. RTFM yerself

Mr E

21,622 posts

260 months

Thursday 9th September 2004
quotequote all
rebelstar said:

JamieBeeston said:
7:24PM up 1 day, 1:20, 2 users, load averages: 748.94, 663.73, 358.47





indeed....

156 days and counting.

rebelstar

1,146 posts

245 months

Thursday 9th September 2004
quotequote all
Mr E said:


rebelstar said:



JamieBeeston said:
7:24PM up 1 day, 1:20, 2 users, load averages: 748.94, 663.73, 358.47









indeed....

156 days and counting.



I've got an old laptop running slackware linux - the jiffies have now rolled over (currently 500 days uptime)

11:33:21 up 3 days, 17:47, 3 users, load average: 0.50, 0.87, 0.94
USER TTY FROM LOGIN@ IDLE JCPU PCPU WHAT
adam tty1 - 27Apr03 500days 2.53s 0.01s /bin/sh /usr/X11

>> Edited by rebelstar on Thursday 9th September 11:34

JamieBeeston

9,294 posts

266 months

Thursday 9th September 2004
quotequote all
I had an old Compaq, 997 days iirc, it died as I installed Tuxtime on it to monitor and track the uptime, and .. yes, you guessed it, Tuxtime crashed it

it went crazy and spawed thousands of connections, resulting in no more files open.

Fun!

Bodo

12,375 posts

267 months

Thursday 9th September 2004
quotequote all
JamieBeeston said:

Fun!



TheExcession

Original Poster:

11,669 posts

251 months

Thursday 9th September 2004
quotequote all
thanks for the info guys,

hasn't really helped me sort the proble tho

rebelstar

1,146 posts

245 months

Saturday 11th September 2004
quotequote all
TheExcession said:
thanks for the info guys,

hasn't really helped me sort the proble tho


Now that we've done the "my uptime is bigger than yours"...

I'll hack something together for you, but you'll need to tell me what kernel you're running (since the /proc filesystem changes between major releases).

TheExcession

Original Poster:

11,669 posts

251 months

Sunday 12th September 2004
quotequote all
rebelstar said:

TheExcession said:
thanks for the info guys,

hasn't really helped me sort the proble tho



Now that we've done the "my uptime is bigger than yours"...

I'll hack something together for you, but you'll need to tell me what kernel you're running (since the /proc filesystem changes between major releases).


Cheers man - you're a star!

It's

Red Hat Linux release 6.2 (Zoot)
Kernel 2.2.14-5.0smp on an i686

muchos gassios

best
Ex