Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix machine name handling for nrpe_exporter binary #126

Merged
merged 3 commits into from
Feb 28, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions charmcraft.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -22,11 +22,11 @@ parts:
override-pull: |
if [ $CRAFT_TARGET_ARCH == "amd64" ]; then
URI=https://github.com/canonical/nrpe_exporter/releases/latest/download/nrpe_exporter-amd64
curl -L $URI -o nrpe_exporter-amd64
elif [ $CRAFT_TARGET_ARCH == "arm64" ] || [ $CRAFT_TARGET_ARCH == "aarch64" ]; then
URI=https://github.com/canonical/nrpe_exporter/releases/latest/download/nrpe_exporter-arm64
curl -L $URI -o nrpe_exporter-aarch64
fi

curl -L $URI -o nrpe_exporter-aarch64
vector:
plugin: dump
source: .
Expand Down
11 changes: 10 additions & 1 deletion src/charm.py
Original file line number Diff line number Diff line change
Expand Up @@ -209,7 +209,16 @@ def _setup_nrpe_exporter(self):
# Make sure the exporter binary is present with a systemd service
if not Path("/usr/local/bin/nrpe-exporter").exists():
arch = platform.machine()
arch = "amd64" if arch == "x86_64" else arch

# Machine names vary. Here we follow Ubuntu's convention of "amd64" and "aarch64".
# https://stackoverflow.com/a/45124927/3516684
# https://en.wikipedia.org/wiki/Uname
if arch in ["x86_64", "amd64"]:
arch = "amd64"
elif arch in ["aarch64", "arm64", "armv8b", "armv8l"]:
arch = "aarch64"
# else: keep arch as is

res = "nrpe_exporter-{}".format(arch)

st = Path(res)
Expand Down
Loading