From a82c9aeaf8798be5061c419ed815054fc38c7f0c Mon Sep 17 00:00:00 2001 From: eperez2 Date: Wed, 2 Dec 2020 19:40:07 +0100 Subject: [PATCH] add monitoring script to check that kanboard is up to date --- monitoring/check_kanbanchaprilorg_update | 38 ++++++++++++++++++++++++ 1 file changed, 38 insertions(+) create mode 100755 monitoring/check_kanbanchaprilorg_update diff --git a/monitoring/check_kanbanchaprilorg_update b/monitoring/check_kanbanchaprilorg_update new file mode 100755 index 0000000..b94eedb --- /dev/null +++ b/monitoring/check_kanbanchaprilorg_update @@ -0,0 +1,38 @@ +#!/bin/bash +# +# Nagios plugin to check kanboard version. +# + +# program return value +# 0 : ok +# 1 : new version available +# 2 : error +# 3 : github not reachable +# 4 : no installed version find + +LAST_VERSION=$(curl --silent https://api.github.com/repos/kanboard/kanboard/tags | jq -r '.[0].name') + +file_name="/srv/kanban.chapril.org/www/app/constants.php" +INSTALLED_VERSION=$(cat $file_name |grep "^defined('APP_VERSION') or define('APP_VERSION', getenv('APP_VERSION') ?: build_app_version('" | grep -o "v[0-9]\.[0-9]\.[0-9][0-9]") + +if [ -z "$LAST_VERSION" ]; then + echo "WARNING : cannot get version from github." + exit 3 +fi + +if [ -z "$INSTALLED_VERSION" ]; then + echo "WARNING : cannot find installed version." + exit 4 +fi + +if [ "$LAST_VERSION" = "$INSTALLED_VERSION" ]; then + echo "OK" + exit 0 +else + echo "WARNING : new version available, installed is $INSTALLED_VERSION, last is $LAST_VERSION." +#call api create tickets + echo 'version='$LAST_VERSION > /srv/kanban.chapril.org/tools/last-version.txt + /bin/bash /srv/kanban.chapril.org/tools/update.sh +#call api if good close tickets + exit 1 +fi