mirror of https://github.com/status-im/op-geth.git
vendor: update elastic/gosigar so that it compiles on OpenBSD (#16542)
This commit is contained in:
parent
b15eb665ee
commit
744428cb03
|
@ -8,10 +8,21 @@ This project adheres to [Semantic Versioning](http://semver.org/).
|
||||||
|
|
||||||
### Fixed
|
### Fixed
|
||||||
|
|
||||||
|
- Added missing runtime import for FreeBSD. #104
|
||||||
|
|
||||||
### Changed
|
### Changed
|
||||||
|
|
||||||
### Deprecated
|
### 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]
|
## [0.8.0]
|
||||||
|
|
||||||
### Added
|
### Added
|
||||||
|
|
|
@ -26,6 +26,7 @@ The features vary by operating system.
|
||||||
| FDUsage | X | | | | X |
|
| FDUsage | X | | | | X |
|
||||||
| FileSystemList | X | X | X | X | X |
|
| FileSystemList | X | X | X | X | X |
|
||||||
| FileSystemUsage | X | X | X | X | X |
|
| FileSystemUsage | X | X | X | X | X |
|
||||||
|
| HugeTLBPages | X | | | | |
|
||||||
| LoadAverage | X | X | | X | X |
|
| LoadAverage | X | X | | X | X |
|
||||||
| Mem | X | X | X | X | X |
|
| Mem | X | X | X | X | X |
|
||||||
| ProcArgs | X | X | X | | X |
|
| ProcArgs | X | X | X | | X |
|
||||||
|
|
|
@ -62,6 +62,12 @@ func (c *ConcreteSigar) GetSwap() (Swap, error) {
|
||||||
return s, err
|
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) {
|
func (c *ConcreteSigar) GetFileSystemUsage(path string) (FileSystemUsage, error) {
|
||||||
f := FileSystemUsage{}
|
f := FileSystemUsage{}
|
||||||
err := f.Get(path)
|
err := f.Get(path)
|
||||||
|
|
|
@ -91,6 +91,10 @@ func (self *Swap) Get() error {
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (self *HugeTLBPages) Get() error {
|
||||||
|
return ErrNotImplemented{runtime.GOOS}
|
||||||
|
}
|
||||||
|
|
||||||
func (self *Cpu) Get() error {
|
func (self *Cpu) Get() error {
|
||||||
var count C.mach_msg_type_number_t = C.HOST_CPU_LOAD_INFO_COUNT
|
var count C.mach_msg_type_number_t = C.HOST_CPU_LOAD_INFO_COUNT
|
||||||
var cpuload C.host_cpu_load_info_data_t
|
var cpuload C.host_cpu_load_info_data_t
|
||||||
|
|
|
@ -4,6 +4,7 @@ package gosigar
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"io/ioutil"
|
"io/ioutil"
|
||||||
|
"runtime"
|
||||||
"strconv"
|
"strconv"
|
||||||
"strings"
|
"strings"
|
||||||
"unsafe"
|
"unsafe"
|
||||||
|
@ -97,6 +98,10 @@ func (self *ProcFDUsage) Get(pid int) error {
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (self *HugeTLBPages) Get() error {
|
||||||
|
return ErrNotImplemented{runtime.GOOS}
|
||||||
|
}
|
||||||
|
|
||||||
func parseCpuStat(self *Cpu, line string) error {
|
func parseCpuStat(self *Cpu, line string) error {
|
||||||
fields := strings.Fields(line)
|
fields := strings.Fields(line)
|
||||||
|
|
||||||
|
|
|
@ -26,6 +26,7 @@ type Sigar interface {
|
||||||
GetLoadAverage() (LoadAverage, error)
|
GetLoadAverage() (LoadAverage, error)
|
||||||
GetMem() (Mem, error)
|
GetMem() (Mem, error)
|
||||||
GetSwap() (Swap, error)
|
GetSwap() (Swap, error)
|
||||||
|
GetHugeTLBPages(HugeTLBPages, error)
|
||||||
GetFileSystemUsage(string) (FileSystemUsage, error)
|
GetFileSystemUsage(string) (FileSystemUsage, error)
|
||||||
GetFDUsage() (FDUsage, error)
|
GetFDUsage() (FDUsage, error)
|
||||||
GetRusage(who int) (Rusage, error)
|
GetRusage(who int) (Rusage, error)
|
||||||
|
@ -82,6 +83,15 @@ type Swap struct {
|
||||||
Free uint64
|
Free uint64
|
||||||
}
|
}
|
||||||
|
|
||||||
|
type HugeTLBPages struct {
|
||||||
|
Total uint64
|
||||||
|
Free uint64
|
||||||
|
Reserved uint64
|
||||||
|
Surplus uint64
|
||||||
|
DefaultSize uint64
|
||||||
|
TotalAllocatedSize uint64
|
||||||
|
}
|
||||||
|
|
||||||
type CpuList struct {
|
type CpuList struct {
|
||||||
List []Cpu
|
List []Cpu
|
||||||
}
|
}
|
||||||
|
|
|
@ -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 {
|
func (self *ProcFDUsage) Get(pid int) error {
|
||||||
err := readFile(procFileName(pid, "limits"), func(line string) bool {
|
err := readFile(procFileName(pid, "limits"), func(line string) bool {
|
||||||
if strings.HasPrefix(line, "Max open files") {
|
if strings.HasPrefix(line, "Max open files") {
|
||||||
|
|
|
@ -379,12 +379,16 @@ func parseMeminfo() (map[string]uint64, error) {
|
||||||
return true // skip on errors
|
return true // skip on errors
|
||||||
}
|
}
|
||||||
|
|
||||||
num := strings.TrimLeft(fields[1], " ")
|
valueUnit := strings.Fields(fields[1])
|
||||||
val, err := strtoull(strings.Fields(num)[0])
|
value, err := strtoull(valueUnit[0])
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return true // skip on errors
|
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
|
return true
|
||||||
})
|
})
|
||||||
|
@ -420,8 +424,18 @@ func procFileName(pid int, name string) string {
|
||||||
return Procd + "/" + strconv.Itoa(pid) + "/" + name
|
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)
|
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)
|
contents, err := ioutil.ReadFile(path)
|
||||||
|
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
|
|
@ -294,6 +294,10 @@ func (self *Swap) Get() error {
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (self *HugeTLBPages) Get() error {
|
||||||
|
return ErrNotImplemented{runtime.GOOS}
|
||||||
|
}
|
||||||
|
|
||||||
func (self *Cpu) Get() error {
|
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}
|
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}
|
return ErrNotImplemented{runtime.GOOS}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (self *Rusage) Get(pid int) error {
|
||||||
|
return ErrNotImplemented{runtime.GOOS}
|
||||||
|
}
|
||||||
|
|
||||||
func fillCpu(cpu *Cpu, load [C.CPUSTATES]C.long) {
|
func fillCpu(cpu *Cpu, load [C.CPUSTATES]C.long) {
|
||||||
cpu.User = uint64(load[0])
|
cpu.User = uint64(load[0])
|
||||||
cpu.Nice = uint64(load[1])
|
cpu.Nice = uint64(load[1])
|
||||||
|
|
|
@ -22,6 +22,10 @@ func (s *Swap) Get() error {
|
||||||
return ErrNotImplemented{runtime.GOOS}
|
return ErrNotImplemented{runtime.GOOS}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (s *HugeTLBPages) Get() error {
|
||||||
|
return ErrNotImplemented{runtime.GOOS}
|
||||||
|
}
|
||||||
|
|
||||||
func (f *FDUsage) Get() error {
|
func (f *FDUsage) Get() error {
|
||||||
return ErrNotImplemented{runtime.GOOS}
|
return ErrNotImplemented{runtime.GOOS}
|
||||||
}
|
}
|
||||||
|
|
|
@ -120,6 +120,10 @@ func (self *Swap) Get() error {
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (self *HugeTLBPages) Get() error {
|
||||||
|
return ErrNotImplemented{runtime.GOOS}
|
||||||
|
}
|
||||||
|
|
||||||
func (self *Cpu) Get() error {
|
func (self *Cpu) Get() error {
|
||||||
idle, kernel, user, err := windows.GetSystemTimes()
|
idle, kernel, user, err := windows.GetSystemTimes()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
|
|
@ -93,10 +93,10 @@
|
||||||
"revisionTime": "2016-05-12T03:30:02Z"
|
"revisionTime": "2016-05-12T03:30:02Z"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"checksumSHA1": "Fc8BCxCoQ7ZmghDT6X1cASR10Ec=",
|
"checksumSHA1": "jElNoLEe7m/iaoF1vYIHyNaS2SE=",
|
||||||
"path": "github.com/elastic/gosigar",
|
"path": "github.com/elastic/gosigar",
|
||||||
"revision": "a3814ce5008e612a0c6d027608b54e1d0d9a5613",
|
"revision": "37f05ff46ffa7a825d1b24cf2b62d4a4c1a9d2e8",
|
||||||
"revisionTime": "2018-01-22T22:25:45Z"
|
"revisionTime": "2018-03-30T10:04:40Z"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"checksumSHA1": "qDsgp2kAeI9nhj565HUScaUyjU4=",
|
"checksumSHA1": "qDsgp2kAeI9nhj565HUScaUyjU4=",
|
||||||
|
|
Loading…
Reference in New Issue