Documentation
¶
Index ¶
- Variables
- type ContainerInfo
- type ContainerdRuntime
- type CrioRuntime
- type DockerRuntime
- type Manager
- func (m *Manager) GetContainer(id string) *ContainerInfo
- func (m *Manager) GetContainerByIDOrName(query string) *ContainerInfo
- func (m *Manager) GetContainerByPID(pid int32) *ContainerInfo
- func (m *Manager) GetPIDsForContainer(query string) []int32
- func (m *Manager) ListContainers() []*ContainerInfo
- func (m *Manager) PropagateToChildren(pidToPpid map[int32]int32)
- func (m *Manager) Refresh() error
- func (m *Manager) RuntimeCount() int
- func (m *Manager) RuntimeNames() []string
- type PodmanRuntime
- type Runtime
Constants ¶
This section is empty.
Variables ¶
var EmptyContainer = &ContainerInfo{ Labels: make(map[string]string), }
EmptyContainer is used for processes not running in a container. This allows CEL expressions to safely access container fields without nil checks. Use container.id != "" to check if a process is containerized.
Functions ¶
This section is empty.
Types ¶
type ContainerInfo ¶
type ContainerInfo struct {
ID string `cel:"id"` // Container ID (short or full)
Name string `cel:"name"` // Container name
Image string `cel:"image"` // Image name
Runtime string `cel:"runtime"` // Runtime type (e.g., "docker", "containerd", "cri-o")
Labels map[string]string `cel:"labels"` // Container labels
PIDs []int32 `cel:"pids"` // PIDs running in this container
}
ContainerInfo holds information about a container
func (*ContainerInfo) HasLabel ¶
func (c *ContainerInfo) HasLabel(key string) bool
HasLabel checks if the container has a label with the given key
func (*ContainerInfo) IsEmpty ¶
func (c *ContainerInfo) IsEmpty() bool
IsEmpty returns true if this is the empty container (process not in container)
func (*ContainerInfo) LabelValue ¶
func (c *ContainerInfo) LabelValue(key string) string
LabelValue returns the value of a label, or empty string if not found
type ContainerdRuntime ¶
type ContainerdRuntime struct {
// contains filtered or unexported fields
}
ContainerdRuntime implements Runtime for containerd
func NewContainerdRuntime ¶
func NewContainerdRuntime(socketPath string) *ContainerdRuntime
NewContainerdRuntime creates a new containerd runtime client
func (*ContainerdRuntime) Available ¶
func (c *ContainerdRuntime) Available() bool
Available checks if containerd is available
func (*ContainerdRuntime) Close ¶
func (c *ContainerdRuntime) Close() error
Close closes the containerd client
func (*ContainerdRuntime) GetContainerByPID ¶
func (c *ContainerdRuntime) GetContainerByPID(pid int32) (*ContainerInfo, error)
GetContainerByPID returns container info for a given PID
func (*ContainerdRuntime) ListContainers ¶
func (c *ContainerdRuntime) ListContainers() ([]*ContainerInfo, error)
ListContainers returns all running containerd containers
func (*ContainerdRuntime) Name ¶
func (c *ContainerdRuntime) Name() string
Name returns the runtime name
type CrioRuntime ¶
type CrioRuntime struct {
// contains filtered or unexported fields
}
CrioRuntime implements Runtime for CRI-O
func NewCrioRuntime ¶
func NewCrioRuntime(socketPath string) *CrioRuntime
NewCrioRuntime creates a new CRI-O runtime client
func (*CrioRuntime) Available ¶
func (c *CrioRuntime) Available() bool
Available checks if CRI-O is available
func (*CrioRuntime) Close ¶
func (c *CrioRuntime) Close() error
Close is a no-op for CRI-O (HTTP client doesn't need closing)
func (*CrioRuntime) GetContainerByPID ¶
func (c *CrioRuntime) GetContainerByPID(pid int32) (*ContainerInfo, error)
GetContainerByPID returns container info for a given PID
func (*CrioRuntime) ListContainers ¶
func (c *CrioRuntime) ListContainers() ([]*ContainerInfo, error)
ListContainers returns all running CRI-O containers
type DockerRuntime ¶
type DockerRuntime struct {
// contains filtered or unexported fields
}
DockerRuntime implements Runtime for Docker
func NewDockerRuntime ¶
func NewDockerRuntime(socketPath string) *DockerRuntime
NewDockerRuntime creates a new Docker runtime client
func (*DockerRuntime) Available ¶
func (d *DockerRuntime) Available() bool
Available checks if Docker is available
func (*DockerRuntime) GetContainerByPID ¶
func (d *DockerRuntime) GetContainerByPID(pid int32) (*ContainerInfo, error)
GetContainerByPID returns container info for a given PID
func (*DockerRuntime) ListContainers ¶
func (d *DockerRuntime) ListContainers() ([]*ContainerInfo, error)
ListContainers returns all running Docker containers
type Manager ¶
type Manager struct {
// contains filtered or unexported fields
}
Manager manages multiple container runtimes and provides a unified interface
func NewDefaultManager ¶
func NewDefaultManager() *Manager
NewDefaultManager creates a manager with all available runtimes
func NewManager ¶
NewManager creates a new container manager with the given runtimes
func (*Manager) GetContainer ¶
func (m *Manager) GetContainer(id string) *ContainerInfo
GetContainer returns container info by ID
func (*Manager) GetContainerByIDOrName ¶
func (m *Manager) GetContainerByIDOrName(query string) *ContainerInfo
GetContainerByIDOrName looks up a container by ID (full or prefix) or by name. Returns nil if no match is found.
func (*Manager) GetContainerByPID ¶
func (m *Manager) GetContainerByPID(pid int32) *ContainerInfo
GetContainerByPID returns container info for a PID, or nil if not in a container
func (*Manager) GetPIDsForContainer ¶
GetPIDsForContainer returns all PIDs associated with a container (by ID or name).
func (*Manager) ListContainers ¶
func (m *Manager) ListContainers() []*ContainerInfo
ListContainers returns all known containers
func (*Manager) PropagateToChildren ¶
PropagateToChildren associates child processes with their parent's container. This should be called after Refresh() with a map of PID -> PPID relationships.
func (*Manager) Refresh ¶
Refresh queries all runtimes and builds the container/PID mappings Runtimes are queried in order, with earlier runtimes taking priority for duplicate PIDs (Docker should come before containerd for better names)
func (*Manager) RuntimeCount ¶
RuntimeCount returns the number of available runtimes
func (*Manager) RuntimeNames ¶
RuntimeNames returns the names of available runtimes
type PodmanRuntime ¶
type PodmanRuntime struct {
// contains filtered or unexported fields
}
PodmanRuntime implements Runtime for Podman using REST API It can manage multiple sockets (root + user sockets)
func NewPodmanRuntime ¶
func NewPodmanRuntime(socketPath string) *PodmanRuntime
NewPodmanRuntime creates a new Podman runtime client
func (*PodmanRuntime) Available ¶
func (p *PodmanRuntime) Available() bool
Available checks if Podman is available
func (*PodmanRuntime) GetContainerByPID ¶
func (p *PodmanRuntime) GetContainerByPID(pid int32) (*ContainerInfo, error)
GetContainerByPID returns container info for a given PID
func (*PodmanRuntime) ListContainers ¶
func (p *PodmanRuntime) ListContainers() ([]*ContainerInfo, error)
ListContainers returns all running Podman containers from all sockets
type Runtime ¶
type Runtime interface {
// Name returns the runtime name (e.g., "docker", "containerd")
Name() string
// Available checks if the runtime is available on the system
Available() bool
// ListContainers returns all running containers
ListContainers() ([]*ContainerInfo, error)
// GetContainerByPID returns container info for a given PID, or nil if not in a container
GetContainerByPID(pid int32) (*ContainerInfo, error)
}
Runtime is the interface that container runtimes must implement