Gather resource consumption data around a CodeReady Containers instance
The following diagram represent the interaction of monitools container with a host running the CodeReady Containers instance.
The container will be configured with ENVs:
TARGET_HOST(mandatory): Target host address
TARGET_HOST_USERNAME(mandatory): username
Chose one of following depending on the target auth mechanism:
TARGET_HOST_KEY_PATH(optional): key path
TARGET_HOST_PASSWORD(optional): pasword
MONICTL_REPETITIONS(optional, default 5)
MONICTL_INTERVAL(optional, default 1)
Sample container execution
podman run -it --rm \
-e TARGET_HOST_USERNAME=XXXX \
-e TARGET_HOST_KEY_PATH=XXXX \
-e TARGET_HOST=XXXX \
quay.io/crc/monitools
Clone this repository by gith clone https://github.com/code-ready/monitools
and the following command will build the monictl
executable and place it in $(GOBIN)
directory.
make install
- Create directory where you want
monictl
to deposit the data. - Have a running instance of CRC (
crc status
returnsRunning
for both VM and the cluster) - Run
monictl -d=<data dir> -n=<num of reps> -s=<length of pause>
- Look into your data folder to inspect the files.
-d
: data directory (relative to current directory)-n
: number of repetitions when probing CPU consumption-s
: time interval between repetitions when probing CPU consumption (in seconds)
Assuming a running CRC instance:
$ make install
$ mkdir data
$ monictl -d=data -n=5 -s=1
-------------
Running monitoring tools with the following settings:
Data directory: data
Number of repeats: 5
Pauses between repeats: 1s
Logging into: logs/monitools_20210329101528.log
-------------
$ ls data
cpu.json crictl-stats-20210329101533.json traffic.json
$ ls logs
monitools_20210329101528.log
First, install this module to your development environment using e.g. go get
tool:
go get github.com/code-ready/monitools
Then use as any other package, e.g. by importing as:
import github.com/code-ready/monitools/tools
In monitools/examples
you will find a short program that imports this module and the tools
package and runs one of its functions. It assumes an existing CRC VM and probes for CPU usage of the qemu
process 5 times with 1s sleep inbetween probes. Resulting %CPU is recorded in cpu.csv
in the same monitools/examples
folder. Run the example script example.go
by
$ cd monitools/examples
$ go run example.go