Update vendoring (#685)

* Update vendor github.com/coreos/go-systemd/dbus@v15

* Update vendor github.com/ema/qdisc

* Update vendor github.com/godbus/dbus

* Update vendor github.com/golang/protobuf/proto

* Update vendor github.com/lufia/iostat

* Update vendor github.com/matttproud/golang_protobuf_extensions/pbutil@v1.0.0

* Update vendor github.com/prometheus/client_golang/...

* Update vendor github.com/prometheus/common/...

* Update vendor github.com/prometheus/procfs/...

* Update vendor github.com/sirupsen/logrus@v1.0.3

Adds vendor golang.org/x/crypto

* Update vendor golang.org/x/net/...

* Update vendor golang.org/x/sys/...

* Update end to end output.
This commit is contained in:
Ben Kochie 2017-10-05 16:20:47 +02:00 committed by GitHub
commit deadfef4c9
283 changed files with 47085 additions and 29054 deletions

View file

@ -4,6 +4,7 @@ package iostat
// #cgo LDFLAGS: -framework CoreFoundation -framework IOKit
// #include <stdint.h>
// #include <CoreFoundation/CoreFoundation.h>
// #include "iostat_darwin.h"
import "C"
import (
@ -35,3 +36,31 @@ func ReadDriveStats() ([]*DriveStats, error) {
}
return stats, nil
}
// ReadCPUStats returns statistics of CPU usage.
func ReadCPUStats() (*CPUStats, error) {
var cpu C.CPUStats
_, err := C.readcpustat(&cpu)
if err != nil {
return nil, err
}
return &CPUStats{
User: uint64(cpu.user),
Nice: uint64(cpu.nice),
Sys: uint64(cpu.sys),
Idle: uint64(cpu.idle),
}, nil
}
// ReadLoadAvg returns load averages over periods of time.
func ReadLoadAvg() (*LoadAvg, error) {
var load [3]C.double
if _, err := C.getloadavg(&load[0], C.int(len(load))); err != nil {
return nil, err
}
return &LoadAvg{
Load1: float64(load[0]),
Load5: float64(load[1]),
Load15: float64(load[2]),
}, nil
}