mirror of
https://github.com/shirou/gopsutil.git
synced 2025-05-04 22:17:34 +08:00
Merge pull request #351 from danielnelson/io-counters-for-names
Make IOCounters a variadic function
This commit is contained in:
commit
70693b6a3d
@ -62,7 +62,3 @@ func (d IOCountersStat) String() string {
|
|||||||
s, _ := json.Marshal(d)
|
s, _ := json.Marshal(d)
|
||||||
return string(s)
|
return string(s)
|
||||||
}
|
}
|
||||||
|
|
||||||
func IOCounters() (map[string]IOCountersStat, error) {
|
|
||||||
return IOCountersForNames([]string{})
|
|
||||||
}
|
|
||||||
|
@ -34,7 +34,7 @@ import (
|
|||||||
"github.com/shirou/gopsutil/internal/common"
|
"github.com/shirou/gopsutil/internal/common"
|
||||||
)
|
)
|
||||||
|
|
||||||
func IOCountersForNames(names []string) (map[string]IOCountersStat, error) {
|
func IOCounters(names ...string) (map[string]IOCountersStat, error) {
|
||||||
if C.StartIOCounterFetch() == 0 {
|
if C.StartIOCounterFetch() == 0 {
|
||||||
return nil, errors.New("Unable to fetch disk list")
|
return nil, errors.New("Unable to fetch disk list")
|
||||||
}
|
}
|
||||||
|
@ -5,6 +5,6 @@ package disk
|
|||||||
|
|
||||||
import "github.com/shirou/gopsutil/internal/common"
|
import "github.com/shirou/gopsutil/internal/common"
|
||||||
|
|
||||||
func IOCountersForNames(names []string) (map[string]IOCountersStat, error) {
|
func IOCounters(names ...string) (map[string]IOCountersStat, error) {
|
||||||
return nil, common.ErrNotImplementedError
|
return nil, common.ErrNotImplementedError
|
||||||
}
|
}
|
||||||
|
@ -4,7 +4,7 @@ package disk
|
|||||||
|
|
||||||
import "github.com/shirou/gopsutil/internal/common"
|
import "github.com/shirou/gopsutil/internal/common"
|
||||||
|
|
||||||
func IOCountersForNames(names []string) (map[string]IOCountersStat, error) {
|
func IOCounters(names ...string) (map[string]IOCountersStat, error) {
|
||||||
return nil, common.ErrNotImplementedError
|
return nil, common.ErrNotImplementedError
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -94,7 +94,7 @@ func Partitions(all bool) ([]PartitionStat, error) {
|
|||||||
return ret, nil
|
return ret, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func IOCountersForNames(names []string) (map[string]IOCountersStat, error) {
|
func IOCounters(names ...string) (map[string]IOCountersStat, error) {
|
||||||
// statinfo->devinfo->devstat
|
// statinfo->devinfo->devstat
|
||||||
// /usr/include/devinfo.h
|
// /usr/include/devinfo.h
|
||||||
ret := make(map[string]IOCountersStat)
|
ret := make(map[string]IOCountersStat)
|
||||||
|
@ -272,7 +272,7 @@ func getFileSystems() ([]string, error) {
|
|||||||
return ret, nil
|
return ret, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func IOCountersForNames(names []string) (map[string]IOCountersStat, error) {
|
func IOCounters(names ...string) (map[string]IOCountersStat, error) {
|
||||||
filename := common.HostProc("diskstats")
|
filename := common.HostProc("diskstats")
|
||||||
lines, err := common.ReadLines(filename)
|
lines, err := common.ReadLines(filename)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
@ -63,7 +63,7 @@ func Partitions(all bool) ([]PartitionStat, error) {
|
|||||||
return ret, nil
|
return ret, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func IOCountersForNames(names []string) (map[string]IOCountersStat, error) {
|
func IOCounters(names ...string) (map[string]IOCountersStat, error) {
|
||||||
ret := make(map[string]IOCountersStat)
|
ret := make(map[string]IOCountersStat)
|
||||||
|
|
||||||
r, err := syscall.Sysctl("hw.diskstats")
|
r, err := syscall.Sysctl("hw.diskstats")
|
||||||
|
@ -129,7 +129,7 @@ func Partitions(all bool) ([]PartitionStat, error) {
|
|||||||
return ret, nil
|
return ret, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func IOCountersForNames(names []string) (map[string]IOCountersStat, error) {
|
func IOCounters(names ...string) (map[string]IOCountersStat, error) {
|
||||||
ret := make(map[string]IOCountersStat, 0)
|
ret := make(map[string]IOCountersStat, 0)
|
||||||
var dst []Win32_PerfFormattedData
|
var dst []Win32_PerfFormattedData
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user