|
|
@ -40,8 +40,8 @@ selectAction() { |
|
|
|
;; |
|
|
|
;; |
|
|
|
*) |
|
|
|
*) |
|
|
|
before |
|
|
|
before |
|
|
|
install_SMP |
|
|
|
|
|
|
|
install_Agent |
|
|
|
install_Agent |
|
|
|
|
|
|
|
install_SMP |
|
|
|
after |
|
|
|
after |
|
|
|
;; |
|
|
|
;; |
|
|
|
esac |
|
|
|
esac |
|
|
@ -78,16 +78,18 @@ before() { |
|
|
|
updateCe |
|
|
|
updateCe |
|
|
|
$PM update |
|
|
|
$PM update |
|
|
|
$INS wget curl unzip -y |
|
|
|
$INS wget curl unzip -y |
|
|
|
wget $origin |
|
|
|
rm -f master.zip && rm -fr pingm-master |
|
|
|
unzip master.zip |
|
|
|
wget $origin && unzip master.zip || error=1 |
|
|
|
|
|
|
|
[[ $error -eq 1 ]] && echo -e "${RED}下载资源失败,请确保本地正常访问 gitee.com 后重新尝试${PLAIN}" && exit 1 |
|
|
|
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 |
|
|
|
$PM update |
|
|
|
$INS wget curl unzip -y |
|
|
|
$INS wget curl unzip -y |
|
|
|
wget $origin |
|
|
|
rm -f master.zip && rm -fr pingm-master |
|
|
|
unzip master.zip |
|
|
|
wget $origin && unzip master.zip || error=1 |
|
|
|
|
|
|
|
[[ $error -eq 1 ]] && echo -e "${RED}下载资源失败,请确保本地正常访问 gitee.com 后重新尝试${PLAIN}" && exit 1 |
|
|
|
else |
|
|
|
else |
|
|
|
exit 1 |
|
|
|
exit 1 |
|
|
|
fi |
|
|
|
fi |
|
|
@ -103,17 +105,17 @@ install_SMP() { |
|
|
|
rpm_packages="smokeping wqy-zenhei-fonts.noarch" |
|
|
|
rpm_packages="smokeping wqy-zenhei-fonts.noarch" |
|
|
|
apt_packages="smokeping echoping 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 -e "${RED}端口 ${port1:-20000} 已被占用${PLAIN}" && exit 1 |
|
|
|
if [[ $ID == "debian" || $ID == "ubuntu" ]]; then |
|
|
|
if [[ $ID == "debian" || $ID == "ubuntu" ]]; then |
|
|
|
$INS $apt_packages -y || error=1 |
|
|
|
$INS $apt_packages -y || error=1 |
|
|
|
[[ $error -eq 1 ]] && echo "安装 smokeping 失败" && exit 1 |
|
|
|
[[ $error -eq 1 ]] && echo -e "${RED}安装 smokeping 失败${PLAIN}" && exit 1 |
|
|
|
systemctl stop apache2 && systemctl stop smokeping |
|
|
|
systemctl stop apache2 && systemctl stop smokeping |
|
|
|
configureUb |
|
|
|
configureUb |
|
|
|
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 $rpm_packages -y || error=1 |
|
|
|
$INS $rpm_packages -y || error=1 |
|
|
|
[[ $error -eq 1 ]] && echo "安装 smokeping 失败" && exit 1 |
|
|
|
[[ $error -eq 1 ]] && echo -e "${RED}安装 smokeping 失败${PLAIN}" && exit 1 |
|
|
|
systemctl stop httpd && systemctl stop smokeping |
|
|
|
systemctl stop httpd && systemctl stop smokeping |
|
|
|
configureCe |
|
|
|
configureCe |
|
|
|
fi |
|
|
|
fi |
|
|
@ -124,13 +126,13 @@ install_Agent() { |
|
|
|
apt_packages="mtr openjdk-8-jdk" |
|
|
|
apt_packages="mtr openjdk-8-jdk" |
|
|
|
if [[ $ID == "debian" || $ID == "ubuntu" ]]; then |
|
|
|
if [[ $ID == "debian" || $ID == "ubuntu" ]]; then |
|
|
|
$INS $apt_packages -y || error=1 |
|
|
|
$INS $apt_packages -y || error=1 |
|
|
|
[[ $error -eq 1 ]] && echo "安装 Agent 客户端依赖包失败" && exit 1 |
|
|
|
[[ $error -eq 1 ]] && echo -e "${RED}安装 Agent 客户端依赖包失败${PLAIN}" && 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 $rpm_packages -y || error=1 |
|
|
|
$INS $rpm_packages -y || error=1 |
|
|
|
[[ $error -eq 1 ]] && echo "安装 Agent 客户端依赖包失败" && exit 1 |
|
|
|
[[ $error -eq 1 ]] && echo -e "${RED}安装 Agent 客户端依赖包失败${PLAIN}" && exit 1 |
|
|
|
configureCeAgent |
|
|
|
configureCeAgent |
|
|
|
fi |
|
|
|
fi |
|
|
|
} |
|
|
|
} |
|
|
@ -138,7 +140,7 @@ install_Agent() { |
|
|
|
configureUb() { |
|
|
|
configureUb() { |
|
|
|
#get local ip |
|
|
|
#get local ip |
|
|
|
ip=$(curl -sL https://api64.ipify.org -4) || error=1 |
|
|
|
ip=$(curl -sL https://api64.ipify.org -4) || error=1 |
|
|
|
[[ $error -eq 1 ]] && echo "获取本机 IP 地址失败" && exit 1 |
|
|
|
[[ $error -eq 1 ]] && echo -e "${RED}获取本机 IP 地址失败${PLAIN}" && exit 1 |
|
|
|
#clean local config |
|
|
|
#clean local config |
|
|
|
mkdir -p $target_dir |
|
|
|
mkdir -p $target_dir |
|
|
|
mkdir -p /var/run/smokeping |
|
|
|
mkdir -p /var/run/smokeping |
|
|
@ -166,9 +168,9 @@ configureUb() { |
|
|
|
timedatectl set-timezone Asia/Shanghai |
|
|
|
timedatectl set-timezone Asia/Shanghai |
|
|
|
#test |
|
|
|
#test |
|
|
|
smokeping --debug || error=1 |
|
|
|
smokeping --debug || error=1 |
|
|
|
[[ $error -eq 1 ]] && echo "测试运行失败!" && exit 1 |
|
|
|
[[ $error -eq 1 ]] && echo -e "${RED}测试运行失败${PLAIN}" && exit 1 |
|
|
|
systemctl start apache2 smokeping || error=1 |
|
|
|
systemctl start apache2 smokeping || error=1 |
|
|
|
[[ $error -eq 1 ]] && echo "启动失败" && exit 1 |
|
|
|
[[ $error -eq 1 ]] && echo -e "${RED}启动失败${PLAIN}" && exit 1 |
|
|
|
echo "" |
|
|
|
echo "" |
|
|
|
echo "Smokeping安装完成,监控页面:http://$ip:${port1:-20000}/smokeping/sm.cgi" |
|
|
|
echo "Smokeping安装完成,监控页面:http://$ip:${port1:-20000}/smokeping/sm.cgi" |
|
|
|
echo "" |
|
|
|
echo "" |
|
|
@ -203,7 +205,7 @@ configureUbAgent() { |
|
|
|
configureCe() { |
|
|
|
configureCe() { |
|
|
|
#get local ip |
|
|
|
#get local ip |
|
|
|
ip=$(curl -sL https://api64.ipify.org -4) || error=1 |
|
|
|
ip=$(curl -sL https://api64.ipify.org -4) || error=1 |
|
|
|
[[ $error -eq 1 ]] && echo "获取本机 IP 地址失败" && exit 1 |
|
|
|
[[ $error -eq 1 ]] && echo -e "${RED}获取本机 IP 地址失败${PLAIN}" && exit 1 |
|
|
|
#clean local config |
|
|
|
#clean local config |
|
|
|
mkdir -p $target_dir |
|
|
|
mkdir -p $target_dir |
|
|
|
rm -fr /var/lib/smokeping/*/*.rrd |
|
|
|
rm -fr /var/lib/smokeping/*/*.rrd |
|
|
@ -230,9 +232,9 @@ configureCe() { |
|
|
|
timedatectl set-timezone Asia/Shanghai |
|
|
|
timedatectl set-timezone Asia/Shanghai |
|
|
|
#test |
|
|
|
#test |
|
|
|
smokeping --debug || error=1 |
|
|
|
smokeping --debug || error=1 |
|
|
|
[[ $error -eq 1 ]] && echo "测试运行失败!" && exit 1 |
|
|
|
[[ $error -eq 1 ]] && echo -e "${RED}测试运行失败${PLAIN}" && exit 1 |
|
|
|
systemctl start httpd smokeping || error=1 |
|
|
|
systemctl start httpd smokeping || error=1 |
|
|
|
[[ $error -eq 1 ]] && echo "启动失败" && exit 1 |
|
|
|
[[ $error -eq 1 ]] && echo -e "${RED}启动失败${PLAIN}" && exit 1 |
|
|
|
echo "" |
|
|
|
echo "" |
|
|
|
echo "Smokeping安装完成,监控页面:http://$ip:${port1:-20000}/smokeping/sm.cgi" |
|
|
|
echo "Smokeping安装完成,监控页面:http://$ip:${port1:-20000}/smokeping/sm.cgi" |
|
|
|
echo "" |
|
|
|
echo "" |
|
|
|