1

SOLVED I need ATOP to install on EC2 the instances when the machines deploy from Beanstalk. AWS support only had the link below to follow, but it doesn't show how to deploy in the ebextensions config files. Has someone already done this and have a config file already made? Thanks! --> https://www.tecmint.com/how-to-install-atop-to-monitor-logging-activity-of-linux-system-processes/

{{Edit 3/23/18}}

Working through this on my own so far, this is what I have. It doesn't fully work, but still working on it.

packages:
  rpm:
    epel: https://dl.fedoraproject.org/pub/epel/epel-release-latest-6.noarch.rpm

container_commands:
  1_rpm_atop:
    command: "sudo /bin/rpm -i --replacepkgs 
https://www.atoptool.nl/download/atop-2.3.0-1.el6.x86_64.rpm"
  2_add_atop:
    command: "/sbin/chkconfig --add atop"
    leader_only: true
  3_add_atop:
    command: "/sbin/chkconfig atop on --level 235"
    leader_only: true
  4_config_atop:
    command: "/bin/sed 's/600/60/' /usr/share/atop/atop.daily -i"
    leader_only: true
  5_link:
    command: "/bin/ln -sfn /var/log/atop /var/app/current/wp-content/uploads/atop"
    leader_only: true
  6_start:
    command: "/etc/init.d/atop start"
    leader_only: true
Kliqks
  • 21
  • 4

2 Answers2

1

With the help of the amazing Yao from AWS Beanstalk tech support, we have been able to create a file that installs ATOP on all instances. As well, it writes individual instance logs to my already existing sym-linked EFS file directory so that the logs will persist through scaling and machine deployments. This is working now in my dev deployment. If you hear nothing else, it will mean that it is working in production as well in about a week. Here's the contents tweaked for my Wordpress deployment. Enjoy!

container_commands:
  1_install_config_atop:
    command: /tmp/installatop.sh

files:
  "/tmp/installatop.sh":
      mode: "000755"
      content : |
        #!/bin/bash

    #############################################


    ATOPLOGDEST=/var/app/current/wp-content/uploads/atop/   #where to persist the atop log
    LOGFILE=/tmp/atopinstall.log #installaton log

    ##############################################
    INSTANCEID=$(curl http://169.254.169.254/latest/meta-data/instance-id/)

    exec 1>&- # close stdout
    exec 2>&- # close stderr

    echo "========" >> $LOGFILE
    date >> $LOGFILE
    echo "starting" >> $LOGFILE

    echo "---- Step 1, install atop" >> $LOGFILE
    echo "check if atop is installed" >> $LOGFILE
    rpm -q atop >> $LOGFILE
    if [ $? -ne 0 ]
    then
      echo "atop not installed yet" >> $LOGFILE
      rpm -i https://www.atoptool.nl/download/atop-2.3.0-1.el6.x86_64.rpm
      rpm -q atop >> $LOGFILE
      echo "now installed" >> $LOGFILE
    fi

    echo "---- step 2, config atop in chkconfig" >> $LOGFILE
    /sbin/chkconfig --add atop
    /sbin/chkconfig atop on --level 235
    echo "this is the output of chkconfig"  >> $LOGFILE
    /sbin/chkconfig | grep atop >> $LOGFILE

    echo "---- setp 3, config atop's schedule to 60 seconds" >> $LOGFILE
    /bin/sed 's/600/60/' /usr/share/atop/atop.daily -i
    cat /usr/share/atop/atop.daily | grep "INTERVAL=" >> $LOGFILE

    echo "---- step 4, presistent it in EFS" >> $LOGFILE
    mkdir -p $ATOPLOGDEST$INSTANCEID
    /bin/sed "s|/var/log/atop|$ATOPLOGDEST$INSTANCEID|" /usr/share/atop/atop.daily -i
    cat /usr/share/atop/atop.daily | grep "LOGPATH=" >> $LOGFILE
    stat $ATOPLOGDEST$INSTANCEID >> $LOGFILE

    echo "---- step 5, restart atop" >> $LOGFILE
    /etc/init.d/atop restart
    sleep 5
    ps aux | grep atop >> $LOGFILE

    echo "---- finished!" >> $LOGFILE
    date >> $LOGFILE
    echo "========" >> $LOGFILE
Kliqks
  • 21
  • 4
0

Iā€™m not positive, but I think if you were to run that curl url from an AWS instance CLI, it will return the instance ID from which you are calling from. One of the ways it uses this is to create log directories with the instance ID as the folder name so that they can be logged to and retrieved per instance that runs ATOP.

Kliqks
  • 1