use sys/unix package instead of syscall (#1340)
According to the golang docs, the syscall package is deprecated. https://golang.org/pkg/syscall This updates collectors to use the x/sys/unix package instead. Also updates the vendored x/sys/unix module to latest. Signed-off-by: Paul Gier <pgier@redhat.com>
This commit is contained in:
parent
f97f01c46c
commit
d0a66c4c40
39 changed files with 2942 additions and 19 deletions
|
|
@ -22,10 +22,10 @@ import (
|
|||
"os"
|
||||
"strings"
|
||||
"sync"
|
||||
"syscall"
|
||||
"time"
|
||||
|
||||
"github.com/prometheus/common/log"
|
||||
"golang.org/x/sys/unix"
|
||||
)
|
||||
|
||||
const (
|
||||
|
|
@ -70,9 +70,8 @@ func (c *filesystemCollector) GetStats() ([]filesystemStats, error) {
|
|||
success := make(chan struct{})
|
||||
go stuckMountWatcher(labels.mountPoint, success)
|
||||
|
||||
buf := new(syscall.Statfs_t)
|
||||
err = syscall.Statfs(rootfsFilePath(labels.mountPoint), buf)
|
||||
|
||||
buf := new(unix.Statfs_t)
|
||||
err = unix.Statfs(rootfsFilePath(labels.mountPoint), buf)
|
||||
stuckMountsMtx.Lock()
|
||||
close(success)
|
||||
// If the mount has been marked as stuck, unmark it and log it's recovery.
|
||||
|
|
|
|||
|
|
@ -23,10 +23,10 @@ import (
|
|||
"regexp"
|
||||
"strconv"
|
||||
"strings"
|
||||
"syscall"
|
||||
|
||||
"github.com/prometheus/client_golang/prometheus"
|
||||
"github.com/prometheus/common/log"
|
||||
"golang.org/x/sys/unix"
|
||||
)
|
||||
|
||||
var (
|
||||
|
|
@ -86,9 +86,9 @@ func sysReadFile(file string) ([]byte, error) {
|
|||
// Go's ioutil.ReadFile implementation to poll forever.
|
||||
//
|
||||
// Since we either want to read data or bail immediately, do the simplest
|
||||
// possible read using syscall directly.
|
||||
// possible read using system call directly.
|
||||
b := make([]byte, 128)
|
||||
n, err := syscall.Read(int(f.Fd()), b)
|
||||
n, err := unix.Read(int(f.Fd()), b)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
|
|
|||
|
|
@ -18,7 +18,6 @@ package collector
|
|||
|
||||
import (
|
||||
"fmt"
|
||||
"syscall"
|
||||
"unsafe"
|
||||
|
||||
"github.com/prometheus/client_golang/prometheus"
|
||||
|
|
@ -98,16 +97,16 @@ func (b bsdSysctl) getStructTimeval() (float64, error) {
|
|||
return 0, err
|
||||
}
|
||||
|
||||
if len(raw) != int(unsafe.Sizeof(syscall.Timeval{})) {
|
||||
if len(raw) != int(unsafe.Sizeof(unix.Timeval{})) {
|
||||
// Shouldn't get here.
|
||||
return 0, fmt.Errorf(
|
||||
"length of bytes received from sysctl (%d) does not match expected bytes (%d)",
|
||||
len(raw),
|
||||
unsafe.Sizeof(syscall.Timeval{}),
|
||||
unsafe.Sizeof(unix.Timeval{}),
|
||||
)
|
||||
}
|
||||
|
||||
tv := *(*syscall.Timeval)(unsafe.Pointer(&raw[0]))
|
||||
tv := *(*unix.Timeval)(unsafe.Pointer(&raw[0]))
|
||||
|
||||
// This conversion maintains the usec precision. Using the time
|
||||
// package did not.
|
||||
|
|
|
|||
|
|
@ -18,9 +18,9 @@ package collector
|
|||
|
||||
import (
|
||||
"fmt"
|
||||
"syscall"
|
||||
|
||||
"github.com/prometheus/client_golang/prometheus"
|
||||
"golang.org/x/sys/unix"
|
||||
)
|
||||
|
||||
const (
|
||||
|
|
@ -156,9 +156,9 @@ func NewTimexCollector() (Collector, error) {
|
|||
func (c *timexCollector) Update(ch chan<- prometheus.Metric) error {
|
||||
var syncStatus float64
|
||||
var divisor float64
|
||||
var timex = new(syscall.Timex)
|
||||
var timex = new(unix.Timex)
|
||||
|
||||
status, err := syscall.Adjtimex(timex)
|
||||
status, err := unix.Adjtimex(timex)
|
||||
if err != nil {
|
||||
return fmt.Errorf("failed to retrieve adjtimex stats: %v", err)
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue