Cloudinsight Agent install script
#!/bin/bash
# Cloudinsight Agent install script.
set -e
logfile="ci-agent-install.log"
gist_request=/tmp/agent-gist-request.tmp
gist_response=/tmp/agent-gist-response.tmp if [ $(command -v curl) ]; then
cl_cmd="curl -f"
else
cl_cmd="wget --quiet"
fi # Set up a named pipe for logging
npipe=/tmp/$$.tmp
mknod $npipe p # Log all output to a log for error checking
tee <$npipe $logfile &
exec 1>&-
exec 1>$npipe 2>&1
trap "rm -f $npipe" EXIT function on_error() {
printf "\033[31m$ERROR_MESSAGE
It looks like you hit an issue when trying to install the Agent. Troubleshooting and basic usage information for the Agent are available at: http://docs-ci.oneapm.com/quick-start/ If you're still having problems, please contact to support@oneapm.com
and we'll try our best to help you solve your problem.\n\033[0m\n"
}
trap on_error ERR if [ -n "$CI_LICENSE_KEY" ]; then
license_key=$CI_LICENSE_KEY
fi if [ -n "$CI_INSTALL_ONLY" ]; then
no_start=true
else
no_start=false
fi if [ ! $license_key ]; then
printf "\033[31mLicense key not available in CI_LICENSE_KEY environment variable.\033[0m\n"
exit 1;
fi # OS/Distro Detection
# Try lsb_release, fallback with /etc/issue then uname command
KNOWN_DISTRIBUTION="(Debian|Ubuntu|RedHat|CentOS|Amazon)"
DISTRIBUTION=$(lsb_release -d 2>/dev/null | grep -Eo $KNOWN_DISTRIBUTION || grep -Eo $KNOWN_DISTRIBUTION /etc/issue 2>/dev/null || uname -s) if [ $DISTRIBUTION = "Darwin" ]; then
printf "\033[31mThis script does not support installing on the Mac..\033[0m\n"
exit 1; elif [ -f /etc/debian_version -o "$DISTRIBUTION" == "Debian" -o "$DISTRIBUTION" == "Ubuntu" ]; then
OS="Debian"
elif [ -f /etc/redhat-release -o "$DISTRIBUTION" == "RedHat" -o "$DISTRIBUTION" == "CentOS" -o "$DISTRIBUTION" == "Amazon" ]; then
OS="RedHat"
elif [ -f /etc/system-release -o "$DISTRIBUTION" == "Amazon" ]; then
OS="RedHat"
fi # Root user detection
if [ $(echo "$UID") = "" ]; then
sudo_cmd=''
else
sudo_cmd='sudo'
fi function backup_old_configuration {
if [[ ! -d /etc/cloudinsight-agent ]]; then
# New configuration does not exist, move legacy configuration to new location
echo -e "Please note, Cloudinsight Agent's configuration is now located at '/etc/cloudinsight-agent' (previously '/etc/oneapm-ci-agent')."
$sudo_cmd mkdir /etc/cloudinsight-agent
$sudo_cmd cp -r /etc/oneapm-ci-agent/checks.d /etc/cloudinsight-agent/
$sudo_cmd cp -r /etc/oneapm-ci-agent/conf.d /etc/cloudinsight-agent/ backup_name="oneapm-ci-agent.conf.$(date +%s).backup"
echo "A backup of your current configuration can be found at: /etc/cloudinsight-agent/$backup_name"
$sudo_cmd cp -a /etc/oneapm-ci-agent/oneapm-ci-agent.conf /etc/cloudinsight-agent/$backup_name
fi
} # Install the necessary package sources
if [ $OS = "RedHat" ]; then
echo -e "\033[34m\n* Installing YUM sources for Cloudinsight Agent\n\033[0m" UNAME_M=$(uname -m)
if [ "$UNAME_M" == "i686" -o "$UNAME_M" == "i386" -o "$UNAME_M" == "x86" ]; then
ARCHI="i386"
else
ARCHI="x86_64"
fi $sudo_cmd sh -c "echo -e '[cloudinsight-agent]\nname = OneAPM, Inc.\nbaseurl = http://yum.oneapm.com/$ARCHI/\nenabled=1\ngpgcheck=0\npriority=1' > /etc/yum.repos.d/cloudinsight-agent.repo" printf "\033[34m* Installing the Cloudinsight Agent package\n\033[0m\n" CI_OLD_INSTALLED=$(yum list installed oneapm-ci-agent > /dev/null 2>&1 || echo "no")
if [ "$CI_OLD_INSTALLED" != "no" ]; then
backup_old_configuration $sudo_cmd rm -f /etc/yum.repos.d/oneapm-ci-agent.repo echo -e "\033[34m\n* Uninstall oneapm-ci-agent\n\033[0m"
$sudo_cmd yum -y remove oneapm-ci-agent # Remove extra files
$sudo_cmd rm -rf /opt/oneapm-ci-agent
$sudo_cmd rm -rf /var/log/oneapm-ci-agent
$sudo_cmd rm -rf /etc/oneapm-ci-agent
fi $sudo_cmd yum -y --disablerepo='*' --enablerepo='cloudinsight-agent' install cloudinsight-agent
elif [ $OS = "Debian" ]; then
printf "\033[34m\n* Installing APT package sources for Cloudinsight Agent\n\033[0m\n"
$sudo_cmd sh -c "echo 'deb http://apt.oneapm.com/ stable main' > /etc/apt/sources.list.d/cloudinsight-agent.list"
$sudo_cmd apt-key adv --recv-keys --keyserver hkp://keyserver.ubuntu.com:80 54B043BC printf "\033[34m\n* Installing the Cloudinsight Agent package\n\033[0m\n"
ERROR_MESSAGE="ERROR
Failed to update the sources after adding the Cloudinsight repository.
This may be due to any of the configured APT sources failing -
see the logs above to determine the cause.
If the failing repository is Cloudinsight, please contact Cloudinsight support.
*****
" $sudo_cmd apt-get update -o Dir::Etc::sourcelist="sources.list.d/cloudinsight-agent.list" -o Dir::Etc::sourceparts="-" -o APT::Get::List-Cleanup=""
ERROR_MESSAGE="ERROR
Failed to install the Cloudinsight package, sometimes it may be
due to another APT source failing. See the logs above to
determine the cause.
If the cause is unclear, please contact Cloudinsight support.
*****
" if [ -f /etc/apt/sources.list.d/oneapm-ci-agent.list ]; then
$sudo_cmd rm -f /etc/apt/sources.list.d/oneapm-ci-agent.list
fi CI_OLD_INSTALLED=$(dpkg -l | grep oneapm-ci-agent > /dev/null 2>&1 || echo "no")
if [ "$CI_OLD_INSTALLED" != "no" ]; then
backup_old_configuration echo -e "\033[34m\n* Uninstall oneapm-ci-agent\n\033[0m"
$sudo_cmd apt-get purge -y oneapm-ci-agent
fi $sudo_cmd apt-get install -y --force-yes cloudinsight-agent
ERROR_MESSAGE=""
else
printf "\033[31mYour OS or distribution are not supported by this install script.
Please follow the instructions on the Agent setup page.\033[0m\n"
exit;
fi # Set the configuration
if [ -e /etc/cloudinsight-agent/cloudinsight-agent.conf ]; then
printf "\033[34m\n* Keeping old cloudinsight-agent.conf configuration file\n\033[0m\n"
else
printf "\033[34m\n* Adding your license key to the Agent configuration: /etc/cloudinsight-agent/cloudinsight-agent.conf\n\033[0m\n"
$sudo_cmd sh -c "sed 's/license_key:.*/license_key: $license_key/' /etc/cloudinsight-agent/cloudinsight-agent.conf.example > /etc/cloudinsight-agent/cloudinsight-agent.conf"
fi restart_cmd="$sudo_cmd /etc/init.d/cloudinsight-agent restart"
if command -v invoke-rc.d >/dev/null 2>&1; then
restart_cmd="$sudo_cmd invoke-rc.d cloudinsight-agent restart"
fi if $no_start; then
printf "\033[34m
* CI_INSTALL_ONLY environment variable set: the newly installed version of the agent
will not start by itself. You will have to do it manually using the following
command: $restart_cmd \033[0m\n"
exit
fi printf "\033[34m* Starting the Agent...\n\033[0m\n"
eval $restart_cmd # Wait for metrics to be submitted by the forwarder
printf "\033[32m
Your Agent has started up for the first time. We're currently verifying that
data is being submitted.\033[0m Waiting for metrics..." c=0
while [ "$c" -lt "" ]; do
sleep 1
echo -n "."
c=$(($c+1))
done # Reuse the same counter
c=0 # The command to check the status of the forwarder might fail at first, this is expected
# so we remove the trap and we set +e
set +e
trap - ERR $cl_cmd http://127.0.0.1:10010/status?threshold=0 > /dev/null 2>&1
success=$?
while [ "$success" -gt "" ]; do
sleep 1
echo -n "."
$cl_cmd http://127.0.0.1:10010/status?threshold=0 > /dev/null 2>&1
success=$?
c=$(($c+1)) if [ "$c" -gt "" -o "$success" -eq "" ]; then
# After 15 tries, we give up, we restore the trap and set -e
# Also restore the trap on success
set -e
trap on_error ERR
fi
done # Metrics are submitted, echo some instructions and exit
printf "\033[32m Your Agent is running and functioning properly. It will continue to run in the
background and submit metrics to Cloudinsight. If you ever want to stop the Agent, run: sudo /etc/init.d/cloudinsight-agent stop And to run it again run: sudo /etc/init.d/cloudinsight-agent start \033[0m"
Cloudinsight Agent install script的更多相关文章
- webpacke install vue application 报错 Failed at the phantomjs-prebuilt@2.1.14 install script
刚刚在网上下了个开源的项目: https://github.com/ing670/webappkiller 执行npm install 报错:npm ERR! Failed at the phanto ...
- Oracle 12c agent install for linux
安装Agent代理 在EM11g时,agent安装是通过在被监制主机端下载agent代理并安装,在EM12c版本号上,能够在EM12c服务端.通过"推送"的方式把agent代理在远 ...
- centos6.7 mutlipath install script
#!/bin/bash if [ `id -g` != 0 ] ;then echo -e "\033[31m Please use root user\033[0m" exit ...
- php7 install script
./configure --prefix=/home/admin/local/php7 --with-gd=/home/admin/local/libgd-2.1.1/ --with-jpeg-dir ...
- Oracle 12c agent install for windows
在Oracle EM12c 中部署agent的方法分两种,一种是通过EM12c的控制台通过ssh直接把agent"推送"安装到被管理端.这样的方法在linux平台的OMS和被管理端 ...
- ! Failed at the chromedriver@2.35.0 install script.
npm install 过程中报错 解决方法 运行 npm install chromedriver --chromedriver_cdnurl=http://cdn.npm.taobao.org/d ...
- Centos7 PXE Server Install Script
#安装前配置好centos和epel yum源 #网卡ip和localip一致 localip="192.168.88.200" eth_name='eth0' dnsmasq_i ...
- npm 安装vue 报错Failed at the chromedriver@2.46.0 install script 'node install.js'
原因一般是下载源被封了,我们连接淘宝的下载源下载: npm install chromedriver --chromedriver_cdnurl=http://cdn.npm.taobao.org/d ...
- npm 安装vue 报错Failed at the chromedriver@2.34.0 install script 'node install.js'
提示版本不够,后来百度到,在你的vue项目包下执行: npm install chromedriver --chromedriver_cdnurl=http://cdn.npm.taobao.org/ ...
随机推荐
- Java实现UDP之Echo客户端和服务端
Java实现UDP之Echo客户端和服务端 代码内容 采用UDP协议编写服务器端代码(端口任意) 编写客户机的代码访问该端口 客户机按行输入 服务器将收到的字符流和接收到的时间输出在服务器consol ...
- 硬件描述语言Verilog设计经验总结
一.硬件描述语言Verilog 粗略地看Verilog与C语言有许多相似之处.分号用于结束每个语句,注释符也是相同的(/* ... */和// 都是熟悉的),运算符"=="也用来测 ...
- (转)Unity3D游戏开发 NGUI之渐变加载到100%的Loading场景进度条
NGUI 现有的进度条存在的问题: 进度条跳跃式前进,加载到90%后卡住,突然进入下一个场景.接下来就是解决这个问题. 背景 通常游戏的主场景包含的资源较多,这会导致加载场景的时间较长.为了避免这个问 ...
- loadView, viewDidLoad 快速使用
一 loadView: 在每次访问 UIViewController时,且其 view = nil 时,会调用这个方法,所以大家在开发中想自己设置 view 的可以用这个方法,在这个方法中自定义 v ...
- @synthesize 有什么好处?
如果不用 synthesize,操作的是 @property中定义的变量,使用synthesize之后,间接的操作了一个新的成员变量,到底有什么好处?直接只用一个@property不是更简单吗?
- Map、Set、List、Queue、Stack的特点与用法
Collection 接口的接口 对象的集合 ├ List 子接口 按进入先后有序保存 可重复 │├ LinkedList ...
- php file_put_contents() 写入回车
PHP file_put_contents() 函数是一次性向文件写入字符串或追加字符串内容的最合适选择. file_put_contents() file_put_contents() 函数用于把字 ...
- Jquery $.getJSON()设置同步
如下: $.ajaxSettings.async = false; $.getJSON('/AjaxSwitchDynamicInfo/GetPortUsedCount.cspx', { switch ...
- android 安装应用程序apk安装不了
今天用测试机的时候遇到这个问题 解决办法: 在设置里面找到应用程序管理安全设置,,[允许未知来源程序安装] -------------大致以上思路,具体按钮名称我就不重新去找了------------ ...
- Android:apk文件结构
Android apk文件,即Android application package文件. 每个要安装到Android平台的应用都要被编译打包为一个单独的文件,后缀名为.apk,其中包含了应用的二进制 ...