すべてのプロダクト
Search
ドキュメントセンター

CloudOps Orchestration Service:ACS-ECS-InstallXDragonAndCloudMonitor

最終更新日:Dec 21, 2025

テンプレート名

ACS-ECS-InstallXDragonAndCloudMonitor:X-Dragon および CloudMonitor プラグインをバッチインストールします

今すぐ実行

テンプレートの説明

複数の Elastic Compute Service (ECS) インスタンスに SHENLONG ハードウェア検出プラグイン、CloudMonitor、および smartmontools をインストールし、SHENLONG ハードウェア検出プラグインをアンインストールおよび更新します

テンプレートタイプ

自動化

所有者

Alibaba Cloud

入力パラメーター

パラメーター

説明

タイプ

必須

デフォルト値

制限

targets

ターゲットインスタンス

Json

はい

action

操作タイプ

String

はい

regionId

リージョン ID。

String

いいえ

{{ ACS::RegionId }}

timeout

ECS インスタンスでコマンドを実行するためのタイムアウト期間。

Number

いいえ

600

rateControl

タスク実行の同時実行数

Json

いいえ

{'Mode': 'Concurrency', 'MaxErrors': 0, 'Concurrency': 10}

OOSAssumeRole

CloudOps Orchestration Service (OOS) によって引き受けられる Resource Access Management (RAM) ロール。

String

いいえ

""

出力パラメーター

パラメーター

説明

タイプ

commandOutputs

String

テンプレートを実行するために必要な権限ポリシー

{
    "Version": "1",
    "Statement": [
        {
            "Action": [
                "ecs:DescribeInstances",
                "ecs:DescribeInvocationResults",
                "ecs:DescribeInvocations",
                "ecs:RunCommand"
            ],
            "Resource": "*",
            "Effect": "Allow"
        },
        {
            "Action": [
                "oos:GetApplicationGroup"
            ],
            "Resource": "*",
            "Effect": "Allow"
        }
    ]
}

詳細

ACS-ECS-InstallXDragonAndCloudMonitor:詳細

テンプレートコンテンツ

FormatVersion: OOS-2019-06-01
Description:
  en: X-Dragon ハードウェア検出プラグイン、CloudMonitor、および smartmontools を一括でインストールします。このテンプレートは、X-Dragon ハードウェア検出プラグインのアンインストールまたは更新も行います。
  zh-cn: X-Dragon ハードウェア検出プラグイン、CloudMonitor、および smartmontools を一括でインストールします。このテンプレートは、X-Dragon ハードウェア検出プラグインのアンインストールまたは更新も行います。
  name-en: ACS-ECS-InstallXDragonAndCloudMonitor
  name-zh-cn: X-Dragon および監視プラグインのバッチインストール
  categories:
    - run_command
Parameters:
  regionId:
    Type: String
    Label:
      en: リージョン ID
      zh-cn: リージョン ID
    AssociationProperty: RegionId
    Default: '{{ ACS::RegionId }}'
  targets:
    Type: Json
    Label:
      en: ターゲットインスタンス
      zh-cn: ターゲットインスタンス
    AssociationProperty: Targets
    AssociationPropertyMetadata:
      ResourceType: 'ALIYUN::ECS::Instance'
      RegionId: regionId
  action:
    Type: String
    Label:
      en: 操作タイプ
      zh-cn: 操作タイプ
    AllowedValues:
      - install
      - update
      - remove
  timeout:
    Label:
      en: コマンド実行のタイムアウト
      zh-cn: ECS インスタンスでコマンドを実行するためのタイムアウト期間 (秒)。
    Type: Number
    Default: 600
  rateControl:
    Label:
      en: レート制御
      zh-cn: タスク実行の同時実行数。
    Type: Json
    AssociationProperty: RateControl
    Default:
      Mode: Concurrency
      MaxErrors: 0
      Concurrency: 10
  OOSAssumeRole:
    Label:
      en: OOS が引き受ける RAM ロール
      zh-cn: OOS が引き受ける RAM ロール。
    Type: String
    Default: ''
