Documentation ¶
Overview ¶
Package agents provides individual handlers for managing portions of controlling or observing a contained process.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Job ¶
type Job struct { Cmd *exec.Cmd // Handle to the forked process Proc *process.Process // gopsutil process handle for later stats gathering Pid int // Process ID, not particularlly useful Pgid int // Process Group ID, used for stats/control of the entire tree created // contains filtered or unexported fields }
Job contains a handle to the actual process struct.
func (*Job) StdoutByteCount ¶ added in v1.1.1
StdoutByteCount returns the number of emitted bytes to STDOUT by the child process.
type JobControl ¶
type JobControl interface { Stop() error // Gracefully end process Suspend() error // Stop scheduling process to be resumed later Resume() error // Resume a previously stopped process Kill(int64) error // Send SIGKILL (or arg os.Signal) Done() chan error // Reflects the child process is done Process() *process.Process // Handle to gopsutil process struct for stats StdoutByteCount() int64 // Return the number of bytes emitted to STDOUT }
JobControl provides a command interface for control
func NewControlledProcess ¶
func NewControlledProcess(cmd string, arguments []string, doneChan chan error, stdoutLimit int64) (JobControl, error)
NewControlledProcess creates the child proc.
type ProcessStatCollector ¶
type ProcessStatCollector struct {
// contains filtered or unexported fields
}
ProcessStatCollector is a container for internal state
func (*ProcessStatCollector) NewTicker ¶ added in v1.2.0
func (ps *ProcessStatCollector) NewTicker(d time.Duration)
NewTicker creates a new time.Ticker instance with the passed in duration Used to dynamically change the sampling interval
func (*ProcessStatCollector) ReinitializeConnection ¶ added in v1.5.0
func (ps *ProcessStatCollector) ReinitializeConnection(newConn *amqp.Connection) error
ReinitializeConnection reconnects to the AMQP exchange
func (*ProcessStatCollector) Sample ¶
func (ps *ProcessStatCollector) Sample() error
Sample collects process statistcs and emits them.
type ProcessStatCommand ¶ added in v1.5.0
ProcessStatCommand is used to communicate sample commands and ticker updates with a channel implementation to the ProcessStats agent.
type ProcessStatSample ¶
type ProcessStatSample struct { Host host.HostInfoStat // See gopsutil for description Memory process.MemoryInfoStat // See gopsutil for description CPUTimes cpu.CPUTimesStat // See gopsutil for description IOCounters process.IOCountersStat // See gopsutil for description OpenFiles []process.OpenFilesStat // See gopsutil for description NumThreads int32 // Number of threads in use by the child processes (if supported) Pid int32 // Process ID for the group ChildPids []int32 // Children process IDs CPUPercent float64 // Sum of parent and children CPU percent usage TimeUTC time.Time // Timestamp of collection with location set to UTC TimeUnix int64 // Timestamp of collection based on seconds elapsed since the unix epoch. StdoutBytes int64 // Running total of bytes emitted via STDOUT by the child process UserData map[string]interface{} // User provided JSON from invocation (not validated in proc_box!) }
ProcessStatSample contains a single sample of the underlying process system usage. See gopsutil for defintions of these structures and support for particular OSes.
type ProcessStats ¶
type ProcessStats interface { Sample() error // Take a statistical sample and emit it on AMQP NewTicker(time.Duration) ReinitializeConnection(*amqp.Connection) error }
ProcessStats provides an interface for collecting statistics about the pid
func NewProcessStats ¶
func NewProcessStats( amqp *amqp.Connection, routingKey string, exchange string, job *JobControl, interval time.Duration, msgTimeout time.Duration, userJSON string, ) (ProcessStats, error)
NewProcessStats establishes a new AMQP channel and configures sampling period
type RemoteControl ¶
type RemoteControl struct { Commands chan RemoteControlCommand // Channel for incoming JSON unmarshalled RemoteControlCommands // contains filtered or unexported fields }
RemoteControl is a container for the AMQP connection for remote process control
func NewRemoteControl ¶
func NewRemoteControl(amqp *amqp.Connection, routingKeys []string, exchange string) (*RemoteControl, error)
NewRemoteControl creates a new watcher for external commands through AMQP to control the boxed process.
func (*RemoteControl) Shutdown ¶
func (rc *RemoteControl) Shutdown() error
Shutdown gracefully stops incoming command traffic and closes the channel
type RemoteControlCommand ¶
type RemoteControlCommand struct { Command string // Command to execute Arguments []string // Optional arguments }
RemoteControlCommand is the unmarshalled JSON remote command to control the process.
type Timer ¶
type Timer interface { Reset() error // Clear elapsed time Start() error // Start counting time from zero Stop() error // Pause timer Resume() error // Resume previously paused timer ElapsedTime() (time.Duration, error) // Return duration of elapsed time Done() chan error // Timer has hit the maximum value }
Timer provides access to control the timer behavior as a stopwatch.
type WallclockTimer ¶
type WallclockTimer struct {
// contains filtered or unexported fields
}
WallclockTimer provides an internal structure for storing the timer state.
func (*WallclockTimer) Done ¶
func (timer *WallclockTimer) Done() chan error
Done provides the channel used by the tiemr when it has expired
func (*WallclockTimer) ElapsedTime ¶
func (timer *WallclockTimer) ElapsedTime() (time.Duration, error)
ElapsedTime provides the duration of elapsed time counted by the timer
func (*WallclockTimer) Resume ¶
func (timer *WallclockTimer) Resume() error
Resume continues a paused timer
func (*WallclockTimer) Start ¶
func (timer *WallclockTimer) Start() error
Start starts the timer from zero
func (*WallclockTimer) Stop ¶
func (timer *WallclockTimer) Stop() error
Stop pauses the timer from counting