Skip to content

Instantly share code, notes, and snippets.

@leonsodhi
Forked from troy/01papertrail.config
Last active December 23, 2015 18:39
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save leonsodhi/6677257 to your computer and use it in GitHub Desktop.
Save leonsodhi/6677257 to your computer and use it in GitHub Desktop.
# Credit: Jason Pirkey, Táve Corporation, http://www.tave.com/
# See http://help.papertrailapp.com/kb/hosting-services/amazon-elastic-beanstalk
packages:
yum:
rubygems: []
ruby-devel: []
openssl-devel: []
rubygems:
eventmachine: []
remote_syslog: []
files:
"/etc/remote_applog.yml":
mode: "00644"
owner: root
group: root
encoding: plain
content: |
files: [/var/log/YOUR/LOG_FILE1, /var/log/YOUR/LOG_FILE2]
destination:
host: logs.papertrailapp.com
port: <YOUR-PORT-NUMBER>
"/tmp/update-remote-log-hostname.sh":
mode: "00555"
owner: root
group: root
encoding: plain
content: |
#!/bin/bash
logger_config="/etc/remote_applog.yml"
if [ -f $logger_config ]; then
# remove the current host entry
sed -i "/hostname*/d" $logger_config
# add the proper one
sed -i "1i\
hostname: $YOUR_HOST_NAME" $logger_config
fi
"/etc/init.d/remote_applog":
mode: "00555"
owner: root
group: root
encoding: plain
content: |
#!/bin/bash
#
# remote_syslog This shell script takes care of starting and stopping
# remote_syslog daemon
#
# chkconfig: - 58 74
# description: papertrail/remote_syslog \
# https://github.com/papertrail/remote_syslog/blob/master/examples/remote_syslog.init.d
### BEGIN INIT INFO
# Provides: remote_applog
# Required-Start: $network $local_fs $remote_fs
# Required-Stop: $network $local_fs $remote_fs
# Should-Start: $syslog $named ntpdate
# Should-Stop: $syslog $named
# Short-Description: start and stop remote_errolog
# Description: papertrail/remote_syslog
# https://github.com/papertrail/remote_syslog/blob/master/examples/remote_syslog.init.d
### END INIT INFO
# Source function library.
. /etc/init.d/functions
# Source networking configuration.
. /etc/sysconfig/network
if [ -f /usr/bin/remote_syslog ]; then
prog="/usr/bin/remote_syslog"
else
prog="/opt/elasticbeanstalk/bin/remote_syslog"
fi
config="/etc/remote_applog.yml"
pid_dir="/var/run"
EXTRAOPTIONS=""
pid_file="$pid_dir/remote_applog.pid"
PATH=/sbin:/bin:/usr/bin:/usr/sbin:/usr/local/bin:/usr/local/sbin
RETVAL=0
is_running(){
[ -e $pid_file ]
}
start(){
echo -n $"Starting $prog: "
unset HOME MAIL USER USERNAME
$prog -c $config --tls --pid-file $pid_file $EXTRAOPTIONS
RETVAL=$?
echo
return $RETVAL
}
stop(){
echo -n $"Stopping $prog: "
if (is_running); then
kill `cat $pid_file`
RETVAL=$?
echo
return $RETVAL
else
echo "$pid_file not found"
fi
}
status(){
echo -n $"Checking for $pid_file: "
if (is_running); then
echo "found"
else
echo "not found"
fi
}
reload(){
restart
}
restart(){
stop
start
}
condrestart(){
is_running && restart
return 0
}
# See how we were called.
case "$1" in
start)
start
;;
stop)
stop
;;
status)
status
;;
restart)
restart
;;
reload)
reload
;;
condrestart)
condrestart
;;
*)
echo $"Usage: $0 {start|stop|status|restart|condrestart|reload}"
RETVAL=1
esac
exit $RETVAL
commands:
01_update_config_file:
command: ". /tmp/update-remote-log-hostname.sh"
02_enable_service:
command: "/sbin/chkconfig remote_applog on"
03_start_service:
command: "/sbin/service remote_applog restart"
ignoreErrors: true
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment