安装监控插件
本文介绍了两种安装监控插件xdragon_hardware_detect_plugin的方式,适用于使用了本地盘的弹性裸金属服务器实例。
前提条件
待安装监控插件的弹性裸金属服务器实例必须满足以下条件:
背景信息
如果您使用的是搭载了本地盘的弹性裸金属服务器实例规格,需要您自行监控和诊断本地盘健康状态。
插件xdragon_hardware_detect_plugin可以定期检测弹性裸金属服务器实例上的本地盘设备的健康状态,如果发生本地盘异常事件,插件会自动将异常事件反馈成本地盘系统事件。对应的系统事件代码为SystemMaintenance.ReInitErrorDisk
。详情请参见本地盘实例系统事件概述。
方式一:使用OOS批量安装监控插件
运维编排服务OOS能通过公共模板自动安装监控插件xdragon_hardware_detect_plugin。
方式二:手动安装监控插件
云助手客户端提供的aliyun_installer工具可以下载并安装监控插件xdragon_hardware_detect_plugin。
手动安装特殊版本云监控插件的Shell脚本如下所示:
#!/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
执行结果
aliyun_installer -d xdragon_hardware_detect_plugin
,卸载插件可执行aliyun_installer -u xdragon_hardware_detect_plugin
。
后续步骤
您可以调用ECS API隔离损坏的本地盘,隔离后,弹性裸金属服务器实例不会变更所宿物理机。详情请参见本地盘实例系统事件。
版权声明
本文仅代表作者观点,不代表本站立场。
本文系作者授权发表,未经许可,不得转载。
评论