[Gllug] hourly/daily rate for linux systems admins?

Steve Parker steve at steve-parker.org
Tue Nov 23 23:26:05 UTC 2010


On 23/11/10 22:23, Nix wrote:
> On 23 Nov 2010, Karanbir Singh told this:
>    
>> As another example, when asked to find per-process blockdev i/o rate,
>> only 1 out of 8 people actually looked in /proc/<id>/; a couple
>>      
> I'm sorry, where is this? I just hunted for it and can't see anything
> relating to per-process blockdev I/O there. I had no idea Linux tracked
> such things on a per-process basis (in fact I can remember patches to do
> such things being rejected in the past).
>
> Of course what I do now is dig into the source tree, and find that the
> third-from-last /proc/{pid}/stat entry is the per-task I/O delay figure,
> which may be what you referred to. This is seriously obscure stuff: it
> was added in 2006, but the only distro which appears to have packaged
> the userspace side of this is OpenSUSE. I can't find any sign of an
> upstream source tree at all.
>    
I wrote this very short script a few months ago to identify processes by 
state and CPU, it works on RHEL5 (2.6.18):

#!/bin/sh
pid=${1}
if [ ! -z "$pid" ]; then
   read pid tcomm state ppid pgid sid tty_nr tty_pgrp flags min_flt 
cmin_flt maj_flt cmaj_flt utime stime cutime cstime priority nice 
num_threads start_time vsize mm rsslim start_code end_code start_stack 
eis eip pending blocked sigign sigcatch wchan oul1 oul2 exit_signal cpu 
rt_priority policy ticks < /proc/$pid/stat
   echo "Pid $pid $tcomm is in state $state on CPU $cpu"
fi

Which is general-purpose enough to add $blocked (and all sorts of other 
detail, like $num_threads) to the output if required. I've found it 
quite handy a few times recently - share and enjoy! It takes its 
definitions from o_task_stat in linux-2.6.18.x86_64/fs/proc/array.c.
> Anyone who correctly answers this question is a kernel deity, or
> Shailabh Nagar :)
>    
I am neither. Like you, I just read the source. I wouldn't expect anyone 
to come up with this kind of level of detail in an interview situation 
though.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mailman.lug.org.uk/pipermail/gllug/attachments/20101123/9ab02855/attachment.html>
-------------- next part --------------
-- 
Gllug mailing list  -  Gllug at gllug.org.uk
http://lists.gllug.org.uk/mailman/listinfo/gllug


More information about the GLLUG mailing list