Skip to content

Instantly share code, notes, and snippets.

@theIV
Forked from troy/01papertrail.config
Last active August 29, 2015 14:07
Show Gist options
  • Select an option

  • Save theIV/7c333f8fe0ef7526909a to your computer and use it in GitHub Desktop.

Select an option

Save theIV/7c333f8fe0ef7526909a to your computer and use it in GitHub Desktop.

Revisions

  1. theIV revised this gist Oct 14, 2014. 1 changed file with 1 addition and 1 deletion.
    2 changes: 1 addition & 1 deletion 01papertrail.config
    Original file line number Diff line number Diff line change
    @@ -2,7 +2,7 @@
    # Jason Pirkey, Táve Corporation, http://www.tave.com/
    # Jeremy Mickelson, https://github.com/CyborgMaster

    # See http://help.papertrailapp.com/kb/hosting-services/amazon-elastic-beanstalk
    # See http://help.papertrailapp.com/kb/hosting-services/aws-elastic-beanstalk/

    packages:
    yum:
  2. @troy troy revised this gist Apr 19, 2014. 1 changed file with 33 additions and 48 deletions.
    81 changes: 33 additions & 48 deletions 01papertrail.config
    Original file line number Diff line number Diff line change
    @@ -1,15 +1,18 @@
    # Credit: Jason Pirkey, Táve Corporation, http://www.tave.com/
    # Credits:
    # Jason Pirkey, Táve Corporation, http://www.tave.com/
    # Jeremy Mickelson, https://github.com/CyborgMaster

    # See http://help.papertrailapp.com/kb/hosting-services/amazon-elastic-beanstalk

    packages:
    yum:
    rubygems: []
    rubygems: []
    ruby-devel: []
    openssl-devel: []
    rubygems:
    eventmachine: []
    remote_syslog: []
    json: []

    files:
    "/etc/remote_applog.yml":
    @@ -18,28 +21,13 @@ files:
    group: root
    encoding: plain
    content: |
    files: [/var/log/YOUR/LOG_FILE1, /var/log/YOUR/LOG_FILE2]
    files:
    - <YOUR-TRACKED-FILES>
    hostname: <YOUR-APP-NAME>
    destination:
    host: logs.papertrailapp.com
    host: <YOUR-LOG-DESTINATION>
    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
    @@ -54,7 +42,7 @@ files:
    # 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
    @@ -65,43 +53,43 @@ files:
    # 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
    $prog -c $config --tcp --pid-file $pid_file "$EXTRAOPTIONS"
    RETVAL=$?
    echo
    return $RETVAL
    }

    stop(){
    echo -n $"Stopping $prog: "
    if (is_running); then
    @@ -113,32 +101,32 @@ files:
    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)
    @@ -163,16 +151,13 @@ files:
    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:
    commands:
    01_enable_service:
    command: "/sbin/chkconfig remote_applog on"

    03_start_service:
    02_start_service:
    command: "/sbin/service remote_applog restart"
    ignoreErrors: true
  3. @troy troy revised this gist Apr 19, 2014. 1 changed file with 3 additions and 11 deletions.
    14 changes: 3 additions & 11 deletions 01papertrail.config
    Original file line number Diff line number Diff line change
    @@ -18,7 +18,7 @@ files:
    group: root
    encoding: plain
    content: |
    files: [/var/log/httpd/access_log, /var/log/httpd/error_log, /var/log/php.log]
    files: [/var/log/YOUR/LOG_FILE1, /var/log/YOUR/LOG_FILE2]
    destination:
    host: logs.papertrailapp.com
    port: <YOUR-PORT-NUMBER>
    @@ -96,7 +96,7 @@ files:
    start(){
    echo -n $"Starting $prog: "
    unset HOME MAIL USER USERNAME
    $prog -c $config --tls --pid-file $pid_file "$EXTRAOPTIONS"
    $prog -c $config --tls --pid-file $pid_file $EXTRAOPTIONS
    RETVAL=$?
    echo
    return $RETVAL
    @@ -165,14 +165,6 @@ files:
    esac

    exit $RETVAL

    "/var/log/php.log":
    mode: "00640"
    owner: webapp
    group: webapp
    encoding: plain
    content: |
    # php.log or any other file you are monitoring that the webserver is writing to

    commands:
    01_update_config_file:
    @@ -183,4 +175,4 @@ commands:

    03_start_service:
    command: "/sbin/service remote_applog restart"
    ignoreErrors: true
    ignoreErrors: true
  4. @troy troy revised this gist Feb 5, 2013. 1 changed file with 2 additions and 1 deletion.
    3 changes: 2 additions & 1 deletion 01papertrail.config
    Original file line number Diff line number Diff line change
    @@ -182,4 +182,5 @@ commands:
    command: "/sbin/chkconfig remote_applog on"

    03_start_service:
    command: "/sbin/service remote_applog restart" ignoreErrors: true
    command: "/sbin/service remote_applog restart"
    ignoreErrors: true
  5. @troy troy created this gist Feb 4, 2013.
    185 changes: 185 additions & 0 deletions 01papertrail.config
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,185 @@
    # 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/httpd/access_log, /var/log/httpd/error_log, /var/log/php.log]
    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

    "/var/log/php.log":
    mode: "00640"
    owner: webapp
    group: webapp
    encoding: plain
    content: |
    # php.log or any other file you are monitoring that the webserver is writing to

    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