mirror of
https://github.com/kemko/nomad.git
synced 2026-01-07 19:05:42 +03:00
Merge pull request #2452 from jen20/deps-update-gopsutil
deps: Update github.com/shirou/gopsutil/...
This commit is contained in:
43
vendor/github.com/shirou/gopsutil/README.rst
generated
vendored
43
vendor/github.com/shirou/gopsutil/README.rst
generated
vendored
@@ -49,6 +49,7 @@ Available Architectures
|
||||
- Windows/amd64
|
||||
- Darwin i386/amd64
|
||||
- OpenBDS amd64 (Thank you @mpfz0r!)
|
||||
- Solaris amd64 (developed and tested on SmartOS/Illumos, Thank you @jen20!)
|
||||
|
||||
All works are implemented without cgo by porting c struct to golang struct.
|
||||
|
||||
@@ -173,13 +174,13 @@ Current Status
|
||||
- x: work
|
||||
- b: almost works, but something is broken
|
||||
|
||||
=================== ====== ======= ======= ====== =======
|
||||
name Linux FreeBSD OpenBSD MacOSX Windows
|
||||
=================== ====== ======= ======= ====== ======= =======
|
||||
name Linux FreeBSD OpenBSD MacOSX Windows Solaris
|
||||
cpu_times x x x x x
|
||||
cpu_count x x x x x
|
||||
cpu_percent x x x x x
|
||||
cpu_times_percent x x x x x
|
||||
virtual_memory x x x x x
|
||||
virtual_memory x x x x x b
|
||||
swap_memory x x x x
|
||||
disk_partitions x x x x x
|
||||
disk_io_counters x x x
|
||||
@@ -244,26 +245,26 @@ is_running
|
||||
Original Metrics
|
||||
^^^^^^^^^^^^^^^^^^^
|
||||
|
||||
================== ===== ======= ======= ====== =======
|
||||
item Linux FreeBSD OpenBSD MacOSX Windows
|
||||
================== ===== ======= ======= ====== ======= =======
|
||||
item Linux FreeBSD OpenBSD MacOSX Windows Solaris
|
||||
**HostInfo**
|
||||
hostname x x x x x
|
||||
uptime x x x x
|
||||
proces x x x
|
||||
os x x x x x
|
||||
platform x x x x
|
||||
platformfamily x x x x
|
||||
hostname x x x x x x
|
||||
uptime x x x x x
|
||||
proces x x x x
|
||||
os x x x x x x
|
||||
platform x x x x x
|
||||
platformfamily x x x x x
|
||||
virtualization x
|
||||
**CPU**
|
||||
VendorID x x x x x
|
||||
Family x x x x x
|
||||
Model x x x x x
|
||||
Stepping x x x x x
|
||||
PhysicalID x
|
||||
CoreID x
|
||||
Cores x x
|
||||
ModelName x x x x x
|
||||
Microcode x
|
||||
VendorID x x x x x x
|
||||
Family x x x x x x
|
||||
Model x x x x x x
|
||||
Stepping x x x x x x
|
||||
PhysicalID x x
|
||||
CoreID x x
|
||||
Cores x x x
|
||||
ModelName x x x x x x
|
||||
Microcode x x
|
||||
**LoadAvg**
|
||||
Load1 x x x x
|
||||
Load5 x x x x
|
||||
@@ -275,7 +276,7 @@ hostname x x x x x
|
||||
system x no no no no
|
||||
**CgroupsMem**
|
||||
various x no no no no
|
||||
================== ===== ======= ======= ====== =======
|
||||
================== ===== ======= ======= ====== ======= =======
|
||||
|
||||
- future work
|
||||
|
||||
|
||||
2
vendor/github.com/shirou/gopsutil/cpu/cpu.go
generated
vendored
2
vendor/github.com/shirou/gopsutil/cpu/cpu.go
generated
vendored
@@ -171,7 +171,7 @@ func percentUsedFromLastCall(percpu bool) ([]float64, error) {
|
||||
}
|
||||
|
||||
if lastTimes == nil {
|
||||
return nil, fmt.Errorf("Error getting times for cpu percent. LastTimes was nil")
|
||||
return nil, fmt.Errorf("error getting times for cpu percent. lastTimes was nil")
|
||||
}
|
||||
return calculateAllBusy(lastTimes, cpuTimes)
|
||||
}
|
||||
|
||||
10
vendor/github.com/shirou/gopsutil/cpu/cpu_freebsd.go
generated
vendored
10
vendor/github.com/shirou/gopsutil/cpu/cpu_freebsd.go
generated
vendored
@@ -118,7 +118,7 @@ func Info() ([]InfoStat, error) {
|
||||
return nil, err
|
||||
}
|
||||
if c.Mhz, err = strconv.ParseFloat(vals[0], 64); err != nil {
|
||||
return nil, fmt.Errorf("Unable to parse FreeBSD CPU clock rate: %v", err)
|
||||
return nil, fmt.Errorf("unable to parse FreeBSD CPU clock rate: %v", err)
|
||||
}
|
||||
|
||||
if vals, err = common.DoSysctrl("hw.ncpu"); err != nil {
|
||||
@@ -126,7 +126,7 @@ func Info() ([]InfoStat, error) {
|
||||
}
|
||||
var i64 int64
|
||||
if i64, err = strconv.ParseInt(vals[0], 10, 32); err != nil {
|
||||
return nil, fmt.Errorf("Unable to parse FreeBSD cores: %v", err)
|
||||
return nil, fmt.Errorf("unable to parse FreeBSD cores: %v", err)
|
||||
}
|
||||
c.Cores = int32(i64)
|
||||
|
||||
@@ -156,7 +156,7 @@ func parseDmesgBoot(fileName string) (InfoStat, int, error) {
|
||||
c.Model = matches[4]
|
||||
t, err := strconv.ParseInt(matches[5], 10, 32)
|
||||
if err != nil {
|
||||
return c, 0, fmt.Errorf("Unable to parse FreeBSD CPU stepping information from %q: %v", line, err)
|
||||
return c, 0, fmt.Errorf("unable to parse FreeBSD CPU stepping information from %q: %v", line, err)
|
||||
}
|
||||
c.Stepping = int32(t)
|
||||
} else if matches := featuresMatch.FindStringSubmatch(line); matches != nil {
|
||||
@@ -170,12 +170,12 @@ func parseDmesgBoot(fileName string) (InfoStat, int, error) {
|
||||
} else if matches := cpuCores.FindStringSubmatch(line); matches != nil {
|
||||
t, err := strconv.ParseInt(matches[1], 10, 32)
|
||||
if err != nil {
|
||||
return c, 0, fmt.Errorf("Unable to parse FreeBSD CPU Nums from %q: %v", line, err)
|
||||
return c, 0, fmt.Errorf("unable to parse FreeBSD CPU Nums from %q: %v", line, err)
|
||||
}
|
||||
cpuNum = int(t)
|
||||
t2, err := strconv.ParseInt(matches[2], 10, 32)
|
||||
if err != nil {
|
||||
return c, 0, fmt.Errorf("Unable to parse FreeBSD CPU cores from %q: %v", line, err)
|
||||
return c, 0, fmt.Errorf("unable to parse FreeBSD CPU cores from %q: %v", line, err)
|
||||
}
|
||||
c.Cores = int32(t2)
|
||||
}
|
||||
|
||||
42
vendor/github.com/shirou/gopsutil/cpu/cpu_solaris.go
generated
vendored
42
vendor/github.com/shirou/gopsutil/cpu/cpu_solaris.go
generated
vendored
@@ -36,30 +36,30 @@ func Times(percpu bool) ([]TimesStat, error) {
|
||||
func Info() ([]InfoStat, error) {
|
||||
psrInfo, err := exec.LookPath("/usr/sbin/psrinfo")
|
||||
if err != nil {
|
||||
return nil, fmt.Errorf("Cannot find psrinfo: %s", err)
|
||||
return nil, fmt.Errorf("cannot find psrinfo: %s", err)
|
||||
}
|
||||
psrInfoOut, err := invoke.Command(psrInfo, "-p", "-v")
|
||||
if err != nil {
|
||||
return nil, fmt.Errorf("Cannot execute psrinfo: %s", err)
|
||||
return nil, fmt.Errorf("cannot execute psrinfo: %s", err)
|
||||
}
|
||||
|
||||
isaInfo, err := exec.LookPath("/usr/bin/isainfo")
|
||||
if err != nil {
|
||||
return nil, fmt.Errorf("Cannot find isainfo: %s", err)
|
||||
return nil, fmt.Errorf("cannot find isainfo: %s", err)
|
||||
}
|
||||
isaInfoOut, err := invoke.Command(isaInfo, "-b", "-v")
|
||||
if err != nil {
|
||||
return nil, fmt.Errorf("Cannot execute isainfo: %s", err)
|
||||
return nil, fmt.Errorf("cannot execute isainfo: %s", err)
|
||||
}
|
||||
|
||||
procs, err := parseProcessorInfo(string(psrInfoOut))
|
||||
if err != nil {
|
||||
return nil, fmt.Errorf("Error parsing psrinfo output: %s", err)
|
||||
return nil, fmt.Errorf("error parsing psrinfo output: %s", err)
|
||||
}
|
||||
|
||||
flags, err := parseISAInfo(string(isaInfoOut))
|
||||
if err != nil {
|
||||
return nil, fmt.Errorf("Error parsing isainfo output: %s", err)
|
||||
return nil, fmt.Errorf("error parsing isainfo output: %s", err)
|
||||
}
|
||||
|
||||
result := make([]InfoStat, 0, len(flags))
|
||||
@@ -79,7 +79,7 @@ func parseISAInfo(cmdOutput string) ([]string, error) {
|
||||
|
||||
// Sanity check the output
|
||||
if len(words) < 4 || words[1] != "bit" || words[3] != "applications" {
|
||||
return nil, errors.New("Attempted to parse invalid isainfo output")
|
||||
return nil, errors.New("attempted to parse invalid isainfo output")
|
||||
}
|
||||
|
||||
flags := make([]string, len(words)-4)
|
||||
@@ -94,15 +94,15 @@ func parseISAInfo(cmdOutput string) ([]string, error) {
|
||||
var psrInfoMatch = regexp.MustCompile(`The physical processor has (?:([\d]+) virtual processor \(([\d]+)\)|([\d]+) cores and ([\d]+) virtual processors[^\n]+)\n(?:\s+ The core has.+\n)*\s+.+ \((\w+) ([\S]+) family (.+) model (.+) step (.+) clock (.+) MHz\)\n[\s]*(.*)`)
|
||||
|
||||
const (
|
||||
psrNumCoresOffset = 1
|
||||
psrNumCoresOffset = 1
|
||||
psrNumCoresHTOffset = 3
|
||||
psrNumHTOffset = 4
|
||||
psrVendorIDOffset = 5
|
||||
psrFamilyOffset = 7
|
||||
psrModelOffset = 8
|
||||
psrStepOffset = 9
|
||||
psrClockOffset = 10
|
||||
psrModelNameOffset = 11
|
||||
psrNumHTOffset = 4
|
||||
psrVendorIDOffset = 5
|
||||
psrFamilyOffset = 7
|
||||
psrModelOffset = 8
|
||||
psrStepOffset = 9
|
||||
psrClockOffset = 10
|
||||
psrModelNameOffset = 11
|
||||
)
|
||||
|
||||
func parseProcessorInfo(cmdOutput string) ([]InfoStat, error) {
|
||||
@@ -117,7 +117,7 @@ func parseProcessorInfo(cmdOutput string) ([]InfoStat, error) {
|
||||
if physicalCPU[psrStepOffset] != "" {
|
||||
stepParsed, err := strconv.ParseInt(physicalCPU[psrStepOffset], 10, 32)
|
||||
if err != nil {
|
||||
return nil, fmt.Errorf("Cannot parse value %q for step as 32-bit integer: %s", physicalCPU[9], err)
|
||||
return nil, fmt.Errorf("cannot parse value %q for step as 32-bit integer: %s", physicalCPU[9], err)
|
||||
}
|
||||
step = int32(stepParsed)
|
||||
}
|
||||
@@ -125,7 +125,7 @@ func parseProcessorInfo(cmdOutput string) ([]InfoStat, error) {
|
||||
if physicalCPU[psrClockOffset] != "" {
|
||||
clockParsed, err := strconv.ParseInt(physicalCPU[psrClockOffset], 10, 64)
|
||||
if err != nil {
|
||||
return nil, fmt.Errorf("Cannot parse value %q for clock as 32-bit integer: %s", physicalCPU[10], err)
|
||||
return nil, fmt.Errorf("cannot parse value %q for clock as 32-bit integer: %s", physicalCPU[10], err)
|
||||
}
|
||||
clock = float64(clockParsed)
|
||||
}
|
||||
@@ -137,7 +137,7 @@ func parseProcessorInfo(cmdOutput string) ([]InfoStat, error) {
|
||||
case physicalCPU[psrNumCoresOffset] != "":
|
||||
numCores, err = strconv.ParseInt(physicalCPU[psrNumCoresOffset], 10, 32)
|
||||
if err != nil {
|
||||
return nil, fmt.Errorf("Cannot parse value %q for core count as 32-bit integer: %s", physicalCPU[1], err)
|
||||
return nil, fmt.Errorf("cannot parse value %q for core count as 32-bit integer: %s", physicalCPU[1], err)
|
||||
}
|
||||
|
||||
for i := 0; i < int(numCores); i++ {
|
||||
@@ -158,12 +158,12 @@ func parseProcessorInfo(cmdOutput string) ([]InfoStat, error) {
|
||||
case physicalCPU[psrNumCoresHTOffset] != "":
|
||||
numCores, err = strconv.ParseInt(physicalCPU[psrNumCoresHTOffset], 10, 32)
|
||||
if err != nil {
|
||||
return nil, fmt.Errorf("Cannot parse value %q for core count as 32-bit integer: %s", physicalCPU[3], err)
|
||||
return nil, fmt.Errorf("cannot parse value %q for core count as 32-bit integer: %s", physicalCPU[3], err)
|
||||
}
|
||||
|
||||
numHT, err = strconv.ParseInt(physicalCPU[psrNumHTOffset], 10, 32)
|
||||
if err != nil {
|
||||
return nil, fmt.Errorf("Cannot parse value %q for hyperthread count as 32-bit integer: %s", physicalCPU[4], err)
|
||||
return nil, fmt.Errorf("cannot parse value %q for hyperthread count as 32-bit integer: %s", physicalCPU[4], err)
|
||||
}
|
||||
|
||||
for i := 0; i < int(numCores); i++ {
|
||||
@@ -182,7 +182,7 @@ func parseProcessorInfo(cmdOutput string) ([]InfoStat, error) {
|
||||
infoStatCount++
|
||||
}
|
||||
default:
|
||||
return nil, errors.New("Values for cores with and without hyperthreading are both set")
|
||||
return nil, errors.New("values for cores with and without hyperthreading are both set")
|
||||
}
|
||||
}
|
||||
return result, nil
|
||||
|
||||
2
vendor/github.com/shirou/gopsutil/host/host_fallback.go
generated
vendored
2
vendor/github.com/shirou/gopsutil/host/host_fallback.go
generated
vendored
@@ -1,4 +1,4 @@
|
||||
// +build !darwin,!linux,!freebsd,!openbsd,!windows
|
||||
// +build !darwin,!linux,!freebsd,!openbsd,!solaris,!windows
|
||||
|
||||
package host
|
||||
|
||||
|
||||
132
vendor/github.com/shirou/gopsutil/host/host_solaris.go
generated
vendored
Normal file
132
vendor/github.com/shirou/gopsutil/host/host_solaris.go
generated
vendored
Normal file
@@ -0,0 +1,132 @@
|
||||
package host
|
||||
|
||||
import (
|
||||
"bufio"
|
||||
"fmt"
|
||||
"io/ioutil"
|
||||
"os"
|
||||
"os/exec"
|
||||
"regexp"
|
||||
"runtime"
|
||||
"strconv"
|
||||
"strings"
|
||||
"time"
|
||||
|
||||
"github.com/shirou/gopsutil/internal/common"
|
||||
)
|
||||
|
||||
func Info() (*InfoStat, error) {
|
||||
result := &InfoStat{
|
||||
OS: runtime.GOOS,
|
||||
}
|
||||
|
||||
hostname, err := os.Hostname()
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
result.Hostname = hostname
|
||||
|
||||
// Parse versions from output of `uname(1)`
|
||||
uname, err := exec.LookPath("/usr/bin/uname")
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
out, err := invoke.Command(uname, "-srv")
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
fields := strings.Fields(string(out))
|
||||
if len(fields) >= 1 {
|
||||
result.PlatformFamily = fields[0]
|
||||
}
|
||||
if len(fields) >= 2 {
|
||||
result.KernelVersion = fields[1]
|
||||
}
|
||||
if len(fields) == 3 {
|
||||
result.PlatformVersion = fields[2]
|
||||
}
|
||||
|
||||
// Find distribution name from /etc/release
|
||||
fh, err := os.Open("/etc/release")
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
defer fh.Close()
|
||||
|
||||
sc := bufio.NewScanner(fh)
|
||||
if sc.Scan() {
|
||||
line := strings.TrimSpace(sc.Text())
|
||||
switch {
|
||||
case strings.HasPrefix(line, "SmartOS"):
|
||||
result.Platform = "SmartOS"
|
||||
case strings.HasPrefix(line, "OpenIndiana"):
|
||||
result.Platform = "OpenIndiana"
|
||||
case strings.HasPrefix(line, "OmniOS"):
|
||||
result.Platform = "OmniOS"
|
||||
case strings.HasPrefix(line, "Open Storage"):
|
||||
result.Platform = "NexentaStor"
|
||||
case strings.HasPrefix(line, "Solaris"):
|
||||
result.Platform = "Solaris"
|
||||
case strings.HasPrefix(line, "Oracle Solaris"):
|
||||
result.Platform = "Solaris"
|
||||
default:
|
||||
result.Platform = strings.Fields(line)[0]
|
||||
}
|
||||
}
|
||||
|
||||
// Find the boot time and calculate uptime relative to it
|
||||
bootTime, err := BootTime()
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
result.BootTime = bootTime
|
||||
result.Uptime = uptimeSince(bootTime)
|
||||
|
||||
// Count number of processes based on the number of entries in /proc
|
||||
dirs, err := ioutil.ReadDir("/proc")
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
result.Procs = uint64(len(dirs))
|
||||
|
||||
return result, nil
|
||||
}
|
||||
|
||||
var kstatMatch = regexp.MustCompile(`([^\s]+)[\s]+([^\s]*)`)
|
||||
|
||||
func BootTime() (uint64, error) {
|
||||
kstat, err := exec.LookPath("/usr/bin/kstat")
|
||||
if err != nil {
|
||||
return 0, err
|
||||
}
|
||||
|
||||
out, err := invoke.Command(kstat, "-p", "unix:0:system_misc:boot_time")
|
||||
if err != nil {
|
||||
return 0, err
|
||||
}
|
||||
|
||||
kstats := kstatMatch.FindAllStringSubmatch(string(out), -1)
|
||||
if len(kstats) != 1 {
|
||||
return 0, fmt.Errorf("expected 1 kstat, found %d", len(kstats))
|
||||
}
|
||||
|
||||
return strconv.ParseUint(kstats[0][2], 10, 64)
|
||||
}
|
||||
|
||||
func Uptime() (uint64, error) {
|
||||
bootTime, err := BootTime()
|
||||
if err != nil {
|
||||
return 0, err
|
||||
}
|
||||
return uptimeSince(bootTime), nil
|
||||
}
|
||||
|
||||
func uptimeSince(since uint64) uint64 {
|
||||
return uint64(time.Now().Unix()) - since
|
||||
}
|
||||
|
||||
func Users() ([]UserStat, error) {
|
||||
return []UserStat{}, common.ErrNotImplementedError
|
||||
}
|
||||
20
vendor/github.com/shirou/gopsutil/internal/common/common.go
generated
vendored
20
vendor/github.com/shirou/gopsutil/internal/common/common.go
generated
vendored
@@ -10,6 +10,7 @@ import (
|
||||
"bufio"
|
||||
"bytes"
|
||||
"errors"
|
||||
"fmt"
|
||||
"io/ioutil"
|
||||
"log"
|
||||
"net/url"
|
||||
@@ -41,9 +42,8 @@ func (i Invoke) Command(name string, arg ...string) ([]byte, error) {
|
||||
}
|
||||
|
||||
type FakeInvoke struct {
|
||||
CommandExpectedDir string // CommandExpectedDir specifies dir which includes expected outputs.
|
||||
Suffix string // Suffix species expected file name suffix such as "fail"
|
||||
Error error // If Error specfied, return the error.
|
||||
Suffix string // Suffix species expected file name suffix such as "fail"
|
||||
Error error // If Error specfied, return the error.
|
||||
}
|
||||
|
||||
// Command in FakeInvoke returns from expected file if exists.
|
||||
@@ -54,22 +54,18 @@ func (i FakeInvoke) Command(name string, arg ...string) ([]byte, error) {
|
||||
|
||||
arch := runtime.GOOS
|
||||
|
||||
fname := strings.Join(append([]string{name}, arg...), "")
|
||||
commandName := filepath.Base(name)
|
||||
|
||||
fname := strings.Join(append([]string{commandName}, arg...), "")
|
||||
fname = url.QueryEscape(fname)
|
||||
var dir string
|
||||
if i.CommandExpectedDir == "" {
|
||||
dir = "expected"
|
||||
} else {
|
||||
dir = i.CommandExpectedDir
|
||||
}
|
||||
fpath := path.Join(dir, arch, fname)
|
||||
fpath := path.Join("testdata", arch, fname)
|
||||
if i.Suffix != "" {
|
||||
fpath += "_" + i.Suffix
|
||||
}
|
||||
if PathExists(fpath) {
|
||||
return ioutil.ReadFile(fpath)
|
||||
}
|
||||
return exec.Command(name, arg...).Output()
|
||||
return []byte{}, fmt.Errorf("could not find testdata: %s", fpath)
|
||||
}
|
||||
|
||||
var ErrNotImplementedError = errors.New("not implemented yet")
|
||||
|
||||
2
vendor/github.com/shirou/gopsutil/mem/mem_fallback.go
generated
vendored
2
vendor/github.com/shirou/gopsutil/mem/mem_fallback.go
generated
vendored
@@ -1,4 +1,4 @@
|
||||
// +build !darwin,!linux,!freebsd,!openbsd,!windows
|
||||
// +build !darwin,!linux,!freebsd,!openbsd,!solaris,!windows
|
||||
|
||||
package mem
|
||||
|
||||
|
||||
109
vendor/github.com/shirou/gopsutil/mem/mem_solaris.go
generated
vendored
Normal file
109
vendor/github.com/shirou/gopsutil/mem/mem_solaris.go
generated
vendored
Normal file
@@ -0,0 +1,109 @@
|
||||
package mem
|
||||
|
||||
import (
|
||||
"errors"
|
||||
"fmt"
|
||||
"os/exec"
|
||||
"regexp"
|
||||
"strconv"
|
||||
"strings"
|
||||
|
||||
"github.com/shirou/gopsutil/internal/common"
|
||||
)
|
||||
|
||||
// VirtualMemory for Solaris is a minimal implementation which only returns
|
||||
// what Nomad needs. It does take into account global vs zone, however.
|
||||
func VirtualMemory() (*VirtualMemoryStat, error) {
|
||||
result := &VirtualMemoryStat{}
|
||||
|
||||
zoneName, err := zoneName()
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
if zoneName == "global" {
|
||||
cap, err := globalZoneMemoryCapacity()
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
result.Total = cap
|
||||
} else {
|
||||
cap, err := nonGlobalZoneMemoryCapacity()
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
result.Total = cap
|
||||
}
|
||||
|
||||
return result, nil
|
||||
}
|
||||
|
||||
func SwapMemory() (*SwapMemoryStat, error) {
|
||||
return nil, common.ErrNotImplementedError
|
||||
}
|
||||
|
||||
func zoneName() (string, error) {
|
||||
zonename, err := exec.LookPath("/usr/bin/zonename")
|
||||
if err != nil {
|
||||
return "", err
|
||||
}
|
||||
|
||||
out, err := invoke.Command(zonename)
|
||||
if err != nil {
|
||||
return "", err
|
||||
}
|
||||
|
||||
return strings.TrimSpace(string(out)), nil
|
||||
}
|
||||
|
||||
var globalZoneMemoryCapacityMatch = regexp.MustCompile(`memory size: ([\d]+) Megabytes`)
|
||||
|
||||
func globalZoneMemoryCapacity() (uint64, error) {
|
||||
prtconf, err := exec.LookPath("/usr/sbin/prtconf")
|
||||
if err != nil {
|
||||
return 0, err
|
||||
}
|
||||
|
||||
out, err := invoke.Command(prtconf)
|
||||
if err != nil {
|
||||
return 0, err
|
||||
}
|
||||
|
||||
match := globalZoneMemoryCapacityMatch.FindAllStringSubmatch(string(out), -1)
|
||||
if len(match) != 1 {
|
||||
return 0, errors.New("memory size not contained in output of /usr/sbin/prtconf")
|
||||
}
|
||||
|
||||
totalMB, err := strconv.ParseUint(match[0][1], 10, 64)
|
||||
if err != nil {
|
||||
return 0, err
|
||||
}
|
||||
|
||||
return totalMB * 1024 * 1024, nil
|
||||
}
|
||||
|
||||
var kstatMatch = regexp.MustCompile(`([^\s]+)[\s]+([^\s]*)`)
|
||||
|
||||
func nonGlobalZoneMemoryCapacity() (uint64, error) {
|
||||
kstat, err := exec.LookPath("/usr/bin/kstat")
|
||||
if err != nil {
|
||||
return 0, err
|
||||
}
|
||||
|
||||
out, err := invoke.Command(kstat, "-p", "-c", "zone_memory_cap", "memory_cap:*:*:physcap")
|
||||
if err != nil {
|
||||
return 0, err
|
||||
}
|
||||
|
||||
kstats := kstatMatch.FindAllStringSubmatch(string(out), -1)
|
||||
if len(kstats) != 1 {
|
||||
return 0, fmt.Errorf("expected 1 kstat, found %d", len(kstats))
|
||||
}
|
||||
|
||||
memSizeBytes, err := strconv.ParseUint(kstats[0][2], 10, 64)
|
||||
if err != nil {
|
||||
return 0, err
|
||||
}
|
||||
|
||||
return memSizeBytes, nil
|
||||
}
|
||||
42
vendor/vendor.json
vendored
42
vendor/vendor.json
vendored
@@ -1051,52 +1051,52 @@
|
||||
"revisionTime": "2016-04-29T17:20:22Z"
|
||||
},
|
||||
{
|
||||
"checksumSHA1": "cDsY1Bw9zumq+u6RTpp3ubJPTMk=",
|
||||
"checksumSHA1": "cpqxlYWQDDhWffBhX8mOf7qKL9E=",
|
||||
"path": "github.com/shirou/gopsutil",
|
||||
"revision": "d4c8874c1901eea436d4b8df4f67a32a56a1b950",
|
||||
"revisionTime": "2017-03-13T16:51:04Z"
|
||||
"revision": "98d5de7ce9acd16b430be82ef4448ca578537a4a",
|
||||
"revisionTime": "2017-03-15T14:36:14Z"
|
||||
},
|
||||
{
|
||||
"checksumSHA1": "9LIkEB03iL8LhQNZ0ydyLxXY32A=",
|
||||
"checksumSHA1": "j9WpHCDGE8l+6Aa1hLItk7gTQF8=",
|
||||
"path": "github.com/shirou/gopsutil/cpu",
|
||||
"revision": "d4c8874c1901eea436d4b8df4f67a32a56a1b950",
|
||||
"revisionTime": "2017-03-13T16:51:04Z"
|
||||
"revision": "98d5de7ce9acd16b430be82ef4448ca578537a4a",
|
||||
"revisionTime": "2017-03-15T14:36:14Z"
|
||||
},
|
||||
{
|
||||
"checksumSHA1": "EHW4AH6SCfTJGTrnqZ56PiOrJ7o=",
|
||||
"path": "github.com/shirou/gopsutil/disk",
|
||||
"revision": "d4c8874c1901eea436d4b8df4f67a32a56a1b950",
|
||||
"revisionTime": "2017-03-13T16:51:04Z"
|
||||
"revision": "98d5de7ce9acd16b430be82ef4448ca578537a4a",
|
||||
"revisionTime": "2017-03-15T14:36:14Z"
|
||||
},
|
||||
{
|
||||
"checksumSHA1": "fe9lD1jnx0DF2ByG3/FeIbJRI4w=",
|
||||
"checksumSHA1": "iT9WvLvEKQREitNP/mAyN145Rpk=",
|
||||
"path": "github.com/shirou/gopsutil/host",
|
||||
"revision": "d4c8874c1901eea436d4b8df4f67a32a56a1b950",
|
||||
"revisionTime": "2017-03-13T16:51:04Z"
|
||||
"revision": "98d5de7ce9acd16b430be82ef4448ca578537a4a",
|
||||
"revisionTime": "2017-03-15T14:36:14Z"
|
||||
},
|
||||
{
|
||||
"checksumSHA1": "S8QxcgsIi8ckcQRKNGCn4Z5Lymw=",
|
||||
"checksumSHA1": "hKDsT0KAOtA7UqiXYdO0RahnQZ8=",
|
||||
"path": "github.com/shirou/gopsutil/internal/common",
|
||||
"revision": "d4c8874c1901eea436d4b8df4f67a32a56a1b950",
|
||||
"revisionTime": "2017-03-13T16:51:04Z"
|
||||
"revision": "98d5de7ce9acd16b430be82ef4448ca578537a4a",
|
||||
"revisionTime": "2017-03-15T14:36:14Z"
|
||||
},
|
||||
{
|
||||
"checksumSHA1": "XQwjGKI51Y3aQ3/jNyRh9Gnprgg=",
|
||||
"checksumSHA1": "zkNNauN735M7Jghr+MsARbb+/xQ=",
|
||||
"path": "github.com/shirou/gopsutil/mem",
|
||||
"revision": "d4c8874c1901eea436d4b8df4f67a32a56a1b950",
|
||||
"revisionTime": "2017-03-13T16:51:04Z"
|
||||
"revision": "98d5de7ce9acd16b430be82ef4448ca578537a4a",
|
||||
"revisionTime": "2017-03-15T14:36:14Z"
|
||||
},
|
||||
{
|
||||
"checksumSHA1": "zqdJo70e2vfUaNAs8hs3CA7ZmfQ=",
|
||||
"path": "github.com/shirou/gopsutil/net",
|
||||
"revision": "d4c8874c1901eea436d4b8df4f67a32a56a1b950",
|
||||
"revisionTime": "2017-03-13T16:51:04Z"
|
||||
"revision": "98d5de7ce9acd16b430be82ef4448ca578537a4a",
|
||||
"revisionTime": "2017-03-15T14:36:14Z"
|
||||
},
|
||||
{
|
||||
"checksumSHA1": "g/TH+QY+CH4rJTg0BJ1vdLWIFaA=",
|
||||
"path": "github.com/shirou/gopsutil/process",
|
||||
"revision": "d4c8874c1901eea436d4b8df4f67a32a56a1b950",
|
||||
"revisionTime": "2017-03-13T16:51:04Z"
|
||||
"revision": "98d5de7ce9acd16b430be82ef4448ca578537a4a",
|
||||
"revisionTime": "2017-03-15T14:36:14Z"
|
||||
},
|
||||
{
|
||||
"checksumSHA1": "Nve7SpDmjsv6+rhkXAkfg/UQx94=",
|
||||
|
||||
Reference in New Issue
Block a user