Skip to content

Instantly share code, notes, and snippets.

@leitu
Last active August 29, 2015 14:12
Show Gist options
  • Save leitu/ae30a4c1a1f342df1274 to your computer and use it in GitHub Desktop.
Save leitu/ae30a4c1a1f342df1274 to your computer and use it in GitHub Desktop.
logstash-forwarder
#! /bin/sh
# From The Logstash Book
# The original of this file can be found at: http://logstashbook.com/code/index.html
#
# logstash-forwarder Start/Stop logstash-forwarder
#
# chkconfig: 345 99 99
# description: logstash-forwarder
# processname: logstash-forwarder
LOGSTASH_FORWARDER_BIN="/opt/logstash-forwarder/bin/logstash-forwarder"
LOGSTASH_FORWARDER_CFG="/etc/logstash-forwarder"
LOGSTASH_FORWARDER_OPTIONS="-spool-size=1024"
find_logstash_forwarder_process () {
PIDTEMP=`pgrep -f ${LOGSTASH_FORWARDER_BIN}`
# Pid not found
if [ "x$PIDTEMP" = "x" ]; then
PID=-1
else
PID=$PIDTEMP
fi
}
start () {
nohup ${LOGSTASH_FORWARDER_BIN} -config=${LOGSTASH_FORWARDER_CFG} ${LOGSTASH_FORWARDER_
OPTIONS} 2>&1 &
}
stop () {
pkill -f ${LOGSTASH_FORWARDER_BIN}
}
case $1 in
start)
start
;;
stop)
stop
exit 0;
;;
reload)
stop
start
;;
restart)
stop
start
;;
status)
find_logstash_forwarder_process
if [ $PID -gt 0 ]; then
exit 0
else
exit 1
fi
;;
*fi)
echo $"Usage: $0 {start|stop|restart|reload|status}"
RETVAL=1
esac
exit 0
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment