Skip to content

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

@iori-yja

Description

@iori-yja

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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions