Documentation
¶
Overview ¶
Package top wraps Linux 'top' command.
Index ¶
Constants ¶
This section is empty.
Variables ¶
View Source
var DefaultExecPath = "/usr/bin/top"
DefaultExecPath is the default 'top' command path.
View Source
var Headers = []string{
"PID",
"USER",
"PR",
"NI",
"VIRT",
"RES",
"SHR",
"S",
"%CPU",
"%MEM",
"TIME+",
"COMMAND",
}
Headers is the headers in 'top' output.
View Source
var RowSchema = schema.RawData{ IsYAML: false, Columns: []schema.Column{ {Name: "PID", Godoc: "pid of the process", Kind: reflect.Int64}, {Name: "USER", Godoc: "user name", Kind: reflect.String}, {Name: "PR", Godoc: "priority", Kind: reflect.String}, {Name: "NI", Godoc: "nice value of the task", Kind: reflect.String}, {Name: "VIRT", Godoc: "total amount of virtual memory used by the task (in KiB)", Kind: reflect.String}, {Name: "RES", Godoc: "non-swapped physical memory a task is using (in KiB)", Kind: reflect.String}, {Name: "SHR", Godoc: "amount of shared memory available to a task, not all of which is typically resident (in KiB)", Kind: reflect.String}, {Name: "S", Godoc: "process status", Kind: reflect.String}, {Name: "CPUPercent", Godoc: "%CPU", Kind: reflect.Float64}, {Name: "MEMPercent", Godoc: "%MEM", Kind: reflect.Float64}, {Name: "TIME", Godoc: "CPU time (TIME+)", Kind: reflect.String}, {Name: "COMMAND", Godoc: "command", Kind: reflect.String}, }, ColumnsToParse: map[string]schema.RawDataType{ "S": schema.TypeStatus, "VIRT": schema.TypeBytes, "RES": schema.TypeBytes, "SHR": schema.TypeBytes, }, }
RowSchema represents a row in 'top' command output. Reference http://man7.org/linux/man-pages/man1/top.1.html.
Functions ¶
This section is empty.
Types ¶
type Config ¶
type Config struct {
// Exec is the 'top' command path.
// Defaults to '/usr/bin/top'.
Exec string
// Limit limits the iteration of 'top' commands to run before exit.
// If 1, 'top' prints out the current processes and exits.
// It's '-n' flag.
Limit int
// IntervalSecond is the delay time between updates.
// Default is 1 second.
// It's '-d' flag.
IntervalSecond float64
// PID specifies the PID to monitor.
// It's '-p' flag.
PID int64
// Writer stores 'top' command outputs.
Writer io.Writer
// contains filtered or unexported fields
}
Config configures 'top' command runs.
func (*Config) StartStream ¶
StartStream starts 'top' command stream.
type Row ¶
type Row struct {
// PID is pid of the process.
PID int64 `column:"pid"`
// USER is user name.
USER string `column:"user"`
// PR is priority.
PR string `column:"pr"`
// NI is nice value of the task.
NI string `column:"ni"`
// VIRT is total amount of virtual memory used by the task (in KiB).
VIRT string `column:"virt"`
VIRTBytesN uint64 `column:"virt_bytes_n"`
VIRTParsedBytes string `column:"virt_parsed_bytes"`
// RES is non-swapped physical memory a task is using (in KiB).
RES string `column:"res"`
RESBytesN uint64 `column:"res_bytes_n"`
RESParsedBytes string `column:"res_parsed_bytes"`
// SHR is amount of shared memory available to a task, not all of which is typically resident (in KiB).
SHR string `column:"shr"`
SHRBytesN uint64 `column:"shr_bytes_n"`
SHRParsedBytes string `column:"shr_parsed_bytes"`
// S is process status.
S string `column:"s"`
SParsedStatus string `column:"s_parsed_status"`
// CPUPercent is %CPU.
CPUPercent float64 `column:"cpupercent"`
// MEMPercent is %MEM.
MEMPercent float64 `column:"mempercent"`
// TIME is CPU time (TIME+).
TIME string `column:"time"`
// COMMAND is command.
COMMAND string `column:"command"`
}
Row represents a row in 'top' command output.
type Stream ¶
type Stream struct {
// contains filtered or unexported fields
}
Stream provides top command output stream.
Click to show internal directories.
Click to hide internal directories.