-
-
Notifications
You must be signed in to change notification settings - Fork 1.6k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
223 changed files
with
303 additions
and
15 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -20,4 +20,3 @@ jobs: | |
with: | ||
args: --verbose | ||
version: latest | ||
working-directory: v3 |
Empty file.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,74 @@ | ||
// +build aix | ||
|
||
package cpu | ||
|
||
import ( | ||
"context" | ||
|
||
"github.com/power-devops/perfstat" | ||
) | ||
|
||
func Times(percpu bool) ([]TimesStat, error) { | ||
return TimesWithContext(context.Background(), percpu) | ||
} | ||
|
||
func TimesWithContext(ctx context.Context, percpu bool) ([]TimesStat, error) { | ||
var ret []TimesStat | ||
if percpu { | ||
cpus, err := perfstat.CpuStat() | ||
if err != nil { | ||
return nil, err | ||
} | ||
for _, c := range cpus { | ||
ct := &TimesStat{ | ||
CPU: c.Name, | ||
Idle: float64(c.Idle), | ||
User: float64(c.User), | ||
System: float64(c.Sys), | ||
Iowait: float64(c.Wait), | ||
} | ||
ret = append(ret, *ct) | ||
} | ||
} else { | ||
c, err := perfstat.CpuUtilTotalStat() | ||
if err != nil { | ||
return nil, err | ||
} | ||
ct := &TimesStat{ | ||
CPU: "cpu-total", | ||
Idle: float64(c.IdlePct), | ||
User: float64(c.UserPct), | ||
System: float64(c.KernPct), | ||
Iowait: float64(c.WaitPct), | ||
} | ||
ret = append(ret, *ct) | ||
} | ||
return ret, nil | ||
} | ||
|
||
func Info() ([]InfoStat, error) { | ||
return InfoWithContext(context.Background()) | ||
} | ||
|
||
func InfoWithContext(ctx context.Context) ([]InfoStat, error) { | ||
c, err := perfstat.CpuTotalStat() | ||
if err != nil { | ||
return nil, err | ||
} | ||
info := InfoStat{ | ||
CPU: 0, | ||
Mhz: float64(c.ProcessorHz / 1000000), | ||
Cores: int32(c.NCpusCfg), | ||
} | ||
result := []InfoStat{info}; | ||
return result, nil | ||
} | ||
|
||
func CountsWithContext(ctx context.Context, logical bool) (int, error) { | ||
c, err := perfstat.CpuTotalStat() | ||
if err != nil { | ||
return 0, err | ||
} | ||
return c.NCpusCfg, nil | ||
} | ||
|
Empty file.
Empty file.
Empty file.
Empty file.
Empty file.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Empty file.
Empty file.
Empty file.
Empty file.
Empty file.
Empty file.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Empty file.
Empty file.
Empty file.
Empty file.
Empty file.
Empty file.
Empty file.
Empty file.
Empty file.
Empty file.
Empty file.
Empty file.
Empty file.
Empty file.
Empty file.
Empty file.
Empty file.
Empty file.
Empty file.
Empty file.
Empty file.
Empty file.
Empty file.
Empty file.
Empty file.
Empty file.
Empty file.
Empty file.
Empty file.
Empty file.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,86 @@ | ||
// +build aix | ||
|
||
package disk | ||
|
||
import ( | ||
"context" | ||
"fmt" | ||
|
||
"github.com/power-devops/perfstat" | ||
"github.com/shirou/gopsutil/v3/internal/common" | ||
) | ||
|
||
var FSType map[int]string | ||
|
||
func init() { | ||
FSType = map[int]string{0: "jfs2", 1: "namefs", 2: "nfs", 3: "jfs", 5: "cdrom", 6: "proc", | ||
16: "special-fs", 17: "cache-fs", 18: "nfs3", 19: "automount-fs", 20: "pool-fs", 32: "vxfs", | ||
33: "veritas-fs", 34: "udfs", 35: "nfs4", 36: "nfs4-pseudo", 37: "smbfs", 38: "mcr-pseudofs", | ||
39: "ahafs", 40: "sterm-nfs", 41: "asmfs" } | ||
} | ||
|
||
func PartitionsWithContext(ctx context.Context, all bool) ([]PartitionStat, error) { | ||
f, err := perfstat.FileSystemStat() | ||
if err != nil { | ||
return nil, err | ||
} | ||
ret := make([]PartitionStat, len(f)) | ||
|
||
for _, fs := range f { | ||
fstyp, exists := FSType[fs.FSType] | ||
if ! exists { | ||
fstyp = "unknown" | ||
} | ||
info := PartitionStat{ | ||
Device: fs.Device, | ||
Mountpoint: fs.MountPoint, | ||
Fstype: fstyp, | ||
} | ||
ret = append(ret,info) | ||
} | ||
|
||
return ret, err | ||
} | ||
|
||
func IOCountersWithContext(ctx context.Context, names ...string) (map[string]IOCountersStat, error) { | ||
return nil, common.ErrNotImplementedError | ||
} | ||
|
||
func UsageWithContext(ctx context.Context, path string) (*UsageStat, error) { | ||
f, err := perfstat.FileSystemStat() | ||
if err != nil { | ||
return nil, err | ||
} | ||
|
||
blocksize := uint64(512) | ||
for _, fs := range f { | ||
if path == fs.MountPoint { | ||
fstyp, exists := FSType[fs.FSType] | ||
if ! exists { | ||
fstyp = "unknown" | ||
} | ||
info := UsageStat{ | ||
Path: path, | ||
Fstype: fstyp, | ||
Total: uint64(fs.TotalBlocks) * blocksize, | ||
Free: uint64(fs.FreeBlocks) * blocksize, | ||
Used: uint64(fs.TotalBlocks - fs.FreeBlocks) * blocksize, | ||
InodesTotal: uint64(fs.TotalInodes), | ||
InodesFree: uint64(fs.FreeInodes), | ||
InodesUsed: uint64(fs.TotalInodes - fs.FreeInodes), | ||
} | ||
info.UsedPercent = (float64(info.Used) / float64(info.Total)) * 100.0 | ||
info.InodesUsedPercent = (float64(info.InodesUsed) / float64(info.InodesTotal)) * 100.0 | ||
return &info, nil | ||
} | ||
} | ||
return nil, fmt.Errorf("mountpoint %s not found", path) | ||
} | ||
|
||
func SerialNumberWithContext(ctx context.Context, name string) (string, error) { | ||
return "", common.ErrNotImplementedError | ||
} | ||
|
||
func LabelWithContext(ctx context.Context, name string) (string, error) { | ||
return "", common.ErrNotImplementedError | ||
} |
Empty file.
Empty file.
Empty file.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Empty file.
Empty file.
Empty file.
Empty file.
Empty file.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Empty file.
Empty file.
Empty file.
Empty file.
Empty file.
Empty file.
Empty file.
Empty file.
Empty file.
Empty file.
Empty file.
Empty file.
Empty file.
Empty file.
Empty file.
Empty file.
Empty file.
Empty file.
Empty file.
Empty file.
Empty file.
Empty file.
Empty file.
Empty file.
Empty file.
Empty file.
Empty file.
Empty file.
Empty file.
Empty file.
Empty file.
Empty file.
Empty file.
Empty file.
Empty file.
Empty file.
Empty file.
Empty file.
Empty file.
Empty file.
Empty file.
Empty file.
Empty file.
Empty file.
Empty file.
Empty file.
Empty file.
Empty file.
Empty file.
Empty file.
Empty file.
Empty file.
Empty file.
Empty file.
Empty file.
Empty file.
Empty file.
Empty file.
Empty file.
Empty file.
Empty file.
Empty file.
Empty file.
Empty file.
Empty file.
Empty file.
Empty file.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Empty file.
Empty file.
Empty file.
Empty file.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,71 @@ | ||
// +build aix | ||
|
||
package load | ||
|
||
/* | ||
#cgo LDFLAGS: -L/usr/lib -lperfstat | ||
#include <libperfstat.h> | ||
#include <procinfo.h> | ||
*/ | ||
import "C" | ||
|
||
import ( | ||
"context" | ||
"unsafe" | ||
|
||
"github.com/power-devops/perfstat" | ||
) | ||
|
||
func Avg() (*AvgStat, error) { | ||
return AvgWithContext(context.Background()) | ||
} | ||
|
||
func AvgWithContext(ctx context.Context) (*AvgStat, error) { | ||
c, err := perfstat.CpuTotalStat() | ||
if err != nil { | ||
return nil, err | ||
} | ||
ret := &AvgStat{ | ||
Load1: float64(c.LoadAvg1), | ||
Load5: float64(c.LoadAvg5), | ||
Load15: float64(c.LoadAvg15), | ||
} | ||
|
||
return ret, nil | ||
} | ||
|
||
// Misc returns miscellaneous host-wide statistics. | ||
// darwin use ps command to get process running/blocked count. | ||
// Almost same as Darwin implementation, but state is different. | ||
func Misc() (*MiscStat, error) { | ||
return MiscWithContext(context.Background()) | ||
} | ||
|
||
func MiscWithContext(ctx context.Context) (*MiscStat, error) { | ||
info := C.struct_procentry64{} | ||
cpid := C.pid_t(0) | ||
|
||
ret := MiscStat{} | ||
for { | ||
// getprocs first argument is a void* | ||
num, err := C.getprocs64(unsafe.Pointer(&info), C.sizeof_struct_procentry64, nil, 0, &cpid, 1) | ||
if err != nil { | ||
return nil, err | ||
} | ||
|
||
ret.ProcsTotal++ | ||
switch info.pi_state { | ||
case C.SACTIVE: | ||
ret.ProcsRunning++ | ||
case C.SSTOP: | ||
ret.ProcsBlocked++ | ||
} | ||
|
||
if num == 0 { | ||
break | ||
} | ||
} | ||
return &ret, nil | ||
} | ||
|
Empty file.
Empty file.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Empty file.
Empty file.
Empty file.
Empty file.
Empty file.
Empty file.
Empty file.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,58 @@ | ||
// +build aix | ||
|
||
package mem | ||
|
||
import ( | ||
"context" | ||
|
||
"github.com/power-devops/perfstat" | ||
) | ||
|
||
func VirtualMemory() (*VirtualMemoryStat, error) { | ||
return VirtualMemoryWithContext(context.Background()) | ||
} | ||
|
||
func VirtualMemoryWithContext(ctx context.Context) (*VirtualMemoryStat, error) { | ||
m, err := perfstat.MemoryTotalStat() | ||
if err != nil { | ||
return nil, err | ||
} | ||
pagesize := uint64(4096) | ||
ret := VirtualMemoryStat{ | ||
Total: uint64(m.RealTotal) * pagesize, | ||
Available: uint64(m.RealAvailable) * pagesize, | ||
Free: uint64(m.RealFree) * pagesize, | ||
Used: uint64(m.RealInUse) * pagesize, | ||
UsedPercent: 100 * float64(m.RealInUse) / float64(m.RealTotal), | ||
Active: uint64(m.VirtualActive) * pagesize, | ||
SwapTotal: uint64(m.PgSpTotal) * pagesize, | ||
SwapFree: uint64(m.PgSpFree) * pagesize, | ||
} | ||
return &ret, nil | ||
} | ||
|
||
func SwapMemory() (*SwapMemoryStat, error) { | ||
return SwapMemoryWithContext(context.Background()) | ||
} | ||
|
||
func SwapMemoryWithContext(ctx context.Context) (*SwapMemoryStat, error) { | ||
m, err := perfstat.MemoryTotalStat() | ||
if err != nil { | ||
return nil, err | ||
} | ||
pagesize := uint64(4096) | ||
swapUsed := uint64(m.PgSpTotal - m.PgSpFree - m.PgSpRsvd) * pagesize | ||
swapTotal := uint64(m.PgSpTotal) * pagesize | ||
ret := SwapMemoryStat{ | ||
Total: swapTotal, | ||
Free: uint64(m.PgSpFree) * pagesize, | ||
Used: swapUsed, | ||
UsedPercent: float64(100 * swapUsed) / float64(swapTotal), | ||
Sin: uint64(m.PgSpIn), | ||
Sout: uint64(m.PgSpOut), | ||
PgIn: uint64(m.PageIn), | ||
PgOut: uint64(m.PageOut), | ||
PgFault: uint64(m.PageFaults), | ||
} | ||
return &ret, nil | ||
} |
Empty file.
Empty file.
Empty file.
Empty file.
Empty file.
Empty file.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Empty file.
Empty file.
Empty file.
Empty file.
Empty file.
Empty file.
Empty file.
Empty file.
Empty file.
Empty file.
Empty file.
Empty file.
Empty file.
Empty file.
Empty file.
Empty file.
Empty file.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Empty file.
Empty file.
Empty file.
Empty file.
Empty file.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Empty file.
Empty file.
Empty file.
Empty file.
Empty file.
Empty file.
Empty file.
Empty file.
Empty file.
Empty file.
Empty file.
Empty file.
Empty file.
Empty file.
Empty file.
Empty file.
Empty file.
Empty file.
Empty file.
Empty file.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Empty file.
Empty file.
Empty file.
Empty file.
Empty file.
Empty file.
Empty file.
Empty file.
Empty file.
Empty file.
Empty file.
Empty file.
Empty file.
Empty file.
Empty file.
Empty file.
Empty file.
Empty file.
Empty file.
Empty file.
Empty file.
Empty file.
Empty file.
Empty file.
Empty file.
Empty file.
Empty file.