Skip to content

Commit

Permalink
Internal renaming of -i parameter, use for tps check (handle issue #28)…
Browse files Browse the repository at this point in the history
… (#32)
  • Loading branch information
Napsty authored Sep 16, 2020
1 parent 1d0bcbc commit f5eb311
Showing 1 changed file with 17 additions and 7 deletions.
24 changes: 17 additions & 7 deletions check_es_system.sh
Original file line number Diff line number Diff line change
Expand Up @@ -52,18 +52,19 @@
# 20200609: Fix readonly check on ALL indices (issue #26) #
# 20200723: Add cluster name to status output #
# 20200824: Fix typo in readonly check output #
# 20200916: Internal renaming of -i parameter, use for tps check (issue #28) #
################################################################################
#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.9.1
version=1.10.0
port=9200
httpscheme=http
unit=G
indexes='_all'
include='_all'
max_time=30
parsers=(jshon jq)
################################################################################
Expand All @@ -83,7 +84,7 @@ Options:
* -t Type of check (disk, mem, status, readonly, jthreads, tps, master)
+ -d Available size of disk or memory (ex. 20)
-o Disk space unit (K|M|G) (defaults to G)
-i Space separated list of indexes to be checked for readonly (default: '_all')
-i Space separated list of included object names to be checked (index names on readonly check, pool names on tps check)
-w Warning threshold (see usage notes below)
-c Critical threshold (see usage notes below)
-m Maximum time in seconds to wait for response (default: 30)
Expand Down Expand Up @@ -191,7 +192,7 @@ do
p) pass=${OPTARG};;
d) available=${OPTARG};;
o) unit=${OPTARG};;
i) indexes=${OPTARG};;
i) include=${OPTARG};;
w) warning=${OPTARG};;
c) critical=${OPTARG};;
t) checktype=${OPTARG};;
Expand Down Expand Up @@ -373,7 +374,7 @@ status) # Check Elasticsearch status

readonly) # Check Readonly status on given indexes
icount=0
for index in $indexes; do
for index in $include; do
if [[ -z $user ]]; then
# Without authentication
settings=$(curl -k -s --max-time ${max_time} ${httpscheme}://${host}:${port}/$index/_settings)
Expand Down Expand Up @@ -438,7 +439,7 @@ readonly) # Check Readonly status on given indexes
echo "ES SYSTEM CRITICAL - ${output[*]}"
exit $STATE_CRITICAL
else
echo "ES SYSTEM OK - Elasticsearch Indexes ($indexes) are writeable"
echo "ES SYSTEM OK - Elasticsearch Indexes ($include) are writeable"
exit $STATE_OK
fi
;;
Expand Down Expand Up @@ -500,6 +501,15 @@ tps) # Check Thread Pool Statistics
fi
fi

if ! [[ $include = "_all" ]]; then
tpsgrep=$(echo "$include" | sed "s/ /|/g")
threadpools=$(echo "$threadpools" | egrep -i "(${tpsgrep})")
if [[ $(echo ${threadpools[*]}) = "" ]]; then
echo "Thread Pool check is critical: No thread pools found with given name(s): ${include}."
exit $STATE_CRITICAL
fi
fi

tpname=($(echo "$threadpools" | awk '{print $1"-"$2}' | sed "s/\n//g"))
tpactive=($(echo "$threadpools" | awk '{print $3}' | sed "s/\n//g"))
tpqueue=($(echo "$threadpools" | awk '{print $4}' | sed "s/\n//g"))
Expand Down Expand Up @@ -620,4 +630,4 @@ master) # Check Cluster Master
;;

*) help
esac
esac

0 comments on commit f5eb311

Please sign in to comment.