Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

cpu_dragonfly.go's cpu time doesn't seem to be in second against its name (node_cpu_seconds_total) #1129

Closed
iori-yja opened this issue Oct 26, 2018 · 3 comments

Comments

@iori-yja
Copy link
Contributor

Host operating system: output of uname -a

DragonFly tech-y09-dfly 5.3-DEVELOPMENT DragonFly v5.3.0.18494.gc70d4-DEVELOPMENT #1: Fri Aug 24 12:27:12 JST 2018 root@tech-y09-dfly:/usr/obj/usr/src/sys/X86_64_GENERIC x86_64

node_exporter version: output of node_exporter --version

Installed from source.
iori@tech-y09-dfly% git log | head -n 3
commit 7519967
Author: Ben Kochie superq@gmail.com
Date: Sat Oct 20 08:21:51 2018 +0200
iori@tech-y09-dfly% node_exporter --version
node_exporter, version (branch: , revision: )
build user:
build date:
go version: go1.10.3

node_exporter command line flags

node_exporter (default)

Are you running node_exporter in Docker?

No

What did you do that produced an error?

Just run.

What did you expect to see?

The node_cpu_seconds_total metrics are in seconds.

What did you see instead?

The total sum of irate of reported metrics are around 40ms which is too smaller than expected (this should be 1 second * ncpu).

The cause

According to cpu_dragonfly.go, the metrics are extracted from kern.cputime and divided by the frequency of kern.cputimer.freq.
However, the comment in the source code states that it counts in microseconds.
https://github.com/DragonFlyBSD/DragonFlyBSD/blob/master/sys/kern/kern_clock.c#L118

The comment is consistent with a shell script as following:

iori@tech-y09-dfly% @ tim=`sysctl kern.cp_time | awk '{print $2 + $3 + $4 + $5 + $6}'` && sleep 1 && @ tim2=`sysctl kern.cp_time | awk '{print $2 + $3 + $4 + $5 + $6}'` ; @ dur = $tim2 - $tim ; echo $dur
4003724

This machine has four cores, so the timer goes around 1000k ticks per CPU in a second, which implies the kernel counts it in microseconds.

I'd like to know why they are divided by that frequency instead of 1/micros.

@discordianfish
Copy link
Member

This was introduced in #310 - @stuartnelson3 Can you clarify this? No clue about Drgonflybsd unfortunately..

@stuartnelson3
Copy link
Contributor

I asked that question (a looong time ago 😄 ) on the dfly mailing list:

http://lists.dragonflybsd.org/pipermail/users/2016-September/356968.html

It's something I could have easily done wrong. At the time, it seemed to get the right values on my system, but it could (and seems to) be wrong.

@iori-yja
Copy link
Contributor Author

iori-yja commented Nov 2, 2018

Thank you, @stuartnelson3... it is curious that the answer turned out wrong.

I have submitted a Pull request #1140 which works on my machine. I'm happy if you would be kind to check this on your environment.

iori-yja pushed a commit to iori-yja/node_exporter that referenced this issue Nov 2, 2018
Signed-off-by: iori-yja <fivio.11235813@gmail.com>
iori-yja pushed a commit to iori-yja/node_exporter that referenced this issue Nov 2, 2018
Signed-off-by: iori-yja <fivio.11235813@gmail.com>
iori-yja added a commit to iori-yja/node_exporter that referenced this issue Nov 16, 2018
Signed-off-by: iori-yja <fivo.11235813@gmail.com>
discordianfish pushed a commit that referenced this issue Nov 17, 2018
* Change Dfly's CPU counting frequency, see: #1129

Signed-off-by: iori-yja <fivio.11235813@gmail.com>

* Convert Dfly's CPU unit into second

Signed-off-by: iori-yja <fivio.11235813@gmail.com>

* Check BSD's mib which accounts for swap size; see #1127

Signed-off-by: iori-yja <fivo.11235813@gmail.com>

* fix swap check code

Signed-off-by: iori-yja <fivo.11235813@gmail.com>
SuperQ pushed a commit that referenced this issue Nov 21, 2018
* Change Dfly's CPU counting frequency, see: #1129

* Convert Dfly's CPU unit into second

Signed-off-by: iori-yja <fivo.11235813@gmail.com>
oblitorum pushed a commit to shatteredsilicon/node_exporter that referenced this issue Apr 9, 2024
* Change Dfly's CPU counting frequency, see: prometheus#1129

Signed-off-by: iori-yja <fivio.11235813@gmail.com>

* Convert Dfly's CPU unit into second

Signed-off-by: iori-yja <fivio.11235813@gmail.com>

* Check BSD's mib which accounts for swap size; see prometheus#1127

Signed-off-by: iori-yja <fivo.11235813@gmail.com>

* fix swap check code

Signed-off-by: iori-yja <fivo.11235813@gmail.com>
oblitorum pushed a commit to shatteredsilicon/node_exporter that referenced this issue Apr 9, 2024
* Change Dfly's CPU counting frequency, see: prometheus#1129

Signed-off-by: iori-yja <fivio.11235813@gmail.com>

* Convert Dfly's CPU unit into second

Signed-off-by: iori-yja <fivio.11235813@gmail.com>

* Check BSD's mib which accounts for swap size; see prometheus#1127

Signed-off-by: iori-yja <fivo.11235813@gmail.com>

* fix swap check code

Signed-off-by: iori-yja <fivo.11235813@gmail.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants