Merge pull request #351 from danielnelson/io-counters-for-names

Make IOCounters a variadic function
This commit is contained in:
shirou 2017-04-14 12:53:08 +09:00 committed by GitHub
commit 70693b6a3d
8 changed files with 7 additions and 11 deletions

View File

@ -62,7 +62,3 @@ func (d IOCountersStat) String() string {
s, _ := json.Marshal(d)
return string(s)
}
func IOCounters() (map[string]IOCountersStat, error) {
return IOCountersForNames([]string{})
}

View File

@ -34,7 +34,7 @@ import (
"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 {
return nil, errors.New("Unable to fetch disk list")
}

View File

@ -5,6 +5,6 @@ package disk
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
}

View File

@ -4,7 +4,7 @@ package disk
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
}

View File

@ -94,7 +94,7 @@ func Partitions(all bool) ([]PartitionStat, error) {
return ret, nil
}
func IOCountersForNames(names []string) (map[string]IOCountersStat, error) {
func IOCounters(names ...string) (map[string]IOCountersStat, error) {
// statinfo->devinfo->devstat
// /usr/include/devinfo.h
ret := make(map[string]IOCountersStat)

View File

@ -272,7 +272,7 @@ func getFileSystems() ([]string, error) {
return ret, nil
}
func IOCountersForNames(names []string) (map[string]IOCountersStat, error) {
func IOCounters(names ...string) (map[string]IOCountersStat, error) {
filename := common.HostProc("diskstats")
lines, err := common.ReadLines(filename)
if err != nil {

View File

@ -63,7 +63,7 @@ func Partitions(all bool) ([]PartitionStat, error) {
return ret, nil
}
func IOCountersForNames(names []string) (map[string]IOCountersStat, error) {
func IOCounters(names ...string) (map[string]IOCountersStat, error) {
ret := make(map[string]IOCountersStat)
r, err := syscall.Sysctl("hw.diskstats")

View File

@ -129,7 +129,7 @@ func Partitions(all bool) ([]PartitionStat, error) {
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)
var dst []Win32_PerfFormattedData