Changeset View
Changeset View
Standalone View
Standalone View
site-modules/profile/files/logstash/es_reopen_closed_indexes.sh
Show All 16 Lines | function filter_index_name() { | ||||
# extract the index name for the lines: | # extract the index name for the lines: | ||||
# new log format : ... "type" =>" cluster_block_exception","reason " => " index [ swh_workers-7.15.2-2021.11.07 ]... | # new log format : ... "type" =>" cluster_block_exception","reason " => " index [ swh_workers-7.15.2-2021.11.07 ]... | ||||
# old log format : ... ({type => cluster_block_exception, reason => index [ systemlogs-2021.11.09 ] blocked... | # old log format : ... ({type => cluster_block_exception, reason => index [ systemlogs-2021.11.09 ] blocked... | ||||
# .* reason "? => "? index \[ ([.a-z0-9_\-]+) \] .* | # .* reason "? => "? index \[ ([.a-z0-9_\-]+) \] .* | ||||
sed -r 's/.*"index"=>"([a-z0-9\-\.\-]+)".*/\1/g' | sort | uniq | sed -r 's/.*"index"=>"([a-z0-9\-\.\-]+)".*/\1/g' | sort | uniq | ||||
} | } | ||||
function log_indices() { | function log_indices() { | ||||
local CONDITION="index_closed_exception" | |||||
if [ -z "$1" ]; then | if [ -z "$1" ]; then | ||||
journalctl -x -u logstash | grep "cluster_block" | filter_index_name | journalctl -x -u logstash | grep ${CONDITION} | filter_index_name | ||||
else | else | ||||
tail -n$1 $LOGFILE | grep "cluster_block" | filter_index_name | tail -n$1 $LOGFILE | grep ${CONDITION} | filter_index_name | ||||
fi | fi | ||||
} | } | ||||
while true; do | while true; do | ||||
date | date | ||||
echo "Searching indices to reopen..." | echo "Searching indices to reopen..." | ||||
INDICES="$(log_indices $LIMIT)" | INDICES="$(log_indices $LIMIT)" | ||||
echo "Found: ${INDICES}" | echo "Found: ${INDICES}" | ||||
Show All 13 Lines |