When cAdvisor starts up, it would read the `vendor` files in `/sys/bus/pci/devices/*` to see if any NVIDIA devices (vendor ID: 0x10de) are attached to the node. If no NVIDIA devices are found, this code path would become dormant for the rest of cAdvisor lifetime. If NVIDIA devices are found, we would start a goroutine that would check for the presence of NVML by trying to dynamically load it at regular intervals. We need to do this regular checking instead of doing it just once because it may happen that cAdvisor is started before the NVIDIA drivers and NVML are installed. Once the NVML dynamic loading succeeds, we would use NVML’s query methods to find out how many devices exist on the node and create a map from their minor numbers to their handles and cache that map. The goroutine would exit at this point. If we detected the presence of NVML in the previous step, whenever a new container is detected by cAdvisor, cAdvisor would read the `devices.list` file from the container's devices cgroup. The `devices.list` file lists the major:minor number of all the devices that the container is allowed to access. If we find any device with major number 195 (which is the major number assigned to NVIDIA devices), we would cache the list of corresponding minor numbers for that container. During every housekeeping operation, in addition to collecting all the existing metrics, we will use the cached NVIDIA device minor numbers and the map from minor numbers to device handles to get metrics for GPU devices attached to the container. |
||
---|---|---|
accelerators | ||
api | ||
build | ||
cache | ||
client | ||
collector | ||
container | ||
deploy | ||
devicemapper | ||
docs | ||
events | ||
fs | ||
Godeps | ||
healthz | ||
http | ||
info | ||
integration | ||
machine | ||
manager | ||
metrics | ||
pages | ||
storage | ||
summary | ||
utils | ||
validate | ||
vendor | ||
version | ||
zfs | ||
.gitignore | ||
AUTHORS | ||
cadvisor_test.go | ||
cadvisor.go | ||
CHANGELOG.md | ||
CONTRIBUTING.md | ||
LICENSE | ||
logo.png | ||
Makefile | ||
README.md | ||
storagedriver.go | ||
test.htdigest | ||
test.htpasswd |
cAdvisor
cAdvisor (Container Advisor) provides container users an understanding of the resource usage and performance characteristics of their running containers. It is a running daemon that collects, aggregates, processes, and exports information about running containers. Specifically, for each container it keeps resource isolation parameters, historical resource usage, histograms of complete historical resource usage and network statistics. This data is exported by container and machine-wide.
cAdvisor has native support for Docker containers and should support just about any other container type out of the box. We strive for support across the board so feel free to open an issue if that is not the case. cAdvisor's container abstraction is based on lmctfy's so containers are inherently nested hierarchically.
Quick Start: Running cAdvisor in a Docker Container
To quickly tryout cAdvisor on your machine with Docker, we have a Docker image that includes everything you need to get started. You can run a single cAdvisor to monitor the whole machine. Simply run:
sudo docker run \
--volume=/:/rootfs:ro \
--volume=/var/run:/var/run:rw \
--volume=/sys:/sys:ro \
--volume=/var/lib/docker/:/var/lib/docker:ro \
--volume=/dev/disk/:/dev/disk:ro \
--publish=8080:8080 \
--detach=true \
--name=cadvisor \
google/cadvisor:latest
cAdvisor is now running (in the background) on http://localhost:8080
. The setup includes directories with Docker state cAdvisor needs to observe.
Note: If you're running on CentOS, Fedora, RHEL, or are using LXC take a look at our running instructions.
We have detailed instructions on running cAdvisor standalone outside of Docker. cAdvisor running options may also be interesting for advanced usecases. If you want to build your own cAdvisor Docker image see our deployment page.
Building and Testing
See the more detailed instructions in the build page. This includes instructions for building and deploying the cAdvisor Docker image.
Exporting stats
cAdvisor supports exporting stats to various storage plugins. See the documentation for more details and examples.
Web UI
cAdvisor exposes a web UI at its port:
http://<hostname>:<port>/
See the documentation for more details.
Remote REST API & Clients
cAdvisor exposes its raw and processed stats via a versioned remote REST API. See the API's documentation for more information.
There is also an official Go client implementation in the client directory. See the documentation for more information.
Roadmap
cAdvisor aims to improve the resource usage and performance characteristics of running containers. Today, we gather and expose this information to users. In our roadmap:
- Advise on the performance of a container (e.g.: when it is being negatively affected by another, when it is not receiving the resources it requires, etc)
- Auto-tune the performance of the container based on previous advise.
- Provide usage prediction to cluster schedulers and orchestration layers.
Community
Contributions, questions, and comments are all welcomed and encouraged! cAdvisor developers hang out on Slack in the #sig-node channel (get an invitation here). We also have the kubernetes-users Google Groups mailing list.