#!/bin/bash

#umonitor3-agent stop
/etc/init.d/agent-update stop
/opt/umonitor3/umonitor3-control stop agent

#download rpm
wget http://softlib.service.ucloud.cn/downloads/umonitor/umonitor3_plugin/umonitor3-agent-2.2.0-1.x86_64.rpm

rpm -e `rpm -qa | grep umonitor3-agent-`
yum -y install umonitor3-agent-2.2.0-1.x86_64.rpm

#modify config zk
sed -i 's/@ZKSERVER/172.20.180.36:2181,172.20.180.37:2181,172.20.176.40:2181,172.20.176.41:2181,172.20.176.42:2181/g' /opt/umonitor3/agent/etc/cfg.json
sed -i 's/@ZKSERVER/172.20.180.36:2181,172.20.180.37:2181,172.20.176.40:2181,172.20.176.41:2181,172.20.176.42:2181/g' /opt/umonitor3/agent-update/etc/cfg.json

#start agent-update
/etc/init.d/agent-update start

#delete rpm
rm umonitor3-agent-2.2.0-1.x86_64.rpm

#delete script
rm update_umonitor3_agent.sh
