loadavg: Remove unnecessary global variable.
This commit is contained in:
parent
ccbea34465
commit
f93125ba10
|
@ -13,15 +13,12 @@ import (
|
||||||
// #include <stdlib.h>
|
// #include <stdlib.h>
|
||||||
import "C"
|
import "C"
|
||||||
|
|
||||||
var loadavg [1]C.double
|
|
||||||
|
|
||||||
type loadavgCollector struct {
|
type loadavgCollector struct {
|
||||||
metric prometheus.Gauge
|
metric prometheus.Gauge
|
||||||
}
|
}
|
||||||
|
|
||||||
func init() {
|
func init() {
|
||||||
Factories["loadavg"] = NewLoadavgCollector
|
Factories["loadavg"] = NewLoadavgCollector
|
||||||
loadavg[0] = 0
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// load1 stat.
|
// load1 stat.
|
||||||
|
@ -47,6 +44,7 @@ func (c *loadavgCollector) Update(ch chan<- prometheus.Metric) (err error) {
|
||||||
}
|
}
|
||||||
|
|
||||||
func getLoad1() (float64, error) {
|
func getLoad1() (float64, error) {
|
||||||
|
var loadavg [1]C.double
|
||||||
samples := C.getloadavg(&loadavg[0], 1)
|
samples := C.getloadavg(&loadavg[0], 1)
|
||||||
if samples > 0 {
|
if samples > 0 {
|
||||||
return float64(loadavg[0]), nil
|
return float64(loadavg[0]), nil
|
||||||
|
|
Loading…
Reference in New Issue