From 65f532cb2fc6d06c174f24190c138dccc0ab22a5 Mon Sep 17 00:00:00 2001 From: Jan Wagner Date: Fri, 8 Mar 2024 12:34:13 +0100 Subject: [PATCH] check_es_system: Update to 1.12.1 --- .../.travis.yml | 6 +++--- .../LICENSE | 0 .../README.md | 0 .../check_es_system.sh | 20 ++++++++++++------- .../check_es_system-1.12.1/test/test_disk.sh | 18 +++++++++++++++++ .../test/test_readonly.sh | 0 .../test/test_status.sh | 0 check_es_system/control | 2 +- check_es_system/src | 2 +- 9 files changed, 36 insertions(+), 12 deletions(-) rename check_es_system/{check_es_system-1.12.0 => check_es_system-1.12.1}/.travis.yml (74%) rename check_es_system/{check_es_system-1.12.0 => check_es_system-1.12.1}/LICENSE (100%) rename check_es_system/{check_es_system-1.12.0 => check_es_system-1.12.1}/README.md (100%) rename check_es_system/{check_es_system-1.12.0 => check_es_system-1.12.1}/check_es_system.sh (97%) create mode 100755 check_es_system/check_es_system-1.12.1/test/test_disk.sh rename check_es_system/{check_es_system-1.12.0 => check_es_system-1.12.1}/test/test_readonly.sh (100%) rename check_es_system/{check_es_system-1.12.0 => check_es_system-1.12.1}/test/test_status.sh (100%) diff --git a/check_es_system/check_es_system-1.12.0/.travis.yml b/check_es_system/check_es_system-1.12.1/.travis.yml similarity index 74% rename from check_es_system/check_es_system-1.12.0/.travis.yml rename to check_es_system/check_es_system-1.12.1/.travis.yml index b597922..9e437af 100644 --- a/check_es_system/check_es_system-1.12.0/.travis.yml +++ b/check_es_system/check_es_system-1.12.1/.travis.yml @@ -15,8 +15,8 @@ before_script: script: - ./check_es_system.sh --help || true - - | - test/test_status.sh - test/test_readonly.sh + - test/test_status.sh + - test/test_readonly.sh + - test/test_disk.sh diff --git a/check_es_system/check_es_system-1.12.0/LICENSE b/check_es_system/check_es_system-1.12.1/LICENSE similarity index 100% rename from check_es_system/check_es_system-1.12.0/LICENSE rename to check_es_system/check_es_system-1.12.1/LICENSE diff --git a/check_es_system/check_es_system-1.12.0/README.md b/check_es_system/check_es_system-1.12.1/README.md similarity index 100% rename from check_es_system/check_es_system-1.12.0/README.md rename to check_es_system/check_es_system-1.12.1/README.md diff --git a/check_es_system/check_es_system-1.12.0/check_es_system.sh b/check_es_system/check_es_system-1.12.1/check_es_system.sh similarity index 97% rename from check_es_system/check_es_system-1.12.0/check_es_system.sh rename to check_es_system/check_es_system-1.12.1/check_es_system.sh index 49dcef5..57d386f 100755 --- a/check_es_system/check_es_system-1.12.0/check_es_system.sh +++ b/check_es_system/check_es_system-1.12.1/check_es_system.sh @@ -3,7 +3,7 @@ # Script: check_es_system.sh # # Author: Claudio Kuenzler www.claudiokuenzler.com # # Purpose: Monitor ElasticSearch Store (Disk) Usage # -# Official doc: www.claudiokuenzler.com/monitoring-plugins/check_es_system.php # +# Docs: www.claudiokuenzler.com/monitoring-plugins/check_es_system.php # # License: GPLv2 # # GNU General Public Licence (GPL) http://www.gnu.org/ # # This program is free software; you can redistribute it and/or # @@ -19,14 +19,14 @@ # You should have received a copy of the GNU General Public License # # along with this program; if not, see . # # # -# Copyright 2016,2018-2021 Claudio Kuenzler # +# Copyright 2016,2018-2021,2023 Claudio Kuenzler # # Copyright 2018 Tomas Barton # # Copyright 2020 NotAProfessionalDeveloper # # Copyright 2020 tatref # # Copyright 2020 fbomj # # Copyright 2021 chicco27 # # # -# History: # +# History/Changelog: # # 20160429: Started programming plugin # # 20160601: Continued programming. Working now as it should =) # # 20160906: Added memory usage check, check types option (-t) # @@ -59,6 +59,7 @@ # 20201125: Show names of read_only indexes with jq, set jq as default parser # # 20210616: Fix authentication bug (#38) and non ES URL responding (#39) # # 20211202: Added local node (-L), SSL settings (-K, -E), cpu check # +# 20230929: Bugfix in readonly check type for missing privileges # ################################################################################ #Variables and defaults STATE_OK=0 # define the exit code if status is OK @@ -66,7 +67,7 @@ STATE_WARNING=1 # define the exit code if status is Warning STATE_CRITICAL=2 # define the exit code if status is Critical STATE_UNKNOWN=3 # define the exit code if status is Unknown export PATH=$PATH:/usr/local/bin:/usr/bin:/bin # Set path -version=1.12.0 +version=1.12.1 port=9200 httpscheme=http unit=G @@ -499,6 +500,10 @@ readonly) # Check Readonly status on given indexes elif [[ $? -eq 28 ]]; then echo "ES SYSTEM CRITICAL - server did not respond within ${max_time} seconds" exit $STATE_CRITICAL + elif [[ "$settings" =~ "is unauthorized" ]]; then + errormsg=$(echo "$settings" | json_parse -r -q -c -x error -x reason) + echo "ES SYSTEM CRITICAL - Access denied ($errormsg)" + exit $STATE_CRITICAL fi rocount=$(echo $settings | json_parse -r -q -c -a -x settings -x index -x blocks -x read_only | grep -c true) roadcount=$(echo $settings | json_parse -r -q -c -a -x settings -x index -x blocks -x read_only_allow_delete | grep -c true) @@ -523,11 +528,12 @@ readonly) # Check Readonly status on given indexes elif [[ $settingsrc -eq 28 ]]; then echo "ES SYSTEM CRITICAL - server did not respond within ${max_time} seconds" exit $STATE_CRITICAL - elif [[ -n $(echo $esstatus | grep -i "unable to authenticate") ]]; then + elif [[ -n $(echo "$settings" | grep -i "unable to authenticate") ]]; then echo "ES SYSTEM CRITICAL - Unable to authenticate user $user for REST request" exit $STATE_CRITICAL - elif [[ -n $(echo $esstatus | grep -i "unauthorized") ]]; then - echo "ES SYSTEM CRITICAL - User $user is unauthorized" + elif [[ "$settings" =~ "is unauthorized" ]]; then + errormsg=$(echo "$settings" | json_parse -r -q -c -x error -x reason) + echo "ES SYSTEM CRITICAL - Access denied ($errormsg)" exit $STATE_CRITICAL fi rocount=$(echo $settings | json_parse -r -q -c -a -x settings -x index -x blocks -x read_only | grep -c true) diff --git a/check_es_system/check_es_system-1.12.1/test/test_disk.sh b/check_es_system/check_es_system-1.12.1/test/test_disk.sh new file mode 100755 index 0000000..ac4155a --- /dev/null +++ b/check_es_system/check_es_system-1.12.1/test/test_disk.sh @@ -0,0 +1,18 @@ +#!/bin/bash +echo "Test Elasticsearch status" +./check_es_system.sh -H 127.0.0.1 -P 9200 -t disk +output=$(./check_es_system.sh -H 127.0.0.1 -P 9200 -t disk) + +if [[ $? -eq 0 ]]; then + echo -e "\e[1m\e[32m✔ Test 3.1 OK: Disk check worked and shows green\e[0m" + exitcode=0 +else + echo -e "\e[1m\e[31m✘ Test 3.1 ERROR: Disk check has not worked\e[0m" + exitcode=1 +fi + +if ! [[ "${output}" =~ "ES SYSTEM OK - Disk usage is at 0%" ]]; then + exitcode=1 +fi + +exit $exitcode diff --git a/check_es_system/check_es_system-1.12.0/test/test_readonly.sh b/check_es_system/check_es_system-1.12.1/test/test_readonly.sh similarity index 100% rename from check_es_system/check_es_system-1.12.0/test/test_readonly.sh rename to check_es_system/check_es_system-1.12.1/test/test_readonly.sh diff --git a/check_es_system/check_es_system-1.12.0/test/test_status.sh b/check_es_system/check_es_system-1.12.1/test/test_status.sh similarity index 100% rename from check_es_system/check_es_system-1.12.0/test/test_status.sh rename to check_es_system/check_es_system-1.12.1/test/test_status.sh diff --git a/check_es_system/control b/check_es_system/control index 45941ca..c01e200 100644 --- a/check_es_system/control +++ b/check_es_system/control @@ -1,6 +1,6 @@ Uploaders: Jan Wagner Recommends: curl, jshon | jq -Version: 1.12.0 +Version: 1.12.1 Homepage: https://github.com/Napsty/check_es_system/ Watch: https://github.com/Napsty/check_es_system/tags .*/v?(\d\S+)\.tar\.gz Description: Plugin script to check the status of an ElasticSearch cluster node. diff --git a/check_es_system/src b/check_es_system/src index 8d0891b..478cf69 120000 --- a/check_es_system/src +++ b/check_es_system/src @@ -1 +1 @@ -check_es_system-1.12.0/ \ No newline at end of file +check_es_system-1.12.1/ \ No newline at end of file