----- Original Message ----- > From: "David Dimas" <[email protected]> > To: "Matt Wringe" <[email protected]> > Sent: Monday, March 28, 2016 11:50:13 PM > Subject: Re: How to calculate Percentage CPU Usage > > Hi, Matt. > how are you? > I am calculating Percentage CPU Usage with your help. > I am going to calculate Memory Usage now. > Can you please explain how to calculate this?
Memory usage is a 'gauge' type metric (eg it can increase or decrease at anytime) and is a quite different than the cpu usage which is a 'cumulative' metric (eg is always increasing). Think of it as the difference between a speedometer and an odometer in a car. For memory usage, its actually much easier. The memory usage value is how much memory (in bytes) is being used at that particular time. You don't need to do any fancy calculations, you can directly use it. > > Regards. > David > > On Mon, Mar 28, 2016 at 7:24 PM, David Dimas <[email protected]> > wrote: > > > Thanks a lot. > > I will calculate with your guide. > > Regards > > > > On Mon, Mar 28, 2016 at 4:33 PM, Matt Wringe <[email protected]> wrote: > > > >> ----- Original Message ----- > >> > From: "David Dimas" <[email protected]> > >> > To: [email protected] > >> > Sent: Friday, March 25, 2016 11:45:05 AM > >> > Subject: How to calculate Percentage CPU Usage > >> > > >> > Hello > >> > How are you? > >> > I am running curl command with your help successfully. > >> > > >> > Now I am going to calculate percentage CPU Usage. I have read this doc. > >> > [ > >> > > >> https://github.com/openshift/origin-metrics/blob/master/docs/hawkular_metrics.adoc#calcuating-percentage-cpu-usage > >> > ] > >> > > >> > In this guide, How can I get 'cpu/usage' and 'uptime'. > >> > I am running this command to get 'cpu/usage'. > >> > > >> > curl -k -H "Authorization: Bearer > >> iCm-Mglj1TvBPd_VoJesqoqIAbVM2psZcXrykyshBU" > >> > -H "Hawkular-tenant: sample" -X GET > >> > > >> https://hawkular-metrics.example.com/hawkular/metrics/counters/data?tags=descriptor_name:cpu/usage,pod_namespace:openshift-infra\&buckets=1\&start=`date > >> <https://hawkular-metrics.example.com/hawkular/metrics/counters/data?tags=descriptor_name:cpu/usage,pod_namespace:openshift-infra%5C&buckets=1%5C&start=date> > >> > -d -10minutes +%s%3N` | python -m json.tool > >> > > >> > Result is [{'min': 555115703.0, 'samples': 120, 'end': 1458837494033, > >> > 'median': 1391865412.971584, 'avg': 26785974599.89168, 'max': > >> > 144149182129.0, 'start': 1458836895027, 'empty': False}]. > >> > > >> > so I think 'cpu/usage' is 'avg' value from this result. it this right? > >> > >> The cpu/usage metric is a cumulative metric, which means that it always > >> increases unless the container has been restarted (at which point it > >> resets > >> back to zero). For your example, the 'avg' value will give you the average > >> over the 10 minute window you specified. Since the value is cumulative and > >> always increasing (assuming no restarts, to find how much as used in that > >> 10 minute window, you would take the max value minus the min value > >> > >> > After this, I calculated the percentage of a CPU core used with the > >> following > >> > function. > >> > %core = 'cpu/usage' / ('uptime' * 1000000) > >> > I am getting 0.0005564113359207296 as core result. Is this right value? > >> > >> Simplifying a bit taking the result from the example above (and assuming > >> no container restart) > >> > >> 'cpu/usage' as 'max' - 'min' = 143594066426 nanoseconds > >> cheating by taking 'uptime' as 'end' - 'start' milliseconds = 599006 > >> milliseconds = 599006000000 nanoseconds > >> > >> 143594066426 nanoseconds / 599006000000 nanoseconds = 0.239720581 = > >> 23.9720581% > >> > >> So in the last 10 minutes, that container used 23.97% of a cpu core > >> (assuming I didn't make some simple calculation error above) > >> > >> > > >> > Please give me a word of advice. I need your help. > >> > Best Regards > >> > > >> > _______________________________________________ > >> > dev mailing list > >> > [email protected] > >> > http://lists.openshift.redhat.com/openshiftmm/listinfo/dev > >> > > >> > > > > > _______________________________________________ dev mailing list [email protected] http://lists.openshift.redhat.com/openshiftmm/listinfo/dev
