forked from cerc-io/plugeth
vendor: update elastic/gosigar so that it compiles on OpenBSD (#16542)
This commit is contained in:
parent
b15eb665ee
commit
744428cb03
11
vendor/github.com/elastic/gosigar/CHANGELOG.md
generated
vendored
11
vendor/github.com/elastic/gosigar/CHANGELOG.md
generated
vendored
@ -8,10 +8,21 @@ This project adheres to [Semantic Versioning](http://semver.org/).
|
||||
|
||||
### Fixed
|
||||
|
||||
- Added missing runtime import for FreeBSD. #104
|
||||
|
||||
### Changed
|
||||
|
||||
### Deprecated
|
||||
|
||||
## [0.9.0]
|
||||
|
||||
### Added
|
||||
- Added support for huge TLB pages on Linux #97
|
||||
- Added support for big endian platform #100
|
||||
|
||||
### Fixed
|
||||
- Add missing method for OpenBSD #99
|
||||
|
||||
## [0.8.0]
|
||||
|
||||
### Added
|
||||
|
1
vendor/github.com/elastic/gosigar/README.md
generated
vendored
1
vendor/github.com/elastic/gosigar/README.md
generated
vendored
@ -26,6 +26,7 @@ The features vary by operating system.
|
||||
| FDUsage | X | | | | X |
|
||||
| FileSystemList | X | X | X | X | X |
|
||||
| FileSystemUsage | X | X | X | X | X |
|
||||
| HugeTLBPages | X | | | | |
|
||||
| LoadAverage | X | X | | X | X |
|
||||
| Mem | X | X | X | X | X |
|
||||
| ProcArgs | X | X | X | | X |
|
||||
|
6
vendor/github.com/elastic/gosigar/concrete_sigar.go
generated
vendored
6
vendor/github.com/elastic/gosigar/concrete_sigar.go
generated
vendored
@ -62,6 +62,12 @@ func (c *ConcreteSigar) GetSwap() (Swap, error) {
|
||||
return s, err
|
||||
}
|
||||
|
||||
func (c *ConcreteSigar) GetHugeTLBPages() (HugeTLBPages, error) {
|
||||
p := HugeTLBPages{}
|
||||
err := p.Get()
|
||||
return p, err
|
||||
}
|
||||
|
||||
func (c *ConcreteSigar) GetFileSystemUsage(path string) (FileSystemUsage, error) {
|
||||
f := FileSystemUsage{}
|
||||
err := f.Get(path)
|
||||
|
4
vendor/github.com/elastic/gosigar/sigar_darwin.go
generated
vendored
4
vendor/github.com/elastic/gosigar/sigar_darwin.go
generated
vendored
@ -91,6 +91,10 @@ func (self *Swap) Get() error {
|
||||
return nil
|
||||
}
|
||||
|
||||
func (self *HugeTLBPages) Get() error {
|
||||
return ErrNotImplemented{runtime.GOOS}
|
||||
}
|
||||
|
||||
func (self *Cpu) Get() error {
|
||||
var count C.mach_msg_type_number_t = C.HOST_CPU_LOAD_INFO_COUNT
|
||||
var cpuload C.host_cpu_load_info_data_t
|
||||
|
5
vendor/github.com/elastic/gosigar/sigar_freebsd.go
generated
vendored
5
vendor/github.com/elastic/gosigar/sigar_freebsd.go
generated
vendored
@ -4,6 +4,7 @@ package gosigar
|
||||
|
||||
import (
|
||||
"io/ioutil"
|
||||
"runtime"
|
||||
"strconv"
|
||||
"strings"
|
||||
"unsafe"
|
||||
@ -97,6 +98,10 @@ func (self *ProcFDUsage) Get(pid int) error {
|
||||
return nil
|
||||
}
|
||||
|
||||
func (self *HugeTLBPages) Get() error {
|
||||
return ErrNotImplemented{runtime.GOOS}
|
||||
}
|
||||
|
||||
func parseCpuStat(self *Cpu, line string) error {
|
||||
fields := strings.Fields(line)
|
||||
|
||||
|
10
vendor/github.com/elastic/gosigar/sigar_interface.go
generated
vendored
10
vendor/github.com/elastic/gosigar/sigar_interface.go
generated
vendored
@ -26,6 +26,7 @@ type Sigar interface {
|
||||
GetLoadAverage() (LoadAverage, error)
|
||||
GetMem() (Mem, error)
|
||||
GetSwap() (Swap, error)
|
||||
GetHugeTLBPages(HugeTLBPages, error)
|
||||
GetFileSystemUsage(string) (FileSystemUsage, error)
|
||||
GetFDUsage() (FDUsage, error)
|
||||
GetRusage(who int) (Rusage, error)
|
||||
@ -82,6 +83,15 @@ type Swap struct {
|
||||
Free uint64
|
||||
}
|
||||
|
||||
type HugeTLBPages struct {
|
||||
Total uint64
|
||||
Free uint64
|
||||
Reserved uint64
|
||||
Surplus uint64
|
||||
DefaultSize uint64
|
||||
TotalAllocatedSize uint64
|
||||
}
|
||||
|
||||
type CpuList struct {
|
||||
List []Cpu
|
||||
}
|
||||
|
24
vendor/github.com/elastic/gosigar/sigar_linux.go
generated
vendored
24
vendor/github.com/elastic/gosigar/sigar_linux.go
generated
vendored
@ -45,6 +45,30 @@ func (self *FDUsage) Get() error {
|
||||
})
|
||||
}
|
||||
|
||||
func (self *HugeTLBPages) Get() error {
|
||||
table, err := parseMeminfo()
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
self.Total, _ = table["HugePages_Total"]
|
||||
self.Free, _ = table["HugePages_Free"]
|
||||
self.Reserved, _ = table["HugePages_Rsvd"]
|
||||
self.Surplus, _ = table["HugePages_Surp"]
|
||||
self.DefaultSize, _ = table["Hugepagesize"]
|
||||
|
||||
if totalSize, found := table["Hugetlb"]; found {
|
||||
self.TotalAllocatedSize = totalSize
|
||||
} else {
|
||||
// If Hugetlb is not present, or huge pages of different sizes
|
||||
// are used, this figure can be unaccurate.
|
||||
// TODO (jsoriano): Extract information from /sys/kernel/mm/hugepages too
|
||||
self.TotalAllocatedSize = (self.Total - self.Free + self.Reserved) * self.DefaultSize
|
||||
}
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
func (self *ProcFDUsage) Get(pid int) error {
|
||||
err := readFile(procFileName(pid, "limits"), func(line string) bool {
|
||||
if strings.HasPrefix(line, "Max open files") {
|
||||
|
22
vendor/github.com/elastic/gosigar/sigar_linux_common.go
generated
vendored
22
vendor/github.com/elastic/gosigar/sigar_linux_common.go
generated
vendored
@ -379,12 +379,16 @@ func parseMeminfo() (map[string]uint64, error) {
|
||||
return true // skip on errors
|
||||
}
|
||||
|
||||
num := strings.TrimLeft(fields[1], " ")
|
||||
val, err := strtoull(strings.Fields(num)[0])
|
||||
valueUnit := strings.Fields(fields[1])
|
||||
value, err := strtoull(valueUnit[0])
|
||||
if err != nil {
|
||||
return true // skip on errors
|
||||
}
|
||||
table[fields[0]] = val * 1024 //in bytes
|
||||
|
||||
if len(valueUnit) > 1 && valueUnit[1] == "kB" {
|
||||
value *= 1024
|
||||
}
|
||||
table[fields[0]] = value
|
||||
|
||||
return true
|
||||
})
|
||||
@ -420,8 +424,18 @@ func procFileName(pid int, name string) string {
|
||||
return Procd + "/" + strconv.Itoa(pid) + "/" + name
|
||||
}
|
||||
|
||||
func readProcFile(pid int, name string) ([]byte, error) {
|
||||
func readProcFile(pid int, name string) (content []byte, err error) {
|
||||
path := procFileName(pid, name)
|
||||
|
||||
// Panics have been reported when reading proc files, let's recover and
|
||||
// report the path if this happens
|
||||
// See https://github.com/elastic/beats/issues/6692
|
||||
defer func() {
|
||||
if r := recover(); r != nil {
|
||||
content = nil
|
||||
err = fmt.Errorf("recovered panic when reading proc file '%s': %v", path, r)
|
||||
}
|
||||
}()
|
||||
contents, err := ioutil.ReadFile(path)
|
||||
|
||||
if err != nil {
|
||||
|
8
vendor/github.com/elastic/gosigar/sigar_openbsd.go
generated
vendored
8
vendor/github.com/elastic/gosigar/sigar_openbsd.go
generated
vendored
@ -294,6 +294,10 @@ func (self *Swap) Get() error {
|
||||
return nil
|
||||
}
|
||||
|
||||
func (self *HugeTLBPages) Get() error {
|
||||
return ErrNotImplemented{runtime.GOOS}
|
||||
}
|
||||
|
||||
func (self *Cpu) Get() error {
|
||||
load := [C.CPUSTATES]C.long{C.CP_USER, C.CP_NICE, C.CP_SYS, C.CP_INTR, C.CP_IDLE}
|
||||
|
||||
@ -381,6 +385,10 @@ func (self *ProcFDUsage) Get(pid int) error {
|
||||
return ErrNotImplemented{runtime.GOOS}
|
||||
}
|
||||
|
||||
func (self *Rusage) Get(pid int) error {
|
||||
return ErrNotImplemented{runtime.GOOS}
|
||||
}
|
||||
|
||||
func fillCpu(cpu *Cpu, load [C.CPUSTATES]C.long) {
|
||||
cpu.User = uint64(load[0])
|
||||
cpu.Nice = uint64(load[1])
|
||||
|
4
vendor/github.com/elastic/gosigar/sigar_stub.go
generated
vendored
4
vendor/github.com/elastic/gosigar/sigar_stub.go
generated
vendored
@ -22,6 +22,10 @@ func (s *Swap) Get() error {
|
||||
return ErrNotImplemented{runtime.GOOS}
|
||||
}
|
||||
|
||||
func (s *HugeTLBPages) Get() error {
|
||||
return ErrNotImplemented{runtime.GOOS}
|
||||
}
|
||||
|
||||
func (f *FDUsage) Get() error {
|
||||
return ErrNotImplemented{runtime.GOOS}
|
||||
}
|
||||
|
4
vendor/github.com/elastic/gosigar/sigar_windows.go
generated
vendored
4
vendor/github.com/elastic/gosigar/sigar_windows.go
generated
vendored
@ -120,6 +120,10 @@ func (self *Swap) Get() error {
|
||||
return nil
|
||||
}
|
||||
|
||||
func (self *HugeTLBPages) Get() error {
|
||||
return ErrNotImplemented{runtime.GOOS}
|
||||
}
|
||||
|
||||
func (self *Cpu) Get() error {
|
||||
idle, kernel, user, err := windows.GetSystemTimes()
|
||||
if err != nil {
|
||||
|
6
vendor/vendor.json
vendored
6
vendor/vendor.json
vendored
@ -93,10 +93,10 @@
|
||||
"revisionTime": "2016-05-12T03:30:02Z"
|
||||
},
|
||||
{
|
||||
"checksumSHA1": "Fc8BCxCoQ7ZmghDT6X1cASR10Ec=",
|
||||
"checksumSHA1": "jElNoLEe7m/iaoF1vYIHyNaS2SE=",
|
||||
"path": "github.com/elastic/gosigar",
|
||||
"revision": "a3814ce5008e612a0c6d027608b54e1d0d9a5613",
|
||||
"revisionTime": "2018-01-22T22:25:45Z"
|
||||
"revision": "37f05ff46ffa7a825d1b24cf2b62d4a4c1a9d2e8",
|
||||
"revisionTime": "2018-03-30T10:04:40Z"
|
||||
},
|
||||
{
|
||||
"checksumSHA1": "qDsgp2kAeI9nhj565HUScaUyjU4=",
|
||||
|
Loading…
Reference in New Issue
Block a user