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

userHz is hard-coded to 100 #61

Open
zegelin opened this issue Sep 27, 2017 · 10 comments
Open

userHz is hard-coded to 100 #61

zegelin opened this issue Sep 27, 2017 · 10 comments

Comments

@zegelin
Copy link

zegelin commented Sep 27, 2017

Running node_exporter inside a LX zone on Joyent's SmartOS (or their cloud platform, Triton) reports incorrect CPU stats.
SmartOS is based on Solaris, and LX zones are containers that enable running Linux application on Solaris.

LX zones report a USER_HZ value of 1000, which results in incorrect CPU stats being reported.

While it may be argued that SmartOS is incorrectly emulating the USER_HZ value (aka, it should report 100), I feel that procfs should query the value rather than have a hard-coded value to maintain compatibility across multiple platforms.

(And yes, I know that procfs did originally query for the value, but it was replaced with a constant for "reasons")

@brian-brazil
Copy link
Contributor

(And yes, I know that procfs did originally query for the value, but it was replaced with a constant for "reasons")

When this was last looked at, all supported platforms used 100.

@SuperQ
Copy link
Member

SuperQ commented Sep 28, 2017

The node_exporter was not designed to run in containers, it is a host system level tool.

@grobie
Copy link
Member

grobie commented Sep 28, 2017

So we removed it as the necessary cgo dependency forced too much overhead in crossbuilds. Could we come up with a simple solution here, like defining the constant in per architecture files and use build flags?

@mdlayher
Copy link
Contributor

We could probably generate the constant in x/sys/Unix and then not worry about it. Easier to push it upstream since the build infrastructure is there.

@zegelin
Copy link
Author

zegelin commented Sep 29, 2017

@SuperQ LX zones should be considered to be similar to full VMs rather than linux containers. We're not talking about LXC or Docker here.

@brian-brazil
Copy link
Contributor

Could we come up with a simple solution here, like defining the constant in per architecture files and use build flags?

The setup here is sufficiently weird that the setting may not be the one we expect for the architecture.

Which architecture is this?

@grobie
Copy link
Member

grobie commented Oct 1, 2017

I should have said per operating system files. It seems SmartOS will just be recognized as Solaris in golang, and I don't know whether all Solaris variants use USER_HZ=1000.

We could re-introduce C code for the syscall in something like user_hz_solaris.go and continue to use the hardcoded value in user_hz.go.

@zegelin Do you know how to query for the USER_HZ value in solaris?

@brian-brazil
Copy link
Contributor

USER_HZ is a Linux thing, Solaris doesn't have it.

@grobie
Copy link
Member

grobie commented Oct 1, 2017

Oh, now I see the issue I guess. From the perspective of the program running in the LX zone, the OS will be Linux.

I'm very hesitant of introducing a C dependency just for that exception. @zegelin Does LX provide any hint about the environment we could query for without a systemcall?

@zegelin
Copy link
Author

zegelin commented Oct 2, 2017

@brian-brazil

Which architecture is this?

x86_64

@grobie
Exactly. Processes running in a LX zone think they are running on Linux even though the host is actually Solaris.

Does LX provide any hint about the environment we could query for without a systemcall?

There is a sysctl that returns:
kernel.osrelease = BrandZ virtual linux

LX emulates /proc:

# cat /proc/sys/kernel/osrelease 
BrandZ virtual linux

bobrik pushed a commit to bobrik/procfs that referenced this issue Jan 14, 2023
bobrik pushed a commit to bobrik/procfs that referenced this issue Jan 14, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

6 participants