<div dir="ltr">Excellent, thank you!</div><br><div class="gmail_quote"><div dir="ltr">On Mon, Sep 19, 2016 at 3:38 AM Sepherosa Ziehau <<a href="mailto:sepherosa@gmail.com">sepherosa@gmail.com</a>> wrote:<br></div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">Hi,<br>
<br>
The bump upon each statclock is:<br>
((cur_systimer - prev_systimer) * systimer_freq) >> 32<br>
<br>
systimer_freq can be extracted from following sysctl in userspace:<br>
sysctl kern.cputimer.freq<br>
<br>
statclock is called at stathz frequency.<br>
<br>
Thanks,<br>
sephe<br>
<br>
<br>
On Mon, Sep 19, 2016 at 12:46 AM, Stuart Nelson <<a href="mailto:stuartnelson3@gmail.com" target="_blank">stuartnelson3@gmail.com</a>> wrote:<br>
> Hey all,<br>
><br>
> I'm following up on some work from this old thread for monitoring CPU time:<br>
> <a href="https://www.dragonflybsd.org/mailarchive/users/2010-04/msg00056.html" rel="noreferrer" target="_blank">https://www.dragonflybsd.org/mailarchive/users/2010-04/msg00056.html</a><br>
><br>
> The code I have is essentially the one shown in the link, but I'm attempting<br>
> to find the actual number of seconds spent in each state. I'm doing this by<br>
> dividing each value by clockrate.stathz, e.g.:<br>
><br>
><br>
> user += cp_t[cpu].cp_user / clockrate.stathz;<br>
><br>
><br>
> Relevant code is here:<br>
> <a href="https://github.com/stuartnelson3/node_exporter/blob/2b5a581942ac31b501438d402274100df1f7d3d6/collector/cpu_dragonfly.go#L50-L98" rel="noreferrer" target="_blank">https://github.com/stuartnelson3/node_exporter/blob/2b5a581942ac31b501438d402274100df1f7d3d6/collector/cpu_dragonfly.go#L50-L98</a><br>
><br>
> My question is about the units on struct members in kinfo_cputime (the<br>
> source of cp_user et al.). The values I'm getting out seem to be growing at<br>
> a rate that indicates I'm not looking at seconds, but something smaller.<br>
><br>
> I'm looking at the rate of change of cpu time on my personal machine running<br>
> dragonfly vs. a machine running linux. The implementation is the same: get<br>
> user time, divide by 100Hz to get the value in seconds, and find the rate of<br>
> change between two collections in fixed time window. The dragonfly rate of<br>
> change seems to be larger by about 2 orders of magnitude, which is why I'm<br>
> asking about the units.<br>
><br>
> For reference, the dragonfly node I'm looking at is reporting ~200 increase<br>
> per second in cpu time for user and sys with loadavg ~0.1%, whereas the<br>
> linux node is reporting values <10 with loadavg ~15%.<br>
><br>
> I'm improving dragonfly support for the node_exporter for Prometheus, a<br>
> metrics and monitoring solution that is used mostly in the linux community.<br>
> I'm assuming the linux implementation for finding cpu time in seconds is<br>
> correct, and it's also the implementation used for finding cpu seconds for<br>
> freebsd. It just struck me as unlikely that my old dell running dragonfly<br>
> would have a rate of change at a fraction of the load that was so<br>
> drastically different.<br>
><br>
> If there is anything I can clarify don't hesitate to write back!<br>
><br>
> Thanks,<br>
> Stuart<br>
><br>
><br>
<br>
<br>
<br>
--<br>
Tomorrow Will Never Die<br>
</blockquote></div>