diff --git a/AutoPing.sh b/AutoPing.sh index 6cb253a..4cec694 100644 --- a/AutoPing.sh +++ b/AutoPing.sh @@ -23,23 +23,26 @@ selectAction() { 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} 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 "" read -rp "请输入数字选择:" num case $num in 1) - get_info + before install_SMP + after ;; 2) - get_info + before install_Agent + after ;; *) - get_info + before install_SMP install_Agent + after ;; esac } @@ -67,29 +70,41 @@ yum -y install epel-release yum clean all && yum repolist } -get_info() { +before() { source /etc/os-release || source /usr/lib/os-release || exit 1 if [[ $ID == "centos" ]]; then PM="yum" INS="yum install" updateCe + $PM update + $INS wget curl unzip -y + wget $origin + unzip master.zip elif [[ $ID == "debian" || $ID == "ubuntu" ]]; then PM="apt" INS="apt install" updateUb + $PM update + $INS wget curl unzip -y + wget $origin + unzip master.zip else exit 1 fi } +after() { + rm -f master.zip + rm -fr pingm-master + >/root/.bash_history +} + install_SMP() { - rpm_packages="smokeping unzip wqy-zenhei-fonts.noarch" - apt_packages="smokeping echoping unzip traceroute" + 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 if [[ $ID == "debian" || $ID == "ubuntu" ]]; then - $PM update - $INS wget curl -y $INS $apt_packages -y || error=1 [[ $error -eq 1 ]] && echo "安装 smokeping 失败" && exit 1 systemctl stop apache2 && systemctl stop smokeping @@ -97,8 +112,8 @@ install_SMP() { elif [[ $ID == "centos" ]]; then sed -i 's/SELINUX=enforcing/SELINUX=disabled/' /etc/selinux/config setenforce 0 - $INS wget curl -y - $INS $rpm_packages -y + $INS $rpm_packages -y || error=1 + [[ $error -eq 1 ]] && echo "安装 smokeping 失败" && exit 1 systemctl stop httpd && systemctl stop smokeping configureCe fi @@ -108,16 +123,14 @@ install_Agent() { rpm_packages="mtr java-1.8.0-openjdk*" apt_packages="mtr openjdk-8-jdk" if [[ $ID == "debian" || $ID == "ubuntu" ]]; then - $PM update - $INS wget curl -y $INS $apt_packages -y || error=1 [[ $error -eq 1 ]] && echo "安装 Agent 客户端依赖包失败" && exit 1 configureUbAgent elif [[ $ID == "centos" ]]; then sed -i 's/SELINUX=enforcing/SELINUX=disabled/' /etc/selinux/config setenforce 0 - $INS wget curl -y - $INS $rpm_packages -y + $INS $rpm_packages -y || error=1 + [[ $error -eq 1 ]] && echo "安装 Agent 客户端依赖包失败" && exit 1 configureCeAgent fi } @@ -131,10 +144,9 @@ configureUb() { mkdir -p /var/run/smokeping rm -fr /var/lib/smokeping/*/*.rrd rm -fr /etc/smokeping/config.d - #get Gist config - wget https://gist.github.com/livejq/d60d8db950a42e9ceb7e4c01e9d32921/archive/9275570e264e12fbaf62a0fc40229818834a74d3.zip - unzip -o *.zip -d /etc/smokeping/ - mv /etc/smokeping/d60d8db950a42e9ceb7e4c01e9d32921-9275570e264e12fbaf62a0fc40229818834a74d3 /etc/smokeping/config.d + #get Gitee config + mv pingm-master/SMP/Ubuntu20 pingm-master/SMP/config.d + mv pingm-master/SMP/config.d /etc/smokeping 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/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 #chmod 755 /usr/bin/tcpping chmod 777 -R /var/lib/smokeping/ + #ufw + ufw allow 22/tcp && ufw allow ${port1:-20000}/tcp + ufw enable && systemctl enable ufw + ufw reload #timezone timedatectl set-timezone Asia/Shanghai #test @@ -163,16 +179,17 @@ configureUb() { } configureUbAgent() { - #Agent mkdir -p /var/monitor_agent - wget $origin - unzip master.zip + #get Gitee config mv pingm-master/Agent/agentMain.jar /var/monitor_agent mv pingm-master/Agent/conf /var/monitor_agent mv pingm-master/Agent/AgentRestart.sh /root - rm -f master.zip - rm -fr pingm-master 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 /root/AgentRestart.sh echo "" @@ -192,10 +209,9 @@ configureCe() { rm -fr /var/lib/smokeping/*/*.rrd rm -fr /etc/smokeping/config.d rm -fr /etc/smokeping/config - #get Gist config - wget https://gist.github.com/livejq/5175c6801ac088cf5177f6a1b12af45c/archive/002038e18ae5617b7aea89ba188c4886cc72eb99.zip - unzip -o *.zip -d /etc/smokeping/ - mv /etc/smokeping/5175c6801ac088cf5177f6a1b12af45c-002038e18ae5617b7aea89ba188c4886cc72eb99 /etc/smokeping/config.d + #get Gitee config + mv pingm-master/SMP/CentOS7 pingm-master/SMP/config.d + mv pingm-master/SMP/config.d /etc/smokeping mv /etc/smokeping/config.d/HW-HK /opt/ysnet mv /etc/smokeping/config.d/config /etc/smokeping sed -i 's/localhost/'$ip':'${port1:-20000}'/g;' /etc/smokeping/config.d/General @@ -208,7 +224,8 @@ configureCe() { #chmod 755 /usr/bin/tcpping chmod 777 -R /var/lib/smokeping/ #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 timedatectl set-timezone Asia/Shanghai #test @@ -226,16 +243,16 @@ configureCe() { } configureCeAgent() { - #Agent mkdir -p /var/monitor_agent - wget $origin - unzip master.zip + #get Gitee config mv pingm-master/Agent/agentMain.jar /var/monitor_agent mv pingm-master/Agent/conf /var/monitor_agent mv pingm-master/Agent/AgentRestart.sh /root - rm -f master.zip - rm -fr pingm-master 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 /root/AgentRestart.sh echo "" diff --git a/SMP/CentOS7/Probes b/SMP/CentOS7/Probes index f42e74a..86efdc4 100644 --- a/SMP/CentOS7/Probes +++ b/SMP/CentOS7/Probes @@ -23,3 +23,10 @@ binary=/usr/bin/curl forks=5 offset=50% urlformat=http://download.xunyou.com/xunyou2012/verinfo.txt + +#+ TCPPing +#binary = /usr/bin/tcpping +#forks = 5 +#offset = 50% +#timeout = 15 +#port = 80 \ No newline at end of file diff --git a/SMP/Ubuntu20/Probes b/SMP/Ubuntu20/Probes index 2a34d09..c8488ab 100644 --- a/SMP/Ubuntu20/Probes +++ b/SMP/Ubuntu20/Probes @@ -13,10 +13,10 @@ offset = random ++ FPingtun1 offset = random -+ EchoPing -binary = /usr/bin/echoping -offset = random -udp = yes +#+ EchoPing +#binary = /usr/bin/echoping +#offset = random +#udp = yes + Curl binary = /usr/bin/curl @@ -24,9 +24,9 @@ forks = 5 offset = 50% urlformat = http://download.xunyou.com/xunyou2012/verinfo.txt -+ TCPPing -binary = /usr/bin/tcpping -forks = 5 -offset = 50% -timeout = 15 -port = 80 +#+ TCPPing +#binary = /usr/bin/tcpping +#forks = 5 +#offset = 50% +#timeout = 15 +#port = 80