Hi.
On Tue, Oct 10, 2006 at 09:47:01AM +0900, Mr. Suhas Ghosh wrote:
> Hi,
>  please some one tell me how to get the cpu usasge ?
>  Is it possible from proc to get  it?
Sure.
What OS you are talking about?
Linux? If you use Linux which kernel version?
2.4.x? 2.6.x? Which architecture? x86? x86_64? ia64?

>   I want to draw the graph of cpu usage of my machine. I am giving my
>   DS design.
>   So please help me how to  put  the  data  in to  it  from proc
>   or any other way.
The solution is in man 5 proc for Kernel 2.4.x:

[... snipp ...]
       /proc/stat
              kernel/system statistics.  Varies with architecture.  Common 
entries include:

              cpu  3357 0 4313 1362393
                     The amount of time, measured in units of USER_HZ (1/100ths 
of a second on most architectures), that the system spent in user mode, user 
mode with low priority (nice), system
                     mode, and the idle task, respectively.  The last value 
should be USER_HZ times the second entry in the uptime pseudo-file.

                     In Linux 2.6 this line includes three additional columns: 
iowait - time waiting for I/O to complete (since 2.5.41); irq -  time  
servicing  interrupts  (since  2.6.0-test4);
                     softirq - time servicing softirqs (since 2.6.0-test4).

[... snipp ...]

and for Kernel 2.6.x:

[... snipp ...]
       /proc/stat
              kernel/system statistics.  Varies with architecture.  Common 
entries include:

              cpu  3357 0 4313 1362393
                     The number of jiffies (1/100ths of a second) that the 
system spent in user mode, user mode with low priority (nice), system mode, and 
the idle task, respectively.  The  last
                     value should be 100 times the second entry in the uptime 
pseudo-file.
[... snipp ...]

>   I am not using SNMP.
Do you collect the data using a Shellscript? Perl?
Using the information from /proc/stat you should change
your "GAUGE" declarations to "COUNTER" (or save the last
values, fetch the new one and calculate the difference,
so it is far much easier to use COUNTERs).

If you change the GAUGEs to COUNTERs you can use:

 - with Kernel 2.4:

# Get user:nice:system:idle
cpudata=`grep '^cpu ' /proc/stat  | sed -e 's/^cpu */N:/' -e 's/ /:/g'`
rrdtool upadte $rrd/cpu.rrd $cpudata

 - with Kernel 2.6 (I will count the iowait,irq,softirq and values as system 
values):
cpudata=`grep '^cpu ' /proc/stat | awk '{print "N:"$2":"$3":"$4+$6+$7":"$5;}'`
rrdtool update $rrd/cpu.rrd $cpudata

HTH,

Andreas.

-- 
Dipl.-Ing. Andreas Maus             science+computing ag
System Administration               Hagellocher Weg 73
mail: [EMAIL PROTECTED]   72070 Tuebingen, Germany
tel.: +49 7071 9457 456             www.science-computing.de

-- Binary/unsupported file stripped by Ecartis --
-- Err : No filename to use for decode, file stripped.
-- Type: application/pgp-signature


--
Unsubscribe mailto:[EMAIL PROTECTED]
Help        mailto:[EMAIL PROTECTED]
Archive     http://lists.ee.ethz.ch/rrd-users
WebAdmin    http://lists.ee.ethz.ch/lsg2.cgi

Reply via email to