Stats returns statistics for the container.
()
| 138 | |
| 139 | // Stats returns statistics for the container. |
| 140 | func (c *Container) Stats() (*Stats, error) { |
| 141 | var ( |
| 142 | err error |
| 143 | stats = &Stats{} |
| 144 | ) |
| 145 | if stats.CgroupStats, err = c.cgroupManager.GetStats(); err != nil { |
| 146 | return stats, fmt.Errorf("unable to get container cgroup stats: %w", err) |
| 147 | } |
| 148 | if c.intelRdtManager != nil { |
| 149 | if stats.IntelRdtStats, err = c.intelRdtManager.GetStats(); err != nil { |
| 150 | return stats, fmt.Errorf("unable to get container Intel RDT stats: %w", err) |
| 151 | } |
| 152 | } |
| 153 | for _, iface := range c.config.Networks { |
| 154 | switch iface.Type { |
| 155 | case "veth": |
| 156 | istats, err := getNetworkInterfaceStats(iface.HostInterfaceName) |
| 157 | if err != nil { |
| 158 | return stats, fmt.Errorf("unable to get network stats for interface %q: %w", iface.HostInterfaceName, err) |
| 159 | } |
| 160 | stats.Interfaces = append(stats.Interfaces, istats) |
| 161 | } |
| 162 | } |
| 163 | return stats, nil |
| 164 | } |
| 165 | |
| 166 | // Set resources of container as configured. Can be used to change resources |
| 167 | // when the container is running. |