Last active
October 8, 2015 20:01
-
-
Save pozgo/e38acdf3d194ce1c8c4b to your computer and use it in GitHub Desktop.
Journalctl to file for logstash-forwarder process
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
is=`ps aux | grep "journalctl -f" | grep -v grep | awk '{print$2}'` | |
file=/var/log/system.log | |
msize="12400000" # Max file sieze set to 10MB | |
asize=`ls -l /var/log/system.log | awk '{print$5}'` | |
logstaship=`fleetctl list-machines -l | grep logsystem | awk '{print$2}'` | |
hostname=`hostname` | |
# Checking the size of log file | |
if [ $asize -gt $msize ] | |
then | |
echo "" > $file | |
fi | |
#Start Journal Dump if not working | |
if [ -z "$is" ] | |
then | |
sudo journalctl -f -a >> $file & | |
sudo docker run -d --name logforwarder -h $hostname --env LOGSTASH_IP=$logstaship -v /var/log:/data/log million12/logstash-forwarder | |
fi | |
exit 0 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment