Skip to content

Instantly share code, notes, and snippets.

@whiskeyalpharomeo
Created June 16, 2015 22:32
Show Gist options
  • Save whiskeyalpharomeo/de6728c6e5b0dfa7f8c7 to your computer and use it in GitHub Desktop.
Save whiskeyalpharomeo/de6728c6e5b0dfa7f8c7 to your computer and use it in GitHub Desktop.
Logstash Wrapper for sFlowtool
#!/bin/bash
#
# Wrapper script for sflowtool when used in pipe input in logstash.
# This wrapper script ensures that the sflowtool is not running prior to start of the sflowtool.
ARGS="$@"
SFLOWTOOL_PID=$(/bin/ps -ef | /bin/grep "/usr/bin/sflowtool $ARGS" | /bin/grep -v "grep" | /bin/awk ' { print $2 } ')
if [ ! -z $SFLOWTOOL_PID ]; then
kill -s 9 $SFLOWTOOL_PID
fi
/usr/bin/sflowtool "$@"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment