A Rust tool that watches your Linux system's CPU cores (and other system metrics!) and exports them to Prometheus.
Only Linux is supported. Currently, only pre-compiled binaries for x86_64 are available, but you can compile it yourself for other architectures.
-
Download the Linux x86_64 binary from the latest release
-
Make it executable and run it:
chmod +x core-watcher ./core-watcherr
-
Core Watcher is now running! 🎉
-
Head to http://localhost:9000/metrics to verify that it's producing metrics as expected.
Prometheus isn't strictly required to run the program, but you'll need it if you want to actually track the metrics, so that you can visualise them in a Grafana dashboard or something like that.
The easiest way to run Prometheus is to install it to your system.
-
Install Prometheus, e.g. by using your system's package manager:
sudo apt install prometheusorsudo pacman -S prometheussudo apt install prometheus # For Debian/Ubuntu sudo pacman -S prometheus # For Arch Linux
-
Run Prometheus:
prometheus --config.file=development/prometheus.yaml
As an alternative to installing Prometheus on your system, you can run it in a Docker container, like this:
docker run \
-p 9090:9090 \
-v ./development/prometheus.yaml:/etc/prometheus/prometheus.yml \
prom/prometheuseusIn production, you can of course use an existing Prometheus instance, or something compatible like VictoriaMetrics (which is what I use). Simply add a scrape config like the following:
- job_name: core_watcher
scrape_interval: "1s"
static_configs:
- targets: ["arch-pc:9000"]You may want to install Core Watcher as a systemd service, so that it starts automatically on boot.
- Install the binary globally:
sudo install -m755 target/release/core-watcher /usr/local/bin/core-watcher - Install the systemd service file:
sudo install -m644 production/core-watcher.service /etc/systemd/system/core-watcher.service - Enable and start the service:
sudo systemctl enable --now core-watcher- This will set Core Watcher to start automatically on boot
- Check that it's started properly:
sudo systemctl status core-watcher
You only need to do this if a pre-compiled binary isn't available for your architecture, or if you want to be sure that you can trust the compiled binary.
Ensure that you have installed Rust first.
- Clone the repository and
cdinto it as per usual - Run the program:
cargo run - Optionally, run Prometheus:
prometheus --config.file=development/prometheus.yaml
See above for instructions for compiling the program from source and running it locally.
- Bump version in
Cargo.toml - Make sure
Cargo.lockhas updated with the new version number (done automatically if you use rust-analyzer) - Commit the version bump to the
masterbranch - Wait for the GitHub Action to build all the binaries for the various platforms
- Download all the zip file artifacts from the GitHub Action
- Create a GitHub release, tell it to create a new tag (e.g.
v0.4.1), upload the zip files to the assets/binaries section, write a little changelog, and publish it as the latest release