From 6a18b1944a0d842faf619e5da56858c12616338f Mon Sep 17 00:00:00 2001 From: Quentin Gibeaux Date: Thu, 15 Oct 2020 18:16:57 +0200 Subject: [PATCH] add scrip check release --- .../check_tootsuite_mastodon_release.sh | 33 +++++++++++++++++++ 1 file changed, 33 insertions(+) create mode 100755 monitoring/check_tootsuite_mastodon_release.sh diff --git a/monitoring/check_tootsuite_mastodon_release.sh b/monitoring/check_tootsuite_mastodon_release.sh new file mode 100755 index 0000000..7dc99b1 --- /dev/null +++ b/monitoring/check_tootsuite_mastodon_release.sh @@ -0,0 +1,33 @@ +#!/bin/bash +# +# Nagios plugin to check mastodon version +# + +# program return value +# 0 : OK +# 1 : CRITICAL +# 2 : WARNING new version available +# 3 : UNKNOWN github or local repo not probable + +LAST_VERSION=$(curl --silent https://api.github.com/repos/tootsuite/mastodon/releases | jq -r '.[0].name') + +INSTALLED_VERSION=$(git -C /home/mastodon/live/ branch | grep ^* | sed -e 's/.*live-//') + +if [ -z "$LAST_VERSION" ]; then + echo "UNKNOWN : cannot get version from github." + exit 3 +fi + +if [ -z "$INSTALLED_VERSION" ]; then + echo "UNKNOWN : cannot get version from /home/mastodon/live" + exit 3 +fi + +if [ "$LAST_VERSION" = "$INSTALLED_VERSION" ]; then + echo "OK : Installed version is $INSTALLED_VERSION, last version is $LAST_VERSION" + exit 0 + else + echo "WARNING : new version available, installed is $INSTALLED_VERSION, last is $LAST_VERSION." + exit 2 +fi +