AWS Elastic Beanstalk의 ATOP 배포를 위한 구성 파일

AWS Elastic Beanstalk의 ATOP 배포를 위한 구성 파일

해결됨 머신이 Beanstalk에서 배포될 때 인스턴스를 EC2에 설치하려면 ATOP가 필요합니다. AWS 지원에는 따라야 할 아래 링크만 있었지만 ebextensions 구성 파일에 배포하는 방법은 나와 있지 않습니다. 누군가 이미 이 작업을 수행하고 구성 파일을 이미 만들었습니까? 감사해요! -->https://www.tecmint.com/how-to-install-atop-to-monitor-logging-activity-of-linux-system-processes/

{{18년 3월 23일 수정}}

지금까지 이 문제를 스스로 해결하면서 이것이 제가 가진 것입니다. 완전히 작동하지는 않지만 여전히 작업 중입니다.

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

답변1

AWS Beanstalk 기술 지원의 놀라운 Yao의 도움으로 모든 인스턴스에 ATOP를 설치하는 파일을 생성할 수 있었습니다. 또한 확장 및 시스템 배포를 통해 로그가 유지되도록 이미 기존의 심볼릭 링크된 EFS 파일 디렉터리에 개별 인스턴스 로그를 기록합니다. 이것은 현재 내 개발 배포에서 작동하고 있습니다. 다른 소리가 들리지 않으면 약 일주일 안에 프로덕션에서도 작동한다는 의미입니다. 다음은 내 Wordpress 배포를 위해 조정된 내용입니다. 즐기다!

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

답변2

긍정적이지는 않지만 AWS 인스턴스 CLI에서 해당 컬 URL을 실행하면 호출하려는 인스턴스 ID가 반환될 것이라고 생각합니다. 이를 사용하는 방법 중 하나는 인스턴스 ID를 폴더 이름으로 사용하여 로그 디렉터리를 생성하여 ATOP를 실행하는 인스턴스별로 기록하고 검색할 수 있도록 하는 것입니다.

관련 정보