[lnkForumImage]
TotalShareware - Download Free Software

Confronta i prezzi di migliaia di prodotti.
Asp Forum
 Home | Login | Register | Search 


 

Forums >

comp.lang.ruby

/proc/PID/stat documentation?

Alex Young

1/6/2007 11:42:00 AM

Not strictly a Ruby question, but I figure someone around here will know
the answer...

I'm using the sys-proctable gem to gather process load information on a
Debian machine (kernel 2.6.15 if it's relevant), because I'm trying to
do some load-balancing between machines and processes on those machines.
However, I can't seem to find any documentation on what the numbers
returned actually represent - specifically, the units of the utime,
stime, cutime and cstime fields, and precisely what they represent.

The numbers are lifted straight from /proc/PID/stat, so any
documentation on that would be handy. I've checked the documentation in
the kernel source tree, but it was singularly unenlightening - unless I
missed something.

For example:

-- konsole_ps.rb --

require 'proctable'
require 'yaml'
konsole = Sys::ProcTable.ps.find{|p| p.name == 'konsole'}
y({'utime' => konsole.utime, 'stime' => konsole.stime, 'cutime' =>
konsole.cutime, 'cstime' => konsole.cstime})

-- output --
---
cutime: 0
utime: 82
stime: 9
cstime: 0

I don't understand what the numbers that come out represent, and I can't
really tie them up with what comes out of `ps`. Can anyone point me in
the right direction?

--
Alex

14 Answers

Sylvain Joyeux

1/6/2007 11:56:00 AM

0

Try "man 5 proc", but I'm afraid it should be more or less the same
information than in the kernel docs ...

Sylvain Joyeux

Cian

1/6/2007 12:11:00 PM

0

On 1/6/07, Sylvain Joyeux <sylvain.joyeux@polytechnique.org> wrote:
> Try "man 5 proc", but I'm afraid it should be more or less the same
> information than in the kernel docs ...
>
Yep, the proc(5) manpage explains what the *time variables mean.

The units are 'jiffies', which appear to be Linux kernel scheduler run
time intervals. There's an explanation of what jiffies are at

http://kerneltrap.org...

Cian

Alex Young

1/6/2007 12:27:00 PM

0

Cian wrote:
> On 1/6/07, Sylvain Joyeux <sylvain.joyeux@polytechnique.org> wrote:
>> Try "man 5 proc", but I'm afraid it should be more or less the same
>> information than in the kernel docs ...
>>
> Yep, the proc(5) manpage explains what the *time variables mean.
>
> The units are 'jiffies', which appear to be Linux kernel scheduler run
> time intervals. There's an explanation of what jiffies are at
>
> http://kerneltrap.org...
>
Thanks - that's exactly what I was after.

--
Alex

M. Edward (Ed) Borasky

1/6/2007 5:22:00 PM

0

Alex Young wrote:
> Not strictly a Ruby question, but I figure someone around here will
> know the answer...
>
> I'm using the sys-proctable gem to gather process load information on
> a Debian machine (kernel 2.6.15 if it's relevant), because I'm trying
> to do some load-balancing between machines and processes on those
> machines. However, I can't seem to find any documentation on what the
> numbers returned actually represent - specifically, the units of the
> utime, stime, cutime and cstime fields, and precisely what they
> represent.
>
> The numbers are lifted straight from /proc/PID/stat, so any
> documentation on that would be handy. I've checked the documentation
> in the kernel source tree, but it was singularly unenlightening -
> unless I missed something.
>
> For example:
>
> -- konsole_ps.rb --
>
> require 'proctable'
> require 'yaml'
> konsole = Sys::ProcTable.ps.find{|p| p.name == 'konsole'}
> y({'utime' => konsole.utime, 'stime' => konsole.stime, 'cutime' =>
> konsole.cutime, 'cstime' => konsole.cstime})
>
> -- output --
> ---
> cutime: 0
> utime: 82
> stime: 9
> cstime: 0
>
> I don't understand what the numbers that come out represent, and I
> can't really tie them up with what comes out of `ps`. Can anyone
> point me in the right direction?
>
utime is the amount of time spent in user mode. If it's being
accumulated correctly, it will include time from both user and "nice"
mode. stime is the amount of time spent in system or kernel mode. If
it's being accumulated correctly, it will include system, irq and
softirq time.

cutime and cstime are the cumulative values of utime and stime,
respectively. When a process forks (clones) a child process (thread),
said child accumulates its own utime and stime. When the process exits,
its accumulated utime gets added back into the parent's cutime, and its
stime gets added back into the parent's cstime. Have a look at the
values for cutime and cstime for the "init" process -- they will be huge
because a parentless process cannot exist -- if a process's parent dies,
"init" adopts it. :)

Now on to "ps". "ps" lives in the "procps" package. It, for some reason,
lumps system and user time together. "ps" converts (utime+stime) to TIME
and (cutime+cstime) to CTIME. It shouldn't do that, but it does and IIRC
the developer of "procps" flat out refuses to change it. "top" is also
in "procps".

One final note: if you really need to know the next layer of detail down
to manage your server, send me an email off list and I'll point you to
some resources. I've never really seen a lot of documentation on this
other than the excellent O'Reilly book, "Understanding The Linux
Kernel", which isn't really written for server managers. Most of the
other books either have just the "top" layer (pun intended) or are
written around a specific tool set.

--
M. Edward (Ed) Borasky, FBG, AB, PTA, PGS, MS, MNLP, NST, ACMC(P)
http://borasky-research.blo...

If God had meant for carrots to be eaten cooked, He would have given rabbits fire.


John

6/27/2007 2:03:00 PM

0


"Christian Williamson" <c.willi@verizon.net> wrote in message
news:gZqgi.2193$s%.159@trnddc02...
> SPQRROMANS@aol.com wrote:
>> As a result of Mr.Bush I am no longer a Republican and I would urge
>> all Republicans to go Independent. WRONG ON IRAQ AND WRONG ON
>> IMMIGRATION.
>>
>
> Actually, no, there have been worse presidents. Jimmy Carter comes to mind
> immediately.

Why? Did he lie us into the verge of bankruptcy like Reagan or Bush?


Salad

6/27/2007 4:33:00 PM

0

si wrote:

> "Christian Williamson" <c.willi@verizon.net> wrote in message
> news:gZqgi.2193$s%.159@trnddc02...
>
>>SPQRROMANS@aol.com wrote:
>>
>>>As a result of Mr.Bush I am no longer a Republican and I would urge
>>>all Republicans to go Independent. WRONG ON IRAQ AND WRONG ON
>>>IMMIGRATION.
>>>
>>
>>Actually, no, there have been worse presidents. Jimmy Carter comes to mind
>>immediately.
>
>
> Carter may not have been a great president - but Bush is not fit to shine
> his shoes.
>

Carter inherited the years immediately following the Vietnam War. It
will be just as bad for the president that is in office immedicately
following bush's Iraqi Invasion folly.

The only "bads" that I've heard about Carter were the high interest
rates (American recovery from Vietnam), an extremely short lived
increase in gas prices, and not succeeding in recovering the hostages in
Iran. I suppose if he'd bombed Iran he'd be a hero now.


si

6/27/2007 7:30:00 PM

0


"salad" <oil@vinegar.com> wrote in message
news:7jwgi.1573$zA4.449@newsread3.news.pas.earthlink.net...
> si wrote:
>
>> "Christian Williamson" <c.willi@verizon.net> wrote in message
>> news:gZqgi.2193$s%.159@trnddc02...
>>
>>>SPQRROMANS@aol.com wrote:
>>>
>>>>As a result of Mr.Bush I am no longer a Republican and I would urge
>>>>all Republicans to go Independent. WRONG ON IRAQ AND WRONG ON
>>>>IMMIGRATION.
>>>>
>>>
>>>Actually, no, there have been worse presidents. Jimmy Carter comes to
>>>mind immediately.
>>
>>
>> Carter may not have been a great president - but Bush is not fit to shine
>> his shoes.
>
> Carter inherited the years immediately following the Vietnam War. It will
> be just as bad for the president that is in office immedicately following
> bush's Iraqi Invasion folly.
>
> The only "bads" that I've heard about Carter were the high interest rates
> (American recovery from Vietnam), an extremely short lived increase in gas
> prices, and not succeeding in recovering the hostages in Iran. I suppose
> if he'd bombed Iran he'd be a hero now.

Seems like Americans like their presidents macho - Carter simply didn't kill
enough people.


GW Chimpzilla's Eye-Rack Neocon Utopia

6/27/2007 9:02:00 PM

0

Christian Williamson wrote:

> SPQRROMANS@aol.com wrote:
>> As a result of Mr.Bush I am no longer a Republican and I would urge
>> all Republicans to go Independent. WRONG ON IRAQ AND WRONG ON
>> IMMIGRATION.
>>
>
> Actually, no, there have been worse presidents. Jimmy Carter comes to
> mind immediately.

Polls say otherwise. AWOL Bush 26%, Jimmy Carter 28% at their lowest. And Bush
still has a year and a half to go lower. How low can he go?

--
There are only two kinds of Republicans: Millionaires and fools.

Nebuchadnezzar II

6/28/2007 2:26:00 AM

0

"salad" <oil@vinegar.com> wrote in message
news:7jwgi.1573$zA4.449@newsread3.news.pas.earthlink.net...
> si wrote:
>
>> "Christian Williamson" <c.willi@verizon.net> wrote in message
>> news:gZqgi.2193$s%.159@trnddc02...
>>
>>>SPQRROMANS@aol.com wrote:
>>>
>>>>As a result of Mr.Bush I am no longer a Republican and I would urge
>>>>all Republicans to go Independent. WRONG ON IRAQ AND WRONG ON
>>>>IMMIGRATION.
>>>>
>>>
>>>Actually, no, there have been worse presidents. Jimmy Carter comes to
>>>mind immediately.
>>
>>
>> Carter may not have been a great president - but Bush is not fit to
>> shine his shoes.
>
> Carter inherited the years immediately following the Vietnam War. It
> will be just as bad for the president that is in office immedicately
> following bush's Iraqi Invasion folly.
>
> The only "bads" that I've heard about Carter were the high interest
> rates (American recovery from Vietnam), an extremely short lived
> increase in gas prices, and not succeeding in recovering the hostages
> in Iran. I suppose if he'd bombed Iran he'd be a hero now.

What never ceases to amaze me is the myths that persist to this day
about Carter and Raygun. Carter inherited stagflation which actually
started in 1968, almost a decade before he became President. Paul
Volcker is the man that deserves the credit for ending stagflation which
saw a significant downward trend early in the Raygun administration.
Volcker was appointed by Carter, not Raygun. The only thing Raygun was
smart enough to do was keep Volcker around. The myth holders would have
you believe Raygunomics ended stagflation, but this only creates another
myth. Paul Volcker ended stagflation through tightening monetary
policies and supply side economics that Raygun touted proved to be a
complete failure.


Christian Williamson

6/28/2007 10:51:00 AM

0

John wrote:
> "Christian Williamson" <c.willi@verizon.net> wrote in message
> news:gZqgi.2193$s%.159@trnddc02...
>> SPQRROMANS@aol.com wrote:
>>> As a result of Mr.Bush I am no longer a Republican and I would urge
>>> all Republicans to go Independent. WRONG ON IRAQ AND WRONG ON
>>> IMMIGRATION.
>>>
>> Actually, no, there have been worse presidents. Jimmy Carter comes to mind
>> immediately.
>
> Why? Did he lie us into the verge of bankruptcy like Reagan or Bush?

Be more specific about the lying. What are you talking about? Or is this
just another leftist wishing things were so?

Here's something: Carter spied on an American citizen in 1977 without a
warrant. Does that bother you at all?