|
|
|
@ -40,8 +40,8 @@ selectAction() { |
|
|
|
|
;; |
|
|
|
|
*) |
|
|
|
|
before |
|
|
|
|
install_SMP |
|
|
|
|
install_Agent |
|
|
|
|
install_SMP |
|
|
|
|
after |
|
|
|
|
;; |
|
|
|
|
esac |
|
|
|
@ -78,16 +78,18 @@ before() { |
|
|
|
|
updateCe |
|
|
|
|
$PM update |
|
|
|
|
$INS wget curl unzip -y |
|
|
|
|
wget $origin |
|
|
|
|
unzip master.zip |
|
|
|
|
rm -f master.zip && rm -fr pingm-master |
|
|
|
|
wget $origin && unzip master.zip || error=1 |
|
|
|
|
[[ $error -eq 1 ]] && echo -e "${RED}下载资源失败,请确保本地正常访问 gitee.com 后重新尝试${PLAIN}" && exit 1 |
|
|
|
|
elif [[ $ID == "debian" || $ID == "ubuntu" ]]; then |
|
|
|
|
PM="apt" |
|
|
|
|
INS="apt install" |
|
|
|
|
updateUb |
|
|
|
|
$PM update |
|
|
|
|
$INS wget curl unzip -y |
|
|
|
|
wget $origin |
|
|
|
|
unzip master.zip |
|
|
|
|
rm -f master.zip && rm -fr pingm-master |
|
|
|
|
wget $origin && unzip master.zip || error=1 |
|
|
|
|
[[ $error -eq 1 ]] && echo -e "${RED}下载资源失败,请确保本地正常访问 gitee.com 后重新尝试${PLAIN}" && exit 1 |
|
|
|
|
else |
|
|
|
|
exit 1 |
|
|
|
|
fi |
|
|
|
@ -103,17 +105,17 @@ install_SMP() { |
|
|
|
|
rpm_packages="smokeping wqy-zenhei-fonts.noarch" |
|
|
|
|
apt_packages="smokeping echoping traceroute" |
|
|
|
|
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 |
|
|
|
|
$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 |
|
|
|
|
configureUb |
|
|
|
|
elif [[ $ID == "centos" ]]; then |
|
|
|
|
sed -i 's/SELINUX=enforcing/SELINUX=disabled/' /etc/selinux/config |
|
|
|
|
setenforce 0 |
|
|
|
|
$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 |
|
|
|
|
configureCe |
|
|
|
|
fi |
|
|
|
@ -124,13 +126,13 @@ install_Agent() { |
|
|
|
|
apt_packages="mtr openjdk-8-jdk" |
|
|
|
|
if [[ $ID == "debian" || $ID == "ubuntu" ]]; then |
|
|
|
|
$INS $apt_packages -y || error=1 |
|
|
|
|
[[ $error -eq 1 ]] && echo "安装 Agent 客户端依赖包失败" && exit 1 |
|
|
|
|
[[ $error -eq 1 ]] && echo -e "${RED}安装 Agent 客户端依赖包失败${PLAIN}" && exit 1 |
|
|
|
|
configureUbAgent |
|
|
|
|
elif [[ $ID == "centos" ]]; then |
|
|
|
|
sed -i 's/SELINUX=enforcing/SELINUX=disabled/' /etc/selinux/config |
|
|
|
|
setenforce 0 |
|
|
|
|
$INS $rpm_packages -y || error=1 |
|
|
|
|
[[ $error -eq 1 ]] && echo "安装 Agent 客户端依赖包失败" && exit 1 |
|
|
|
|
[[ $error -eq 1 ]] && echo -e "${RED}安装 Agent 客户端依赖包失败${PLAIN}" && exit 1 |
|
|
|
|
configureCeAgent |
|
|
|
|
fi |
|
|
|
|
} |
|
|
|
@ -138,7 +140,7 @@ install_Agent() { |
|
|
|
|
configureUb() { |
|
|
|
|
#get local ip |
|
|
|
|
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 |
|
|
|
|
mkdir -p $target_dir |
|
|
|
|
mkdir -p /var/run/smokeping |
|
|
|
@ -166,9 +168,9 @@ configureUb() { |
|
|
|
|
timedatectl set-timezone Asia/Shanghai |
|
|
|
|
#test |
|
|
|
|
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 |
|
|
|
|
[[ $error -eq 1 ]] && echo "启动失败" && exit 1 |
|
|
|
|
[[ $error -eq 1 ]] && echo -e "${RED}启动失败${PLAIN}" && exit 1 |
|
|
|
|
echo "" |
|
|
|
|
echo "Smokeping安装完成,监控页面:http://$ip:${port1:-20000}/smokeping/sm.cgi" |
|
|
|
|
echo "" |
|
|
|
@ -203,7 +205,7 @@ configureUbAgent() { |
|
|
|
|
configureCe() { |
|
|
|
|
#get local ip |
|
|
|
|
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 |
|
|
|
|
mkdir -p $target_dir |
|
|
|
|
rm -fr /var/lib/smokeping/*/*.rrd |
|
|
|
@ -230,9 +232,9 @@ configureCe() { |
|
|
|
|
timedatectl set-timezone Asia/Shanghai |
|
|
|
|
#test |
|
|
|
|
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 |
|
|
|
|
[[ $error -eq 1 ]] && echo "启动失败" && exit 1 |
|
|
|
|
[[ $error -eq 1 ]] && echo -e "${RED}启动失败${PLAIN}" && exit 1 |
|
|
|
|
echo "" |
|
|
|
|
echo "Smokeping安装完成,监控页面:http://$ip:${port1:-20000}/smokeping/sm.cgi" |
|
|
|
|
echo "" |
|
|
|
|