Skip to content

Instantly share code, notes, and snippets.

@hartfordfive
Created April 2, 2015 19:54
Show Gist options
  • Save hartfordfive/34792fb6e8dd75478539 to your computer and use it in GitHub Desktop.
Save hartfordfive/34792fb6e8dd75478539 to your computer and use it in GitHub Desktop.
Get list of files open by logstash-forwarder
#!/bin/bash
OUTPUT=`lsof -X -c logstash- | egrep -v '\.logstash-forwarder' | egrep -E '[0-9]+r\s+REG' | awk '{print $9}'`
case "$1" in
'json')
FILES=`printf ",\"%s\"" \${OUTPUT[@]}`
echo "{\"open_files\": [${FILES:1:${#FILES}-1}]}"
;;
*)
for F in "$OUTPUT"
do
echo "$F"
done
;;
esac
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment