Documentation ¶
Index ¶
- func ExecCmd(ctx context.Context, cmd, args string) (string, error)
- func ExecCmdStream(ctx context.Context, cmd, args string) (io.ReadCloser, error)
- func ExecShellCmd(ctx context.Context, cmd string) (string, error)
- func ExecTimedCmd(ctx context.Context, cmd, args string) (string, time.Duration, error)
- func ExecTimedCmdNoOut(ctx context.Context, cmd, args string) (string, time.Duration, error)
- func FindPIDByName(name string) (int, error)
- func ResolveBinary(binname string) (string, error)
- type Proc
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func ExecCmdStream ¶
ExecCmdStream executes a command and returns a Reader, which is useful for streaming
func ExecShellCmd ¶
ExecShellCmd executes a 'bash -c' process, with the passed-in command handed to the -c flag of bash
func ExecTimedCmd ¶
ExecTimedCmd executes a command and returns the combined err/out output and any errors This function also times the command and returns the elapsed milliseconds
func ExecTimedCmdNoOut ¶
ExecTimedCmdNoOut executes a command and returns any errors, but ignores output This function also times the command and returns the elapsed milliseconds
func FindPIDByName ¶
FindPIDByName returns process's PID by its name. Note: if there are multiple processes with same name, first one will be returned.
func ResolveBinary ¶
ResolveBinary finds a binary name along the path and evaluates any symlinks
Types ¶
type Proc ¶
type Proc struct {
// contains filtered or unexported fields
}
Proc represents a OS process
func NewProcFromPID ¶
NewProcFromPID finds a process by process id
func (*Proc) CPU ¶
CPU returns how many percents of the CPU a process and its children use between this and previous call