Documentation
¶
Index ¶
- Variables
- func BootTimeWithContext(ctx context.Context, enableCache bool) (uint64, error)
- func GetEnvWithContext(ctx context.Context, key string, dfault string, combineWith ...string) string
- func GetOSReleaseWithContext(ctx context.Context) (platform string, version string, err error)
- func HostEtcWithContext(ctx context.Context, combineWith ...string) string
- func HostProcWithContext(ctx context.Context, combineWith ...string) string
- func HostRootWithContext(ctx context.Context, combineWith ...string) string
- func NewProcess(pid int32) *proc
- func PathExists(filename string) bool
- func Percent(interval time.Duration, percpu bool) ([]float64, error)
- func PercentTotal(interval time.Duration) (float64, error)
- func PercentWithContext(ctx context.Context, interval time.Duration, percpu bool) ([]float64, error)
- func ReadFile(filename string) (string, error)
- func ReadLine(filename string, prefix string) (string, error)
- func ReadLines(filename string) ([]string, error)
- func ReadLinesOffsetN(filename string, offset uint, n int) ([]string, error)
- func Sleep(ctx context.Context, interval time.Duration) error
- func VirtualizationWithContext(ctx context.Context) (string, string, error)
- type EnvKeyType
- type EnvMap
- type PageFaultsStat
- type TimesStat
Constants ¶
This section is empty.
Variables ¶
var ClocksPerSec = float64(100)
var EnvKey = EnvKeyType("env")
EnvKey is a context key that can be used to set programmatically the environment gopsutil relies on to perform calls against the OS. Example of use:
ctx := context.WithValue(context.Background(), common.EnvKey, EnvMap{common.HostProcEnvKey: "/myproc"}) avg, err := load.AvgWithContext(ctx)
Functions ¶
func BootTimeWithContext ¶
func GetEnvWithContext ¶
func GetEnvWithContext(ctx context.Context, key string, dfault string, combineWith ...string) string
GetEnvWithContext retrieves the environment variable key. If it does not exist it returns the default. The context may optionally contain a map superseding os.EnvKey.
func GetOSReleaseWithContext ¶
func HostEtcWithContext ¶
func HostProcWithContext ¶
func HostRootWithContext ¶
func NewProcess ¶
func NewProcess(pid int32) *proc
func PathExists ¶
func PercentWithContext ¶
func ReadLines ¶
ReadLines reads contents from a file and splits them by new lines. A convenience wrapper to ReadLinesOffsetN(filename, 0, -1).
func ReadLinesOffsetN ¶
ReadLinesOffsetN reads contents from file and splits them by new line. The offset tells at which line number to start. The count determines the number of lines to read (starting from offset): n >= 0: at most n lines n < 0: whole file
Types ¶
type EnvKeyType ¶
type EnvKeyType string
type EnvMap ¶
type EnvMap map[EnvKeyType]string
type PageFaultsStat ¶
type TimesStat ¶
type TimesStat struct { CPU string `json:"cpu"` User float64 `json:"user"` System float64 `json:"system"` Idle float64 `json:"idle"` Nice float64 `json:"nice"` Iowait float64 `json:"iowait"` Irq float64 `json:"irq"` Softirq float64 `json:"softirq"` Steal float64 `json:"steal"` Guest float64 `json:"guest"` GuestNice float64 `json:"guestNice"` }
TimesStat contains the amounts of time the CPU has spent performing different kinds of work. Time units are in seconds. It is based on linux /proc/stat file.