|
|
@ -23,23 +23,26 @@ selectAction() { |
|
|
|
echo -e "${GREEN} \ 直接回车一起安装 / ${PLAIN}" |
|
|
|
echo -e "${GREEN} \ 直接回车一起安装 / ${PLAIN}" |
|
|
|
echo -e "${GREEN} ========================================================= ${PLAIN}" |
|
|
|
echo -e "${GREEN} ========================================================= ${PLAIN}" |
|
|
|
echo -e "${YELLOW} System requirements: ${PLAIN}${RED}CentOS 7${PLAIN}${YELLOW} or ${PLAIN}${RED}Ubuntu 20.04${PLAIN}${YELLOW}. ${PLAIN}" |
|
|
|
echo -e "${YELLOW} System requirements: ${PLAIN}${RED}CentOS 7${PLAIN}${YELLOW} or ${PLAIN}${RED}Ubuntu 20.04${PLAIN}${YELLOW}. ${PLAIN}" |
|
|
|
echo -e "${YELLOW} Version: ${PLAIN}${GREEN}1.0.0${PLAIN}${YELLOW} (30 Dec 2021) ${PLAIN}" |
|
|
|
echo -e "${YELLOW} Version: ${PLAIN}${GREEN}1.1.0${PLAIN}${YELLOW} (13 Jan. 2022) ${PLAIN}" |
|
|
|
echo -e "${YELLOW} Copyright (C) 2021 liveJQ cloud@livejq.fun ${PLAIN}" |
|
|
|
echo -e "${YELLOW} Copyright (C) 2021 liveJQ cloud@livejq.fun ${PLAIN}" |
|
|
|
echo "" |
|
|
|
echo "" |
|
|
|
read -rp "请输入数字选择:" num |
|
|
|
read -rp "请输入数字选择:" num |
|
|
|
case $num in |
|
|
|
case $num in |
|
|
|
1) |
|
|
|
1) |
|
|
|
get_info |
|
|
|
before |
|
|
|
install_SMP |
|
|
|
install_SMP |
|
|
|
|
|
|
|
after |
|
|
|
;; |
|
|
|
;; |
|
|
|
2) |
|
|
|
2) |
|
|
|
get_info |
|
|
|
before |
|
|
|
install_Agent |
|
|
|
install_Agent |
|
|
|
|
|
|
|
after |
|
|
|
;; |
|
|
|
;; |
|
|
|
*) |
|
|
|
*) |
|
|
|
get_info |
|
|
|
before |
|
|
|
install_SMP |
|
|
|
install_SMP |
|
|
|
install_Agent |
|
|
|
install_Agent |
|
|
|
|
|
|
|
after |
|
|
|
;; |
|
|
|
;; |
|
|
|
esac |
|
|
|
esac |
|
|
|
} |
|
|
|
} |
|
|
@ -67,29 +70,41 @@ yum -y install epel-release |
|
|
|
yum clean all && yum repolist |
|
|
|
yum clean all && yum repolist |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
get_info() { |
|
|
|
before() { |
|
|
|
source /etc/os-release || source /usr/lib/os-release || exit 1 |
|
|
|
source /etc/os-release || source /usr/lib/os-release || exit 1 |
|
|
|
if [[ $ID == "centos" ]]; then |
|
|
|
if [[ $ID == "centos" ]]; then |
|
|
|
PM="yum" |
|
|
|
PM="yum" |
|
|
|
INS="yum install" |
|
|
|
INS="yum install" |
|
|
|
updateCe |
|
|
|
updateCe |
|
|
|
|
|
|
|
$PM update |
|
|
|
|
|
|
|
$INS wget curl unzip -y |
|
|
|
|
|
|
|
wget $origin |
|
|
|
|
|
|
|
unzip master.zip |
|
|
|
elif [[ $ID == "debian" || $ID == "ubuntu" ]]; then |
|
|
|
elif [[ $ID == "debian" || $ID == "ubuntu" ]]; then |
|
|
|
PM="apt" |
|
|
|
PM="apt" |
|
|
|
INS="apt install" |
|
|
|
INS="apt install" |
|
|
|
updateUb |
|
|
|
updateUb |
|
|
|
|
|
|
|
$PM update |
|
|
|
|
|
|
|
$INS wget curl unzip -y |
|
|
|
|
|
|
|
wget $origin |
|
|
|
|
|
|
|
unzip master.zip |
|
|
|
else |
|
|
|
else |
|
|
|
exit 1 |
|
|
|
exit 1 |
|
|
|
fi |
|
|
|
fi |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
after() { |
|
|
|
|
|
|
|
rm -f master.zip |
|
|
|
|
|
|
|
rm -fr pingm-master |
|
|
|
|
|
|
|
>/root/.bash_history |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
install_SMP() { |
|
|
|
install_SMP() { |
|
|
|
rpm_packages="smokeping unzip wqy-zenhei-fonts.noarch" |
|
|
|
rpm_packages="smokeping wqy-zenhei-fonts.noarch" |
|
|
|
apt_packages="smokeping echoping unzip traceroute" |
|
|
|
apt_packages="smokeping echoping traceroute" |
|
|
|
read -rp "输入监控页面端口(默认20000):" port1 |
|
|
|
read -rp "输入监控页面端口(默认20000):" port1 |
|
|
|
ss -tnlp | grep -q ":${port1:-20000} " && echo "端口 ${port1:-20000} 已被占用" && exit 1 |
|
|
|
ss -tnlp | grep -q ":${port1:-20000} " && echo "端口 ${port1:-20000} 已被占用" && exit 1 |
|
|
|
if [[ $ID == "debian" || $ID == "ubuntu" ]]; then |
|
|
|
if [[ $ID == "debian" || $ID == "ubuntu" ]]; then |
|
|
|
$PM update |
|
|
|
|
|
|
|
$INS wget curl -y |
|
|
|
|
|
|
|
$INS $apt_packages -y || error=1 |
|
|
|
$INS $apt_packages -y || error=1 |
|
|
|
[[ $error -eq 1 ]] && echo "安装 smokeping 失败" && exit 1 |
|
|
|
[[ $error -eq 1 ]] && echo "安装 smokeping 失败" && exit 1 |
|
|
|
systemctl stop apache2 && systemctl stop smokeping |
|
|
|
systemctl stop apache2 && systemctl stop smokeping |
|
|
@ -97,8 +112,8 @@ install_SMP() { |
|
|
|
elif [[ $ID == "centos" ]]; then |
|
|
|
elif [[ $ID == "centos" ]]; then |
|
|
|
sed -i 's/SELINUX=enforcing/SELINUX=disabled/' /etc/selinux/config |
|
|
|
sed -i 's/SELINUX=enforcing/SELINUX=disabled/' /etc/selinux/config |
|
|
|
setenforce 0 |
|
|
|
setenforce 0 |
|
|
|
$INS wget curl -y |
|
|
|
$INS $rpm_packages -y || error=1 |
|
|
|
$INS $rpm_packages -y |
|
|
|
[[ $error -eq 1 ]] && echo "安装 smokeping 失败" && exit 1 |
|
|
|
systemctl stop httpd && systemctl stop smokeping |
|
|
|
systemctl stop httpd && systemctl stop smokeping |
|
|
|
configureCe |
|
|
|
configureCe |
|
|
|
fi |
|
|
|
fi |
|
|
@ -108,16 +123,14 @@ install_Agent() { |
|
|
|
rpm_packages="mtr java-1.8.0-openjdk*" |
|
|
|
rpm_packages="mtr java-1.8.0-openjdk*" |
|
|
|
apt_packages="mtr openjdk-8-jdk" |
|
|
|
apt_packages="mtr openjdk-8-jdk" |
|
|
|
if [[ $ID == "debian" || $ID == "ubuntu" ]]; then |
|
|
|
if [[ $ID == "debian" || $ID == "ubuntu" ]]; then |
|
|
|
$PM update |
|
|
|
|
|
|
|
$INS wget curl -y |
|
|
|
|
|
|
|
$INS $apt_packages -y || error=1 |
|
|
|
$INS $apt_packages -y || error=1 |
|
|
|
[[ $error -eq 1 ]] && echo "安装 Agent 客户端依赖包失败" && exit 1 |
|
|
|
[[ $error -eq 1 ]] && echo "安装 Agent 客户端依赖包失败" && exit 1 |
|
|
|
configureUbAgent |
|
|
|
configureUbAgent |
|
|
|
elif [[ $ID == "centos" ]]; then |
|
|
|
elif [[ $ID == "centos" ]]; then |
|
|
|
sed -i 's/SELINUX=enforcing/SELINUX=disabled/' /etc/selinux/config |
|
|
|
sed -i 's/SELINUX=enforcing/SELINUX=disabled/' /etc/selinux/config |
|
|
|
setenforce 0 |
|
|
|
setenforce 0 |
|
|
|
$INS wget curl -y |
|
|
|
$INS $rpm_packages -y || error=1 |
|
|
|
$INS $rpm_packages -y |
|
|
|
[[ $error -eq 1 ]] && echo "安装 Agent 客户端依赖包失败" && exit 1 |
|
|
|
configureCeAgent |
|
|
|
configureCeAgent |
|
|
|
fi |
|
|
|
fi |
|
|
|
} |
|
|
|
} |
|
|
@ -131,10 +144,9 @@ configureUb() { |
|
|
|
mkdir -p /var/run/smokeping |
|
|
|
mkdir -p /var/run/smokeping |
|
|
|
rm -fr /var/lib/smokeping/*/*.rrd |
|
|
|
rm -fr /var/lib/smokeping/*/*.rrd |
|
|
|
rm -fr /etc/smokeping/config.d |
|
|
|
rm -fr /etc/smokeping/config.d |
|
|
|
#get Gist config |
|
|
|
#get Gitee config |
|
|
|
wget https://gist.github.com/livejq/d60d8db950a42e9ceb7e4c01e9d32921/archive/9275570e264e12fbaf62a0fc40229818834a74d3.zip |
|
|
|
mv pingm-master/SMP/Ubuntu20 pingm-master/SMP/config.d |
|
|
|
unzip -o *.zip -d /etc/smokeping/ |
|
|
|
mv pingm-master/SMP/config.d /etc/smokeping |
|
|
|
mv /etc/smokeping/d60d8db950a42e9ceb7e4c01e9d32921-9275570e264e12fbaf62a0fc40229818834a74d3 /etc/smokeping/config.d |
|
|
|
|
|
|
|
mv /etc/smokeping/config.d/HW-HK /opt/ysnet |
|
|
|
mv /etc/smokeping/config.d/HW-HK /opt/ysnet |
|
|
|
sed -i 's/some.url/'$ip':'${port1:-20000}'/g;' /etc/smokeping/config.d/General |
|
|
|
sed -i 's/some.url/'$ip':'${port1:-20000}'/g;' /etc/smokeping/config.d/General |
|
|
|
sed -i 's/smokeping.cgi/smokeping/g;' /etc/smokeping/config.d/General |
|
|
|
sed -i 's/smokeping.cgi/smokeping/g;' /etc/smokeping/config.d/General |
|
|
@ -146,6 +158,10 @@ configureUb() { |
|
|
|
#wget -O /usr/bin/tcpping https://raw.githubusercontent.com/deajan/tcpping/master/tcpping |
|
|
|
#wget -O /usr/bin/tcpping https://raw.githubusercontent.com/deajan/tcpping/master/tcpping |
|
|
|
#chmod 755 /usr/bin/tcpping |
|
|
|
#chmod 755 /usr/bin/tcpping |
|
|
|
chmod 777 -R /var/lib/smokeping/ |
|
|
|
chmod 777 -R /var/lib/smokeping/ |
|
|
|
|
|
|
|
#ufw |
|
|
|
|
|
|
|
ufw allow 22/tcp && ufw allow ${port1:-20000}/tcp |
|
|
|
|
|
|
|
ufw enable && systemctl enable ufw |
|
|
|
|
|
|
|
ufw reload |
|
|
|
#timezone |
|
|
|
#timezone |
|
|
|
timedatectl set-timezone Asia/Shanghai |
|
|
|
timedatectl set-timezone Asia/Shanghai |
|
|
|
#test |
|
|
|
#test |
|
|
@ -163,16 +179,17 @@ configureUb() { |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
configureUbAgent() { |
|
|
|
configureUbAgent() { |
|
|
|
#Agent |
|
|
|
|
|
|
|
mkdir -p /var/monitor_agent |
|
|
|
mkdir -p /var/monitor_agent |
|
|
|
wget $origin |
|
|
|
#get Gitee config |
|
|
|
unzip master.zip |
|
|
|
|
|
|
|
mv pingm-master/Agent/agentMain.jar /var/monitor_agent |
|
|
|
mv pingm-master/Agent/agentMain.jar /var/monitor_agent |
|
|
|
mv pingm-master/Agent/conf /var/monitor_agent |
|
|
|
mv pingm-master/Agent/conf /var/monitor_agent |
|
|
|
mv pingm-master/Agent/AgentRestart.sh /root |
|
|
|
mv pingm-master/Agent/AgentRestart.sh /root |
|
|
|
rm -f master.zip |
|
|
|
|
|
|
|
rm -fr pingm-master |
|
|
|
|
|
|
|
chmod 755 -R /var/monitor_agent |
|
|
|
chmod 755 -R /var/monitor_agent |
|
|
|
|
|
|
|
#ufw |
|
|
|
|
|
|
|
ufw allow 22/tcp && ufw allow 9123/tcp |
|
|
|
|
|
|
|
ufw enable && systemctl enable ufw |
|
|
|
|
|
|
|
ufw reload |
|
|
|
|
|
|
|
#Running |
|
|
|
chmod 755 /root/AgentRestart.sh |
|
|
|
chmod 755 /root/AgentRestart.sh |
|
|
|
/root/AgentRestart.sh |
|
|
|
/root/AgentRestart.sh |
|
|
|
echo "" |
|
|
|
echo "" |
|
|
@ -192,10 +209,9 @@ configureCe() { |
|
|
|
rm -fr /var/lib/smokeping/*/*.rrd |
|
|
|
rm -fr /var/lib/smokeping/*/*.rrd |
|
|
|
rm -fr /etc/smokeping/config.d |
|
|
|
rm -fr /etc/smokeping/config.d |
|
|
|
rm -fr /etc/smokeping/config |
|
|
|
rm -fr /etc/smokeping/config |
|
|
|
#get Gist config |
|
|
|
#get Gitee config |
|
|
|
wget https://gist.github.com/livejq/5175c6801ac088cf5177f6a1b12af45c/archive/002038e18ae5617b7aea89ba188c4886cc72eb99.zip |
|
|
|
mv pingm-master/SMP/CentOS7 pingm-master/SMP/config.d |
|
|
|
unzip -o *.zip -d /etc/smokeping/ |
|
|
|
mv pingm-master/SMP/config.d /etc/smokeping |
|
|
|
mv /etc/smokeping/5175c6801ac088cf5177f6a1b12af45c-002038e18ae5617b7aea89ba188c4886cc72eb99 /etc/smokeping/config.d |
|
|
|
|
|
|
|
mv /etc/smokeping/config.d/HW-HK /opt/ysnet |
|
|
|
mv /etc/smokeping/config.d/HW-HK /opt/ysnet |
|
|
|
mv /etc/smokeping/config.d/config /etc/smokeping |
|
|
|
mv /etc/smokeping/config.d/config /etc/smokeping |
|
|
|
sed -i 's/localhost/'$ip':'${port1:-20000}'/g;' /etc/smokeping/config.d/General |
|
|
|
sed -i 's/localhost/'$ip':'${port1:-20000}'/g;' /etc/smokeping/config.d/General |
|
|
@ -208,7 +224,8 @@ configureCe() { |
|
|
|
#chmod 755 /usr/bin/tcpping |
|
|
|
#chmod 755 /usr/bin/tcpping |
|
|
|
chmod 777 -R /var/lib/smokeping/ |
|
|
|
chmod 777 -R /var/lib/smokeping/ |
|
|
|
#firewalld |
|
|
|
#firewalld |
|
|
|
systemctl stop firewalld && systemctl disable firewalld |
|
|
|
systemctl restart firewalld && systemctl enable firewalld |
|
|
|
|
|
|
|
firewall-cmd --zone=public --add-port=${port1:-20000}/tcp --permanent && firewall-cmd --reload |
|
|
|
#timezone |
|
|
|
#timezone |
|
|
|
timedatectl set-timezone Asia/Shanghai |
|
|
|
timedatectl set-timezone Asia/Shanghai |
|
|
|
#test |
|
|
|
#test |
|
|
@ -226,16 +243,16 @@ configureCe() { |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
configureCeAgent() { |
|
|
|
configureCeAgent() { |
|
|
|
#Agent |
|
|
|
|
|
|
|
mkdir -p /var/monitor_agent |
|
|
|
mkdir -p /var/monitor_agent |
|
|
|
wget $origin |
|
|
|
#get Gitee config |
|
|
|
unzip master.zip |
|
|
|
|
|
|
|
mv pingm-master/Agent/agentMain.jar /var/monitor_agent |
|
|
|
mv pingm-master/Agent/agentMain.jar /var/monitor_agent |
|
|
|
mv pingm-master/Agent/conf /var/monitor_agent |
|
|
|
mv pingm-master/Agent/conf /var/monitor_agent |
|
|
|
mv pingm-master/Agent/AgentRestart.sh /root |
|
|
|
mv pingm-master/Agent/AgentRestart.sh /root |
|
|
|
rm -f master.zip |
|
|
|
|
|
|
|
rm -fr pingm-master |
|
|
|
|
|
|
|
chmod 755 -R /var/monitor_agent |
|
|
|
chmod 755 -R /var/monitor_agent |
|
|
|
|
|
|
|
#firewall |
|
|
|
|
|
|
|
systemctl restart firewalld |
|
|
|
|
|
|
|
firewall-cmd --zone=public --add-port=9123/tcp --permanent && firewall-cmd --reload |
|
|
|
|
|
|
|
#Running |
|
|
|
chmod 755 /root/AgentRestart.sh |
|
|
|
chmod 755 /root/AgentRestart.sh |
|
|
|
/root/AgentRestart.sh |
|
|
|
/root/AgentRestart.sh |
|
|
|
echo "" |
|
|
|
echo "" |
|
|
|