RamRole: '{{ OOSAssumeRole }}'
Tasks:
  - Name: getInstance
    Description:
      en: 指定された ECS インスタンスを取得します。
      zh-cn: 指定された ECS インスタンスを取得します。
    Action: ACS::SelectTargets
    Properties:
      ResourceType: ALIYUN::ECS::Instance
      RegionId: '{{ regionId }}'
      Filters:
        - '{{ targets }}'
    Outputs:
      instanceIds:
        Type: List
        ValueSelector: Instances.Instance[].InstanceId
  - Name: runCommand
    Action: 'ACS::ECS::RunCommand'
    Description: ECS インスタンスでコマンドを実行し、出力を取得します。
    Properties:
      regionId: '{{ regionId }}'
      commandContent:
        'Fn::Join':
          - |+

          - - 'if [ "{{action}}" = "install" ] ; then'
            - smart_version=`$(smartctl -V)`
            - 'if [ "$smart_version" = "" ]; then'
            - '    sys_version=$(echo `lsb_release -a`)'
            - '    if [ "`echo $sys_version`"=~"CentOS" ]; then'
            - '       yum -y install yum-utils'
            - '       yum -y install smartmontools'
            - '       echo `smartctl -V`'
            - '    fi'
            - '    if [ "`echo $sys_version`"=~"Ubuntu" ]; then'
            - '       apt-get update -y && apt-get upgrade -y && apt install smartmontools -y'
            - '    fi'
            - fi
            - ''
            - aliyun_installer -i xdragon_hardware_detect_plugin -e 1.0.0
            - echo "installing cms agent"
            - ''
            - 'if [ -z "${CMS_HOME}" ]; then'
            - '  CMS_HOME="/usr/local/cloudmonitor"'
            - '  [ ! -z "`egrep -i coreos /etc/os-release`" ] && CMS_HOME="/opt/cloudmonitor"'
            - fi
            - ''
            - 'if [ `uname -m` = "x86_64" ]; then'
            - '    ARCH="amd64"'
            - else
            - '    ARCH="386"'
            - fi
            - ''
            - VERSION="2.1.57"
            - 'ELF_NAME=CmsGoAgent.linux-${ARCH}'
            - 'DOWNLOAD_PATH="cms-go-agent/${VERSION}/${ELF_NAME}"'
            - 'DEST_UPDATE_FILE="$CMS_HOME/${ELF_NAME}"'
            - ''
            - current_cms_version="0"
            - '# X-Dragon インスタンスは常に x86 アーキテクチャを使用します。バージョンを確認します。'
            - 'if [ -f /usr/local/cloudmonitor/CmsGoAgent.linux-amd64 ]; then'
            - '    current_cms_version="$($DEST_UPDATE_FILE version)"'
            - fi
            - ''
            - 'if [ $current_cms_version = "2.1.57" ]; then'
            - '    echo "CmsGoAgent already installed"'
            - '    echo "Installation success."'
            - '    exit 0'
            - fi
            - ''
            - 'if [ -z "${REGION_ID}" ]; then'
            - '  REGION_ID="$(wget -q --timeout=1 -t 1 -O - ''http://100.100.100.200/latest/meta-data/region-id'')"'
            - fi
            - ''
            - ''
            - 'if [ -d $CMS_HOME ] ; then'
            - '  if [ -f $CMS_HOME/wrapper/bin/cloudmonitor.sh ] ; then'
            - '    $CMS_HOME/wrapper/bin/cloudmonitor.sh remove;'
            - '    rm -rf $CMS_HOME;'
            - '  elif [ -f $DEST_UPDATE_FILE ]; then'
            - '    $DEST_UPDATE_FILE stop'
            - '    #$DEST_UPDATE_FILE uninstall'
            - '    ps aux | grep -v grep | grep $ELF_NAME'
            - '  fi'
            - fi
            - ''
            - download()
            - '{'
            - '  if [ -z "${REGION_ID}" ]; then'
            - '    echo "networkType is classic"'
            - '    OSS_URL="http://cms-agent-cn-hangzhou.oss-cn-hangzhou-internal.aliyuncs.com/$DOWNLOAD_PATH"'
            - '  else'
            - '    echo "networkType is vpc, REGION_ID: $REGION_ID"'
            - '    if [ "$REGION_ID" = "cn-shenzhen-finance-1" ]; then'
            - '      OSS_URL="http://cms-download.aliyun.com/$DOWNLOAD_PATH"'
            - '      CMS_PROXY="szcmsproxy.aliyun.com:3128"'
            - '    elif [ "$REGION_ID" = "cn-shanghai-finance-1" ]; then'
            - '      OSS_URL="http://cms-agent-$REGION_ID.oss-$REGION_ID-pub-internal.aliyuncs.com/$DOWNLOAD_PATH"'
            - '    elif [ "$REGION_ID" = "ap-south-1" ]; then'
            - '      OSS_URL="http://cms-download.aliyun.com/$DOWNLOAD_PATH"'
            - '      CMS_PROXY="cmsproxy-ap-south-1.aliyuncs.com:8080"'
            - '    elif [ "$REGION_ID" = "me-east-1" -o "$REGION_ID" = "cn-chengdu" ]; then'
            - '      OSS_URL="http://cms-download.aliyun.com/$DOWNLOAD_PATH"'
            - '    else'
            - '      OSS_URL="http://cms-agent-$REGION_ID.oss-$REGION_ID-internal.aliyuncs.com/$DOWNLOAD_PATH"'
            - '    fi'
            - '  fi'
            - '  echo download from "$OSS_URL"'
            - '  wget -q -e "http_proxy=$CMS_PROXY" "$OSS_URL" -O "$DEST_UPDATE_FILE" -t 3 --connect-timeout=2'
            - '  if [ $? != 0 ]; then'
            - '    echo "download fail, retry..."'
            - '    CMS_PROXY="vpc-opencmsproxy.aliyun.com:8080";'
            - '    OSS_URL="http://cms-download.aliyun.com/$DOWNLOAD_PATH"'
            - '    wget -q -e "http_proxy=$CMS_PROXY" "$OSS_URL" -O "$DEST_UPDATE_FILE" -t 3 --connect-timeout=2'
            - '  fi'
            - '  if [ $? != 0 ]; then'
            - '    echo "download fail, retry..."'
            - '    CMS_PROXY="opencmsproxy.aliyun.com:8080";'
            - '    OSS_URL="http://cms-download.aliyun.com/$DOWNLOAD_PATH"'
            - '    wget -q -e "http_proxy=$CMS_PROXY" "$OSS_URL" -O "$DEST_UPDATE_FILE" -t 3 --connect-timeout=2'
            - '  fi'
            - '}'
            - ''
            - mkdir -p $CMS_HOME && \
            - 'chown -R root:root $CMS_HOME && \'
            - download && \
            - chmod a+x $DEST_UPDATE_FILE
            - $DEST_UPDATE_FILE check
            - RC=$?
            - 'if [ ${RC} -ne 0 ]; then'
            - '    echo CmsGoAgent install failed, your platform is not supported'
            - '    exit ${RC}'
            - fi
            - ''
            - $DEST_UPDATE_FILE install >/dev/null 2>&1 || true
            - $DEST_UPDATE_FILE start
            - ps aux | grep -v grep | grep $ELF_NAME
            - ''
            - ACT_VERSION=`$DEST_UPDATE_FILE version`
            - 'if [ -n "$ACT_VERSION" ]; then'
            - '    echo CmsGoAgent v$ACT_VERSION installed'
            - else
            - '    echo CmsGoAgent install failed'
            - '    exit 1'
            - fi
            - 'elif [ "{{action}}" = "update" ] ; then'
            - ' aliyun_installer -d xdragon_hardware_detect_plugin'
            - 'elif [ "{{action}}" = "remove" ] ; then'
            - ' aliyun_installer -u xdragon_hardware_detect_plugin'
            - fi
      instanceId: '{{ ACS::TaskLoopItem }}'
      timeout: '{{ timeout }}'
      commandType: RunShellScript
    Loop:
      Items: '{{ getInstance.instanceIds }}'
      RateControl: '{{ rateControl }}'
      Outputs:
        commandOutputs:
          AggregateType: Fn::ListJoin
          AggregateField: commandOutput
    Outputs:
      commandOutput:
        Type: String
        ValueSelector: invocationOutput
Outputs:
  commandOutputs:
    Type: String
    Value: '{{ runCommand.commandOutputs }}'
Metadata:
  ALIYUN::OOS::Interface:
    ParameterGroups:
      - Parameters:
          - action
          - timeout
        Label:
          default:
            zh-cn: パラメーターの設定
            en: パラメーターの設定
      - Parameters:
          - regionId
          - targets
        Label:
          default:
            zh-cn: インスタンスの選択
            en: インスタンスの選択
      - Parameters:
          - rateControl
          - OOSAssumeRole
        Label:
          default:
            zh-cn: 詳細オプション
            en: 詳細オプション