system-config/modules/logstash/files/logstash-watchdog.sh
Clark Boylan e6efff22f6 Log logstash watchdog.
Log the activity of the logstash watchdog script so that we can get
numbers on how often this bug occurs and to help debug the script if it
doesn't do what we expect.

Change-Id: Ib12be4e5212c311744f51f0d191323651752731f
2014-02-28 17:01:15 -08:00

24 lines
753 B
Bash

#!/bin/bash
#
# This is a work around for https://logstash.jira.com/browse/LOGSTASH-1951
# Logstash disconnects from the cluster and will not rejoin under
# its own power.
date >> /var/log/logstash/watchdog.log
ES_ADDRESS=$1
echo "$ES_ADDRESS" >> /var/log/logstash/watchdog.log
JSON_OUT=$(curl -sf "http://${ES_ADDRESS}:9200/_cluster/nodes/${HOSTNAME}")
CURL_RET=$?
echo "$JSON_OUT" >> /var/log/logstash/watchdog.log
echo "$CURL_RET" >> /var/log/logstash/watchdog.log
RESULT=$(echo $JSON_OUT | jq '.nodes == {}')
echo "$RESULT" >> /var/log/logstash/watchdog.log
if [ "$CURL_RET" == "0" ] && [ "$RESULT" == "true" ] ;
then
echo "restarting" >> /var/log/logstash/watchdog.log
stop --quiet logstash-indexer
start --quiet logstash-indexer
fi