Install the monitoring agent on bare metal instances with local disks

Updated at:

This topic describes how to install the xdragon_hardware_detect_plugin agent on ECS bare metal instances with local disks.

Prerequisites

The target ECS bare metal instance must meet the following requirements:

  • The instance is in one of the following regions: China (Beijing), China (Shanghai), China (Hangzhou), China (Shenzhen), or China (Zhangjiakou).

  • The instance runs a Linux operating system.

  • If you use CloudOps Orchestration Service (OOS) to install the agent on instances using tags, the instances must have the required tags. For more information, see Create or add a tag.

  • The Cloud Assistant Agent is installed. For more information, see Install the Cloud Assistant Agent.

    Note

    By default, the Cloud Assistant Agent is pre-installed on ECS instances that are created from public images on or after December 01, 2017.

Background

If you use ECS bare metal instance types with local disks, you are responsible for monitoring and diagnosing them.

The xdragon_hardware_detect_plugin agent periodically checks the health of local disks on ECS bare metal instances. If a local disk error occurs, the agent automatically reports the error as a local disk system event. The corresponding system event code is SystemMaintenance.ReInitErrorDisk. For more information, see Maintenance and system events for instances with local disks.

Install the agent using OOS

You can use CloudOps Orchestration Service (OOS) to automatically install the xdragon_hardware_detect_plugin agent using a public template.

  1. Log on to the OOS console.

  2. In the upper-left corner of the page, select a region and resource group.地域

  3. In the left-side navigation pane, choose Automated Task > Public Template, search for ACS-ECS-InstallXDragonAndCloudMonitor, and then click Create an execution..

  4. In the Create an execution. panel, complete the following settings:

    1. On the Basic Information step, select Automatic for execution mode and then click Next: Set Parameters.

    2. On the Parameter Settings step, configure the following parameters and then click Next: Confirm.

      • Action: Select install.

        Note

        This OOS template supports installing, updating, and uninstalling the monitoring agent. Select the action you want to perform.

      • TargetInstance: Select the target ECS bare metal instances.

      • RateControl: Select Concurrency-based Control. For Concurrency, select percentage (%) and enter 100.

    3. Confirm the template settings and click Create.

    After the execution is created, you can view the results on the Executions page.

    • If Success is displayed in the Execution Status column corresponding to the O&M task, the O&M task is completed.

    • If Failed is displayed in the Execution Status column corresponding to the O&M task, you can click Details in the Actions column. Click Log in the Output section. Then, you can analyze and adjust the execution content based on the log information.

Manually install the agent

You can use the aliyun_installer tool included with Cloud Assistant Agent to download and install the xdragon_hardware_detect_plugin agent.

  1. Connect to the ECS bare metal instance as the root user.

  2. (Optional) Run the aliyun_installer -h command to view the help information for the tool.

  3. Run the following command to install the xdragon_hardware_detect_plugin agent.

    aliyun_installer -i xdragon_hardware_detect_plugin -e 1.0.0
  4. To install the CloudMonitor agent, save the script from the sample script section below as a shell file and then run it.

    bash <nameOfTheScript>.sh
    Note

    The xdragon_hardware_detect_plugin agent must be installed before the CloudMonitor agent. If you have already installed the CloudMonitor agent, restart it by running the /usr/local/cloudmonitor/CmsGoAgent.linux-amd64 restart command.

  5. Run the smartctl -V command to check if the smartctl tool for local disk monitoring and analysis is installed on the instance.

    If the command output returns a version number, the tool is installed.

  6. (Optional) If smartmontools is not installed, use one of the following commands to install it:

    • On CentOS:

      yum install smartmontools
    • On Ubuntu:

      apt update &&  apt install smartmontools
    • For other Linux distributions, see the smartmontools documentation.

The following is a sample shell script for manually installing a specific version of the CloudMonitor agent:

#!/bin/bash
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"
# xdragon always x86 arch, judge version
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" = "ap-southeast-3" -o "$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

Results

After installation, the xdragon_hardware_detect_plugin agent is installed in the /usr/local/xdragon_hwqc directory. To update the agent, run aliyun_installer -d xdragon_hardware_detect_plugin. To uninstall the agent, run aliyun_installer -u xdragon_hardware_detect_plugin.

Next steps

You can use an ECS API operation to isolate a faulty local disk. After the disk is isolated, the ECS bare metal instance remains on its current physical host. For more information, see System events for instances with local disks.