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

memory_bsd.go has a sysctl which isn't available in recent DragonflyBSD (not sure about previous one) #1127

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

Comments

@iori-yja
Copy link
Contributor

iori-yja commented Oct 26, 2018

Summary

This error shown below is due to vm.swap_total sysctl that isn't available in recent DragonflyBSD (I am not sure about prior one, but FreeBSD has). I have changed the code as following patch which makes it works:

iori@tech-y09-dfly% git diff
diff --git a/collector/memory_bsd.go b/collector/memory_bsd.go
index 8c7265e..268dccc 100644
--- a/collector/memory_bsd.go
+++ b/collector/memory_bsd.go
@@ -98,7 +98,7 @@ func NewMemoryCollector() (Collector, error) {
                        {
                                name:        "swap_size_bytes",
                                description: "Total swap memory size",
-                               mib:         "vm.swap_total",
+                               mib:         "vm.swap_size",
                                dataType:    bsdSysctlTypeUint64,
                        },
                        // Descriptions via: top(1)

My question is that whether should I make PR to diverge Dfly's memory.go from memory_bsd.go. If this is applicable for other version of DragonflyBSD, I think it is worth to make them separate. If it is only seen in recent version of Dfly, I am not sure what to handle this difference. Please give me some hints to make a PR without regression.

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?

Wait for a couple of seconds.

What did you expect to see?

No errors

What did you see instead?

iori@tech-y09-dfly% node_exporter
INFO[0000] Starting node_exporter (version=, branch=, revision=)  source="node_exporter.go:82"
INFO[0000] Build context (go=go1.10.3, user=, date=)     source="node_exporter.go:83"
INFO[0000] Enabled collectors:                           source="node_exporter.go:90"
INFO[0000]  - boottime                                   source="node_exporter.go:97"
INFO[0000]  - cpu                                        source="node_exporter.go:97"
INFO[0000]  - exec                                       source="node_exporter.go:97"
INFO[0000]  - filesystem                                 source="node_exporter.go:97"
INFO[0000]  - loadavg                                    source="node_exporter.go:97"
INFO[0000]  - meminfo                                    source="node_exporter.go:97"
INFO[0000]  - netdev                                     source="node_exporter.go:97"
INFO[0000]  - textfile                                   source="node_exporter.go:97"
INFO[0000]  - time                                       source="node_exporter.go:97"
INFO[0000] Listening on :9100                            source="node_exporter.go:111"
ERRO[0001] ERROR: meminfo collector failed after 0.000037s: couldn't get memory: no such file or directory  source="collector.go:132" 
ERRO[0006] ERROR: meminfo collector failed after 0.000034s: couldn't get memory: no such file or directory  source="collector.go:132"
ERRO[0011] ERROR: meminfo collector failed after 0.000037s: couldn't get memory: no such file or directory  source="collector.go:132"

@iori-yja iori-yja changed the title memory_bsd.go has a sysctl which isn't available in recent DragonflyBSD (not sure about previous) memory_bsd.go has a sysctl which isn't available in recent DragonflyBSD (not sure about previous one) Oct 26, 2018
@discordianfish
Copy link
Member

Yeah.. good question. Unfortunately I don't use BSD and not sure about the best way forward. But yeah in general, if we need a different behavior in dragonfly than in freebsd, we'd need separate files with build flags to build only the right one.

@iori-yja
Copy link
Contributor Author

iori-yja commented Oct 30, 2018

One of the possible solutions is to add a tiny logic to check the availability of data with vm.swap_total and use vm.swap_size if not. I think that's very very easy, but I couldn't see such workaround in other collectors. 🤔

@iori-yja
Copy link
Contributor Author

iori-yja commented Oct 30, 2018

if we need a different behavior in dragonfly than in freebsd, we'd need separate files with build flags to build only the right one.

That's good because it keeps them simple. On the other hand, keeping them together has a good point for Dragonfly users because they may stay updated thanks to many FreeBSD users.

@discordianfish
Copy link
Member

I think a simple check to use either swap_total or swap_size is probably fine.. But still, not using BSD and not knowing how dragonfly compares to freebsd I don't really have a opinion on that.

@iori-yja
Copy link
Contributor Author

iori-yja commented Nov 7, 2018

Thank you for your advice. I think swap_size is the size in total: https://bugs.dragonflybsd.org/issues/1805#note-1, which means it is very similar to swap_total.

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>
@iori-yja
Copy link
Contributor Author

This issue should be closed because it has merged! Thank you 🙏 🙏

#1149

@isavcic
Copy link

isavcic commented Dec 18, 2018

Hey guys, I still see this error on FreeBSD 12.0-RELEASE.

root@freebsd:~/go/src/github.com/prometheus/node_exporter # ./node_exporter
INFO[0000] Starting node_exporter (version=0.17.0, branch=master, revision=7c960fd68365e9bbdb14cf140fc1d26d4c27333a)  source="node_exporter.go:156"
INFO[0000] Build context (go=go1.11, user=root@freebsd, date=20181218-11:33:20)  source="node_exporter.go:157"
INFO[0000] Enabled collectors:                           source="node_exporter.go:97"
INFO[0000]  - boottime                                   source="node_exporter.go:104"
INFO[0000]  - cpu                                        source="node_exporter.go:104"
INFO[0000]  - exec                                       source="node_exporter.go:104"
INFO[0000]  - filesystem                                 source="node_exporter.go:104"
INFO[0000]  - loadavg                                    source="node_exporter.go:104"
INFO[0000]  - meminfo                                    source="node_exporter.go:104"
INFO[0000]  - netdev                                     source="node_exporter.go:104"
INFO[0000]  - textfile                                   source="node_exporter.go:104"
INFO[0000]  - time                                       source="node_exporter.go:104"
INFO[0000] Listening on :9100                            source="node_exporter.go:170"
ERRO[0014] ERROR: meminfo collector failed after 0.000062s: couldn't get memory: no such file or directory  source="collector.go:132"

Built from master today.

@isavcic
Copy link

isavcic commented Dec 18, 2018

Should I open a new ticket, since it relates to FreeBSD?

@discordianfish
Copy link
Member

Interesting. So this was changed in FreeBSD too? Then I guess it needs a similar change.. Yeah probably best to open a new issue and refer to this one and #1149.
That being said, the change doesn't check for BSD version but just the existence of the mibs. So if this was changed in freebsd the same way, the fix should have fixed that too.

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

4 participants