aboutsummaryrefslogtreecommitdiff
path: root/collector
diff options
context:
space:
mode:
authorTobias Klauser <tklauser@distanz.ch>2020-02-18 14:14:35 +0100
committerGitHub <noreply@github.com>2020-02-18 14:14:35 +0100
commit6ad94ae4bc5527037ce0e6b8462f58cb3b8ccef3 (patch)
tree444fb494a5a3c93f71d1a87c4fa6b710bc574b12 /collector
parent1567cefdaeec156b9f1a231f1bd82fa043f2bd7b (diff)
downloadprometheus_node_collector-6ad94ae4bc5527037ce0e6b8462f58cb3b8ccef3.tar.bz2
prometheus_node_collector-6ad94ae4bc5527037ce0e6b8462f58cb3b8ccef3.tar.xz
prometheus_node_collector-6ad94ae4bc5527037ce0e6b8462f58cb3b8ccef3.zip
Implement loadavg on all BSDs without cgo (#1584)
Reuse the Go-only implementation already in place for FreeBSD (#385) on Darwin, DragonflyBSD, NetBSD and OpenBSD. Tested on all affected platforms. Signed-off-by: Tobias Klauser <tklauser@distanz.ch>
Diffstat (limited to 'collector')
-rw-r--r--collector/loadavg_bsd.go (renamed from collector/loadavg_freebsd.go)1
-rw-r--r--collector/loadavg_unix.go33
2 files changed, 1 insertions, 33 deletions
diff --git a/collector/loadavg_freebsd.go b/collector/loadavg_bsd.go
index e919c50..38215aa 100644
--- a/collector/loadavg_freebsd.go
+++ b/collector/loadavg_bsd.go
@@ -11,6 +11,7 @@
11// See the License for the specific language governing permissions and 11// See the License for the specific language governing permissions and
12// limitations under the License. 12// limitations under the License.
13 13
14// +build darwin dragonfly freebsd netbsd openbsd
14// +build !noloadavg 15// +build !noloadavg
15 16
16package collector 17package collector
diff --git a/collector/loadavg_unix.go b/collector/loadavg_unix.go
deleted file mode 100644
index 4d65885..0000000
--- a/collector/loadavg_unix.go
+++ /dev/null
@@ -1,33 +0,0 @@
1// Copyright 2015 The Prometheus Authors
2// Licensed under the Apache License, Version 2.0 (the "License");
3// you may not use this file except in compliance with the License.
4// You may obtain a copy of the License at
5//
6// http://www.apache.org/licenses/LICENSE-2.0
7//
8// Unless required by applicable law or agreed to in writing, software
9// distributed under the License is distributed on an "AS IS" BASIS,
10// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
11// See the License for the specific language governing permissions and
12// limitations under the License.
13
14// +build darwin dragonfly netbsd openbsd
15// +build !noloadavg
16
17package collector
18
19import (
20 "errors"
21)
22
23// #include <stdlib.h>
24import "C"
25
26func getLoad() ([]float64, error) {
27 var loadavg [3]C.double
28 samples := C.getloadavg(&loadavg[0], 3)
29 if samples != 3 {
30 return nil, errors.New("failed to get load average")
31 }
32 return []float64{float64(loadavg[0]), float64(loadavg[1]), float64(loadavg[2])}, nil
33}