-----Original Message-----
From: ganglia-general-requ...@lists.sourceforge.net 
[mailto:ganglia-general-requ...@lists.sourceforge.net]
Sent: 14 August 2012 19:39
To: ganglia-general@lists.sourceforge.net
Subject: Ganglia-general Digest, Vol 75, Issue 6

Send Ganglia-general mailing list submissions to
        ganglia-general@lists.sourceforge.net

To subscribe or unsubscribe via the World Wide Web, visit
        https://lists.sourceforge.net/lists/listinfo/ganglia-general
or, via email, send a message with subject or body 'help' to
        ganglia-general-requ...@lists.sourceforge.net


   1. calculate cpu utilization with cpu time (crayon z)

----------------------------------------------------------------------

Message: 1
Date: Fri, 10 Aug 2012 17:00:36 +0800
From: crayon z <crayon....@gmail.com>
Subject: [Ganglia-general] calculate cpu utilization with cpu time
To: ganglia-general@lists.sourceforge.net
Message-ID:
        <CAF+Druhxf8R_o1y3kAEJ7etY=1c0uv1q0jrbhyptvr-alnz...@mail.gmail.com>
Content-Type: text/plain; charset="iso-8859-1"

Hi, all:

      I use ganglia to parse metrics from Host sFlow. The cpu metrics in
Host sFlow are in form of CPU time, however, I want to know how ganglia
calculate cpu utilization with cpu time.

Best Regards

--
Crayon Z
-------------- next part --------------
An HTML attachment was scrubbed...

------------------------------

Hi Crayon

>From a python module (there is similar code in procstat.py):

# clock ticks per second... jiffies (HZ)
JIFFIES_PER_SEC = os.sysconf('SC_CLK_TCK')

                cpu_time = time.time()
                proc_time = float(stat[2]) / JIFFIES_PER_SEC
                if not proc in last_val:
                        last_val[proc] = {}

                # do we have an old value to calculate with?
                if 'cpu_time' in last_val[proc]:

                        mymetrics[proc]['cpu'] = (100.0 * float(proc_time - 
last_val[proc]['proc_time'])) / float(cpu_time - last_val[proc]['cpu_time'])

stat[2] contains the number of jiffies executed by the process

so divide the number of jiffies executed by the length of the time period and 
multiply by 100.0 and by JIFFIES_PER_SEC

Regards

--
Paul Hewlett  X25250
http://www.theregister.co.uk/2012/06/25/rbs_natwest_what_went_wrong/
ARM Ltd
110 Fulbourn Road, Cambridge, CB1 9NJ
Tel: +44 (0)1223 405923
skype: paul-at-arm
www.arm.com




End of Ganglia-general Digest, Vol 75, Issue 6
**********************************************


-- IMPORTANT NOTICE: The contents of this email and any attachments are 
confidential and may also be privileged. If you are not the intended recipient, 
please notify the sender immediately and do not disclose the contents to any 
other person, use it for any purpose, or store or copy the information in any 
medium.  Thank you.


------------------------------------------------------------------------------
Live Security Virtual Conference
Exclusive live event will cover all the ways today's security and 
threat landscape has changed and how IT managers can respond. Discussions 
will include endpoint security, mobile security and the latest in malware 
threats. http://www.accelacomm.com/jaw/sfrnl04242012/114/50122263/
_______________________________________________
Ganglia-general mailing list
Ganglia-general@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/ganglia-general

Reply via email to