From d41ff20d7b9102b9b3efa3f9c3c4fd65d64e4bce Mon Sep 17 00:00:00 2001 From: Leon <82407168+sed-i@users.noreply.github.com> Date: Tue, 27 Feb 2024 14:27:03 -0500 Subject: [PATCH 1/3] Update charmcraft.yaml --- charmcraft.yaml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/charmcraft.yaml b/charmcraft.yaml index c9342d9..ef804c9 100644 --- a/charmcraft.yaml +++ b/charmcraft.yaml @@ -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: . From 2e742973b5a24d0590a7a5b2c720f36da4be487a Mon Sep 17 00:00:00 2001 From: Leon <82407168+sed-i@users.noreply.github.com> Date: Tue, 27 Feb 2024 14:36:47 -0500 Subject: [PATCH 2/3] Update charm.py --- src/charm.py | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/src/charm.py b/src/charm.py index d8f719b..9c67be7 100755 --- a/src/charm.py +++ b/src/charm.py @@ -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) From 087ac3f9ea855cd0e5250a18184ad21b2cf0f0fc Mon Sep 17 00:00:00 2001 From: sed-i <82407168+sed-i@users.noreply.github.com> Date: Tue, 27 Feb 2024 14:40:38 -0500 Subject: [PATCH 3/3] Lint --- src/charm.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/charm.py b/src/charm.py index 9c67be7..e532152 100755 --- a/src/charm.py +++ b/src/charm.py @@ -214,9 +214,9 @@ def _setup_nrpe_exporter(self): # https://stackoverflow.com/a/45124927/3516684 # https://en.wikipedia.org/wiki/Uname if arch in ["x86_64", "amd64"]: - arch = "amd64" + arch = "amd64" elif arch in ["aarch64", "arm64", "armv8b", "armv8l"]: - arch = "aarch64" + arch = "aarch64" # else: keep arch as is res = "nrpe_exporter-{}".format(arch)