Skip to content

Commit

Permalink
Issue 30 (#35)
Browse files Browse the repository at this point in the history
* Show read_only and read_only_allow_delete index names when using jq as parser

* Switch default parser from jshon to jq

* Bump version
  • Loading branch information
Napsty authored Nov 25, 2020
1 parent 692f7da commit eb70276
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 9 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ Please refer to https://www.claudiokuenzler.com/monitoring-plugins/check_es_syst
Requirements
------
- The following commands must be available: `curl`, `expr`
- One of the following json parsers must be available: `jshon` or `jq` (defaults to jshon)
- One of the following json parsers must be available: `jshon` or `jq` (defaults to jq)

Usage
------
Expand Down
23 changes: 15 additions & 8 deletions check_es_system.sh
Original file line number Diff line number Diff line change
Expand Up @@ -55,20 +55,21 @@
# 20200824: Fix typo in readonly check output #
# 20200916: Internal renaming of -i parameter, use for tps check (issue #28) #
# 20201110: Fix thresholds in jthreads check #
# 20201125: Show names of read_only indexes with jq, set jq as default parser #
################################################################################
#Variables and defaults
STATE_OK=0 # define the exit code if status is OK
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.10.1
version=1.11.0
port=9200
httpscheme=http
unit=G
include='_all'
max_time=30
parsers=(jshon jq)
parsers=(jq jshon)
################################################################################
#Functions
help () {
Expand All @@ -91,7 +92,7 @@ Options:
-c Critical threshold (see usage notes below)
-m Maximum time in seconds to wait for response (default: 30)
-e Expect master node (used with 'master' check)
-X The json parser to be used jshon or jq (default: jshon)
-X The json parser to be used jshon or jq (default: jq)
-h Help!
*mandatory options
Expand Down Expand Up @@ -200,7 +201,7 @@ do
t) checktype=${OPTARG};;
m) max_time=${OPTARG};;
e) expect_master=${OPTARG};;
X) parser=${OPTARG:=jshon};;
X) parser=${OPTARG:=jq};;
*) help;;
esac
done
Expand Down Expand Up @@ -420,15 +421,21 @@ readonly) # Check Readonly status on given indexes
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)
if [[ $rocount -gt 0 ]]; then
if [[ "$index" = "_all" ]]; then
output[${icount}]=" $rocount index(es) found read-only -"
if [[ "$index" = "_all" ]]; then
if [[ $parser = "jq" ]]; then
roindexes=$(echo $settings | jq -r '.[].settings.index |select(.blocks.read_only == "true").provided_name')
fi
output[${icount}]=" $rocount index(es) found read-only $roindexes -"
else output[${icount}]=" $index is read-only -"
fi
roerror=true
fi
if [[ $roadcount -gt 0 ]]; then
if [[ "$index" = "_all" ]]; then
output[${icount}]+=" $roadcount index(es) found read-only (allow delete) -"
if [[ "$index" = "_all" ]]; then
if [[ $parser = "jq" ]]; then
roadindexes=$(echo $settings | jq -r '.[].settings.index |select(.blocks.read_only_allow_delete == "true").provided_name' | tr '\n' ' ')
fi
output[${icount}]+=" $roadcount index(es) found read-only (allow delete) $roadindexes"
else output[${icount}]+=" $index is read-only (allow delete) -"
fi
roerror=true
Expand Down

0 comments on commit eb70276

Please sign in to comment.