mirror of
https://github.com/Security-Onion-Solutions/securityonion.git
synced 2025-12-11 03:32:53 +01:00
Revise Elastalert index check deletion logic
This commit is contained in:
@@ -852,13 +852,33 @@ up_to_2.3.140() {
|
|||||||
fi
|
fi
|
||||||
|
|
||||||
# Delete Elastalert indices
|
# Delete Elastalert indices
|
||||||
for i in $(so-elasticsearch-query _cat/indices | grep elastalert | awk '{print $3}'); do so-elasticsearch-query $i -XDELETE; done
|
for i in $(so-elasticsearch-query _cat/indices | grep elastalert | awk '{print $3}');
|
||||||
# Check to ensure Elastalert indices have been deleted
|
do
|
||||||
RESPONSE=$(so-elasticsearch-query elastalert*)
|
so-elasticsearch-query $i -XDELETE;
|
||||||
if [[ "$RESPONSE" == "{}" ]]; then
|
done
|
||||||
echo "Elastalert indices have been deleted."
|
|
||||||
else
|
# Check to ensure Elastalert indices are deleted
|
||||||
fail "Something went wrong. Could not delete the Elastalert indices. Exiting."
|
COUNT=0
|
||||||
|
ELASTALERT_INDICES_DELETED="no"
|
||||||
|
while [[ "$COUNT" -le 240 ]]; do
|
||||||
|
RESPONSE=$(so-elasticsearch-query elastalert*)
|
||||||
|
if [[ "$RESPONSE" == "{}" ]]; then
|
||||||
|
ELASTALERT_INDICES_DELETED="yes"
|
||||||
|
echo "Elastalert indices successfully deleted."
|
||||||
|
break
|
||||||
|
else
|
||||||
|
((COUNT+=1))
|
||||||
|
sleep 1
|
||||||
|
echo -n "."
|
||||||
|
fi
|
||||||
|
done
|
||||||
|
|
||||||
|
# If we were unable to delete the Elastalert indices, exit the script
|
||||||
|
if [ "$ELASTALERT_INDICES_DELETED" == "no" ]; then
|
||||||
|
echo
|
||||||
|
echo -e "Unable to connect to delete Elastalert indices. Exiting."
|
||||||
|
echo
|
||||||
|
exit 1
|
||||||
fi
|
fi
|
||||||
##
|
##
|
||||||
INSTALLEDVERSION=2.3.140
|
INSTALLEDVERSION=2.3.140
|
||||||
|
|||||||
Reference in New Issue
Block a user