AWS Elastic Beanstalk 上 ATOP 部署的設定檔

AWS Elastic Beanstalk 上 ATOP 部署的設定檔

解決了 當機器從 Beanstalk 部署時,我需要 ATOP 在 EC2 上安裝實例。 AWS 支援僅提供以下鏈接,但沒有顯示如何在 ebextensions 設定檔中部署。有人已經這樣做了並且已經製作了配置文件嗎?謝謝! -->https://www.how-to-install-atop-to-monitor-logging-activity-of-linux-system-processes/

{{編輯 2018 年 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 運行該curl url,它將傳回您從中呼叫的實例 ID。它使用此方法的方法之一是建立以實例 ID 作為資料夾名稱的日誌目錄,以便可以在每個執行 ATOP 的實例中記錄和檢索它們。

相關內容