mirror of
https://github.com/shirou/gopsutil.git
synced 2025-05-02 22:17:08 +08:00
commit
381f7cc0bf
@ -9,7 +9,7 @@ import (
|
|||||||
"golang.org/x/sys/unix"
|
"golang.org/x/sys/unix"
|
||||||
)
|
)
|
||||||
|
|
||||||
// Usage returns a file system usage. path is a filessytem path such
|
// Usage returns a file system usage. path is a filesystem path such
|
||||||
// as "/", not device file path like "/dev/vda1". If you want to use
|
// as "/", not device file path like "/dev/vda1". If you want to use
|
||||||
// a return value of disk.Partitions, use "Mountpoint" not "Device".
|
// a return value of disk.Partitions, use "Mountpoint" not "Device".
|
||||||
func Usage(path string) (*UsageStat, error) {
|
func Usage(path string) (*UsageStat, error) {
|
||||||
|
@ -269,7 +269,7 @@ func CgroupMemDockerWithContext(ctx context.Context, containerID string) (*Cgrou
|
|||||||
return CgroupMem(containerID, common.HostSys("fs/cgroup/memory/docker"))
|
return CgroupMem(containerID, common.HostSys("fs/cgroup/memory/docker"))
|
||||||
}
|
}
|
||||||
|
|
||||||
// getCgroupFilePath constructs file path to get targetted stats file.
|
// getCgroupFilePath constructs file path to get targeted stats file.
|
||||||
func getCgroupFilePath(containerID, base, target, file string) string {
|
func getCgroupFilePath(containerID, base, target, file string) string {
|
||||||
if len(base) == 0 {
|
if len(base) == 0 {
|
||||||
base = common.HostSys(fmt.Sprintf("fs/cgroup/%s/docker", target))
|
base = common.HostSys(fmt.Sprintf("fs/cgroup/%s/docker", target))
|
||||||
|
@ -657,7 +657,7 @@ func SensorsTemperaturesWithContext(ctx context.Context) ([]TemperatureStat, err
|
|||||||
label = fmt.Sprintf("%s_", strings.Join(strings.Split(strings.TrimSpace(strings.ToLower(string(c))), " "), ""))
|
label = fmt.Sprintf("%s_", strings.Join(strings.Split(strings.TrimSpace(strings.ToLower(string(c))), " "), ""))
|
||||||
}
|
}
|
||||||
|
|
||||||
// Get the name of the tempearture you are reading
|
// Get the name of the temperature you are reading
|
||||||
name, err := ioutil.ReadFile(filepath.Join(filepath.Dir(file), "name"))
|
name, err := ioutil.ReadFile(filepath.Join(filepath.Dir(file), "name"))
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return temperatures, err
|
return temperatures, err
|
||||||
|
@ -143,7 +143,7 @@ func TestKernelVersion(t *testing.T) {
|
|||||||
t.Errorf("KernelVersion() failed, %v", err)
|
t.Errorf("KernelVersion() failed, %v", err)
|
||||||
}
|
}
|
||||||
if version == "" {
|
if version == "" {
|
||||||
t.Errorf("KernelVersion() retuns empty: %s", version)
|
t.Errorf("KernelVersion() returns empty: %s", version)
|
||||||
}
|
}
|
||||||
|
|
||||||
t.Logf("KernelVersion(): %s", version)
|
t.Logf("KernelVersion(): %s", version)
|
||||||
@ -155,7 +155,7 @@ func TestPlatformInformation(t *testing.T) {
|
|||||||
t.Errorf("PlatformInformation() failed, %v", err)
|
t.Errorf("PlatformInformation() failed, %v", err)
|
||||||
}
|
}
|
||||||
if platform == "" {
|
if platform == "" {
|
||||||
t.Errorf("PlatformInformation() retuns empty: %v", platform)
|
t.Errorf("PlatformInformation() returns empty: %v", platform)
|
||||||
}
|
}
|
||||||
|
|
||||||
t.Logf("PlatformInformation(): %v, %v, %v", platform, family, version)
|
t.Logf("PlatformInformation(): %v, %v, %v", platform, family, version)
|
||||||
|
@ -100,7 +100,7 @@ type xswdev struct {
|
|||||||
Used int32 // Used is the number of blocks used
|
Used int32 // Used is the number of blocks used
|
||||||
}
|
}
|
||||||
|
|
||||||
// xswdev11 is a compatiblity for under FreeBSD 11
|
// xswdev11 is a compatibility for under FreeBSD 11
|
||||||
// sys/vm/swap_pager.c
|
// sys/vm/swap_pager.c
|
||||||
type xswdev11 struct {
|
type xswdev11 struct {
|
||||||
Version uint32 // Version is the version
|
Version uint32 // Version is the version
|
||||||
|
@ -42,7 +42,7 @@ func parseNetstatLine(line string) (stat *IOCountersStat, linkID *uint, err erro
|
|||||||
|
|
||||||
base := 1
|
base := 1
|
||||||
numberColumns := len(columns)
|
numberColumns := len(columns)
|
||||||
// sometimes Address is ommitted
|
// sometimes Address is omitted
|
||||||
if numberColumns < 12 {
|
if numberColumns < 12 {
|
||||||
base = 0
|
base = 0
|
||||||
}
|
}
|
||||||
|
@ -45,7 +45,7 @@ func IOCountersWithContext(ctx context.Context, pernic bool) ([]IOCountersStat,
|
|||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
base := 1
|
base := 1
|
||||||
// sometimes Address is ommitted
|
// sometimes Address is omitted
|
||||||
if len(values) < 13 {
|
if len(values) < 13 {
|
||||||
base = 0
|
base = 0
|
||||||
}
|
}
|
||||||
|
@ -41,7 +41,7 @@ func ParseNetstat(output string, mode string,
|
|||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
base := 1
|
base := 1
|
||||||
// sometimes Address is ommitted
|
// sometimes Address is omitted
|
||||||
if len(values) < columns {
|
if len(values) < columns {
|
||||||
base = 0
|
base = 0
|
||||||
}
|
}
|
||||||
|
@ -186,7 +186,7 @@ func (p *Process) ParentWithContext(ctx context.Context) (*Process, error) {
|
|||||||
// Return value could be one of these.
|
// Return value could be one of these.
|
||||||
// R: Running S: Sleep T: Stop I: Idle
|
// R: Running S: Sleep T: Stop I: Idle
|
||||||
// Z: Zombie W: Wait L: Lock
|
// Z: Zombie W: Wait L: Lock
|
||||||
// The charactor is same within all supported platforms.
|
// The character is same within all supported platforms.
|
||||||
func (p *Process) Status() (string, error) {
|
func (p *Process) Status() (string, error) {
|
||||||
return p.StatusWithContext(context.Background())
|
return p.StatusWithContext(context.Background())
|
||||||
}
|
}
|
||||||
|
@ -357,7 +357,7 @@ func Test_Connections(t *testing.T) {
|
|||||||
t.Fatalf("error %v", err)
|
t.Fatalf("error %v", err)
|
||||||
}
|
}
|
||||||
// TODO:
|
// TODO:
|
||||||
// Since go test open no conneciton, ret is empty.
|
// Since go test open no connection, ret is empty.
|
||||||
// should invoke child process or other solutions.
|
// should invoke child process or other solutions.
|
||||||
if len(c) != 0 {
|
if len(c) != 0 {
|
||||||
t.Fatalf("wrong connections")
|
t.Fatalf("wrong connections")
|
||||||
|
Loading…
x
Reference in New Issue
Block a user