package common
import "github.com/google/cadvisor/container/common"
Unmarshal's a Containers description json file. The json file contains an array of ContainerHint structs, each with a container's id and networkInterface This allows collecting stats about network interfaces configured outside docker and lxc
Handler for Docker containers.
Index ¶
- Constants
- Variables
- func AssignDeviceNamesToDiskStats(namer DeviceNamer, stats *info.DiskIoStats)
- func CgroupExists(cgroupPaths map[string]string) bool
- func DebugInfo(watches map[string][]string) map[string][]string
- func GetControllerPath(cgroupPaths map[string]string, controllerName string, cgroup2UnifiedMode bool) (string, bool)
- func GetSpec(cgroupPaths map[string]string, machineInfoFactory info.MachineInfoFactory, hasNetwork, hasFilesystem bool) (info.ContainerSpec, error)
- func ListContainers(name string, cgroupPaths map[string]string, listType container.ListType) ([]info.ContainerReference, error)
- func ListDirectories(dirpath string, parent string, recursive bool, output map[string]struct{}) error
- func MakeCgroupPaths(mountPoints map[string]string, name string) map[string]string
- func RemoveNetMetrics(metrics container.MetricSet, remove bool) container.MetricSet
- type ContainerHints
- type DeviceNamer
- type FsHandler
- type FsUsage
- type InotifyWatcher
- func NewInotifyWatcher() (*InotifyWatcher, error)
- func (iw *InotifyWatcher) AddWatch(containerName, dir string) (bool, error)
- func (iw *InotifyWatcher) Close() error
- func (iw *InotifyWatcher) Error() chan error
- func (iw *InotifyWatcher) Event() chan *inotify.Event
- func (iw *InotifyWatcher) GetWatches() map[string][]string
- func (iw *InotifyWatcher) RemoveWatch(containerName, dir string) (bool, error)
- type MachineInfoNamer
- type Mount
Constants ¶
Variables ¶
var ArgContainerHints = flag.String("container_hints", "/etc/cadvisor/container_hints.json", "location of the container hints file")
Functions ¶
func AssignDeviceNamesToDiskStats ¶
func AssignDeviceNamesToDiskStats(namer DeviceNamer, stats *info.DiskIoStats)
AssignDeviceNamesToDiskStats assigns the Device field on the provided DiskIoStats by looking up the device major and minor identifiers in the provided device namer.
func CgroupExists ¶
func DebugInfo ¶
func GetControllerPath ¶
func GetControllerPath(cgroupPaths map[string]string, controllerName string, cgroup2UnifiedMode bool) (string, bool)
func GetSpec ¶
func GetSpec(cgroupPaths map[string]string, machineInfoFactory info.MachineInfoFactory, hasNetwork, hasFilesystem bool) (info.ContainerSpec, error)
func ListContainers ¶
func ListContainers(name string, cgroupPaths map[string]string, listType container.ListType) ([]info.ContainerReference, error)
func ListDirectories ¶
func ListDirectories(dirpath string, parent string, recursive bool, output map[string]struct{}) error
Lists all directories under "path" and outputs the results as children of "parent".
func MakeCgroupPaths ¶
func RemoveNetMetrics ¶
RemoveNetMetrics is used to remove any network metrics from the given MetricSet. It returns the original set as is if remove is false, or if there are no metrics to remove.
Types ¶
type ContainerHints ¶
type ContainerHints struct {
AllHosts []containerHint `json:"all_hosts,omitempty"`
}
func GetContainerHintsFromFile ¶
func GetContainerHintsFromFile(containerHintsFile string) (ContainerHints, error)
type DeviceNamer ¶
type DeviceNamer interface { // DeviceName returns the name of the device by its major and minor ids, or false if no // such device is recognized. DeviceName(major, minor uint64) (string, bool) }
DeviceNamer returns string names for devices by their major and minor id.
type FsHandler ¶
type FsHandler interface { Start() Usage() FsUsage Stop() }
func NewFsHandler ¶
type FsUsage ¶
type InotifyWatcher ¶
type InotifyWatcher struct {
// contains filtered or unexported fields
}
Watcher for container-related inotify events in the cgroup hierarchy.
Implementation is thread-safe.
func NewInotifyWatcher ¶
func NewInotifyWatcher() (*InotifyWatcher, error)
func (*InotifyWatcher) AddWatch ¶
func (iw *InotifyWatcher) AddWatch(containerName, dir string) (bool, error)
Add a watch to the specified directory. Returns if the container was already being watched.
func (*InotifyWatcher) Close ¶
func (iw *InotifyWatcher) Close() error
Closes the inotify watcher.
func (*InotifyWatcher) Error ¶
func (iw *InotifyWatcher) Error() chan error
Errors are returned on this channel.
func (*InotifyWatcher) Event ¶
func (iw *InotifyWatcher) Event() chan *inotify.Event
Events are returned on this channel.
func (*InotifyWatcher) GetWatches ¶
func (iw *InotifyWatcher) GetWatches() map[string][]string
Returns a map of containers to the cgroup paths being watched.
func (*InotifyWatcher) RemoveWatch ¶
func (iw *InotifyWatcher) RemoveWatch(containerName, dir string) (bool, error)
Remove watch from the specified directory. Returns if this was the last watch on the specified container.
type MachineInfoNamer ¶
type MachineInfoNamer info.MachineInfo
func (*MachineInfoNamer) DeviceName ¶
func (n *MachineInfoNamer) DeviceName(major, minor uint64) (string, bool)
type Mount ¶
type Mount struct { HostDir string `json:"host_dir,omitempty"` ContainerDir string `json:"container_dir,omitempty"` }
Source Files ¶
container_hints.go fsHandler.go helpers.go inotify_watcher.go
- Version
- v0.52.1 (latest)
- Published
- Mar 5, 2025
- Platform
- linux/amd64
- Imports
- 20 packages
- Last checked
- 3 days ago –
Tools for package owners.