Page Menu
Home
Software Heritage
Search
Configure Global Search
Log In
Paste
P1135
es_open_unfreeze_from_journalctl.sh and es_open_unfreeze.sh:
Active
Public
Actions
Authored by
ardumont
on Aug 27 2021, 2:37 PM.
Edit Paste
Archive Paste
View Raw File
Subscribe
Mute Notifications
Award Token
Flag For Later
Tags
None
Subscribers
None
Manual installation so far.
es_open_unfreeze_from_journalctl.sh:
```
root@logstash0:~# cat /usr/local/bin/es_open_unfreeze_from_journalctl.sh
#!/bin/bash
set -x
# Script to reopen and eventually unfreeze frozen indices in elasticsearch
# reason:
# - closed index or frozen index can't be written to
# - journalbeat replays old logs when a machine is rebooted which creates icinga alerts
# - source of this behavior ^ is not determined yet so we work around it with the following script
ES_SERVER=192.168.100.61:9200
LIMIT=$1
function filter_index_name() {
awk '{print $17}' | sort | uniq | tr -d '[' | tr -d ']'
}
function log_indices() {
if [ -z "$1" ]; then
journalctl -x -u logstash | grep "cluster_block" | filter_index_name
else
tail -n$1 $LOGFILE | grep "cluster_block" | filter_index_name
fi
}
while true; do
date
log_indices $LIMIT | xargs -r -t -n1 -i{} curl -s -XPOST http://$ES_SERVER/{}/_open;
log_indices $LIMIT | xargs -r -t -n1 -i{} curl -s -XPOST $ES_SERVER/{}/_unfreeze;
sleep 30
done
```
es_open_unfreeze.sh:
```
root@logstash0:~# cat /usr/local/bin/es_open_unfreeze.sh
#!/bin/bash
set -x
# Script to reopen and eventually unfreeze frozen indices in elasticsearch
# reason:
# - closed index or frozen index can't be written to
# - journalbeat replays old logs when a machine is rebooted which creates icinga alerts
# - source of this behavior ^ is not determined yet so we work around it with the following script
ES_SERVER=192.168.100.61:9200
LOGFILE=/var/log/logstash/logstash-plain.log
LIMIT=$1
function filter_index_name() {
awk '{print $12}' | sort | uniq | tr -d '[' | tr -d ']'
}
function log_indices() {
if [ -z "$1" ]; then
grep "cluster_block" $LOGFILE | filter_index_name
else
tail -n$1 $LOGFILE | grep "cluster_block" | filter_index_name
fi
}
while true; do
date
log_indices $LIMIT | xargs -r -t -n1 -i{} curl -s -XPOST http://$ES_SERVER/{}/_open;
log_indices $LIMIT | xargs -r -t -n1 -i{} curl -s -XPOST $ES_SERVER/{}/_unfreeze;
sleep 30
done
```
j
Event Timeline
ardumont
created this paste.
Aug 27 2021, 2:37 PM
2021-08-27 14:37:38 (UTC+2)
ardumont
mentioned this in
T3545: Update the journalbeat version package
.
Sep 2 2021, 12:29 PM
2021-09-02 12:29:43 (UTC+2)
Log In to Comment