[TOC]html
安裝 epel yum 源和相關基礎依賴包。linux
yum -y install epel-release wget make gcc openssl openssl-devel rrdtool rrdtool-perl perl-core perl mod_fcgid perl-CPAN httpd httpd-devel curl bind-utils gcc make vim gcc-c++ perl-LWP-Protocol-https wqy-microhei-fonts
smokeping 2.7.2以上須要fping4.0以上c++
cd /data/packages wget https://fping.org/dist/fping-4.2.tar.gz tar -zxvf fping-4.2.tar.gz cd fping-4.2 ./configure make make install
若是使用tcp ping,須要它。apache
cd /data/packages wget https://fossies.org/linux/misc/old/echoping-6.0.2.tar.gz tar -zxvf echoping-6.0.2.tar.gz cd echoping-6.0.2 yum install -y popt-devel openssl openssl-devel ./configure --with-ssl --without-libidn make make install
源碼安裝 smokeping 2.7.3。vim
cd /data/packages wget https://oss.oetiker.ch/smokeping/pub/smokeping-2.7.3.tar.gz tar -zxvf smokeping-2.7.3.tar.gz cd smokeping-2.7.3 ./configure --prefix=/usr/local/smokeping /usr/bin/gmake install
cd /usr/local/smokeping mkdir var htdocs/{data,cache} chown apache.apache -R /usr/local/smokeping touch /var/log/smokeping.log chown apache.apache /var/log/smokeping.log cd /usr/local/smokeping/htdocs/ cp smokeping.fcgi.dist smokeping.fcgi chmod 600 /usr/local/smokeping/etc/smokeping_secrets.dist cat > /usr/local/smokeping/etc/config<<EOF *** General *** owner = admin contact = some@address.nowhere mailhost = my.mail.host sendmail = /usr/sbin/sendmail imgcache = /usr/local/smokeping/htdocs/cache imgurl = cache datadir = /usr/local/smokeping/htdocs/data piddir = /usr/local/smokeping/var cgiurl = http://10.10.23.103/smokeping/smokeping.fcgi smokemail = /usr/local/smokeping/etc/smokemail.dist tmail = /usr/local/smokeping/etc/tmail.dist # specify this to get syslog logging syslogfacility = local0 *** Alerts *** to = alertee@address.somewhere from = smokealert@company.xy +hostdown type = loss # in percent pattern = ==0%,==0%,==0%,==U comment = 對端無響應 +hightloss type = loss # in percent pattern = ==0%,==0%,==0%,==0%,>10%,>10%,>10% comment = 連續3次採樣-丟包率超過10% +lossdetect type = loss # in percent pattern = ==0%,==0%,==0%,==0%,>0%,>0%,>0% comment = 連續3次採樣-存在丟包 +someloss type = loss # in percent pattern = >0%,*12*,>0%,*12*,>0% comment = 間斷性丟包 +rttdetect type = rtt # in milli seconds pattern = <100,<100,<100,<100,<100,<150,>150,>150,>150 comment = 連續3次採樣延遲增大-超過150ms *** Database *** step = 60 pings = 20 # consfn mrhb steps total AVERAGE 0.5 1 1008 AVERAGE 0.5 12 4320 MIN 0.5 12 4320 MAX 0.5 12 4320 AVERAGE 0.5 144 720 MAX 0.5 144 720 MIN 0.5 144 720 *** Presentation *** charset = utf-8 template = /usr/local/smokeping/etc/basepage.html.dist htmltitle = yes graphborders = no + charts menu = Charts title = The most interesting destinations ++ stddev sorter = StdDev(entries=>4) title = Top Standard Deviation menu = Std Deviation format = Standard Deviation %f ++ max sorter = Max(entries=>5) title = Top Max Roundtrip Time menu = by Max format = Max Roundtrip Time %f seconds ++ loss sorter = Loss(entries=>5) title = Top Packet Loss menu = Loss format = Packets Lost %f ++ median sorter = Median(entries=>5) title = Top Median Roundtrip Time menu = by Median format = Median RTT %f seconds + overview width = 600 height = 50 range = 10h + detail width = 600 height = 200 unison_tolerance = 2 "Last 3 Hours" 3h "Last 30 Hours" 30h "Last 10 Days" 10d "Last 400 Days" 400d *** Probes *** + FPing binary = /usr/local/sbin/fping #能夠設置源IP地址,適用於多IP的服務器,(好比組專線內網+公網)服務器 #sourceaddressn = 1.1.1.1 #*** Slaves *** #secrets=/usr/local/smokeping/etc/smokeping_secrets.dist #+aliyunShenzhen #display_name=slave1 #location=China #color=ff0000 # #+aliyunHangzhou #display_name=slave2 #location=China #color=ff00ff *** Targets *** probe = FPing menu = Top title = 網絡質量監控系統 remark = 若是您是合法管理員,那麼歡迎您,若是不是,請當即離開 Only legal administrators are welcome, if you are not, please leave immediately #加載額外的監控主機(將監控主機,單獨成一個文件) @include targets EOF
添加監控主機列表文件:安全
cat > /usr/local/smokeping/etc/targets<<EOF + dns menu = 全球公共DNS網絡監控 title = 全球公共DNS網絡監控 #slaves = slave1 slave2 #alerts = hostdown,hightloss ++ public-dns menu = 公共DNS title = 公共DNS網絡監控列表 host = /dns/public-dns/dns-1 /dns/public-dns/dns-2 /dns/public-dns/dns-3 /dns/public-dns/dns-4 /dns/public-dns/dns-5 /dns/public-dns/dns-6 /dns/public-dns/dns-7 /dns/public-dns/dns-8 /dns/public-dns/dns-9 /dns/public-dns/dns-10 /dns/public-dns/dns-11 /dns/public-dns/dns-12 /dns/public-dns/dns-13 /dns/public-dns/dns-14 /dns/public-dns/dns-15 /dns/public-dns/dns-16 /dns/public-dns/dns-17 /dns/public-dns/dns-18 /dns/public-dns/dns-19 /dns/public-dns/dns-20 /dns/public-dns/dns-21 /dns/public-dns/dns-22 /dns/public-dns/dns-23 /dns/public-dns/dns-24 +++ dns-1 menu = 江西移動-211.141.90.68 title = 江西移動-211.141.90.68 host = 211.141.90.68 +++ dns-2 menu = 江西電信-202.101.224.68 title = 江西電信-202.101.224.68 host = 202.101.224.68 +++ dns-3 menu = 江西聯通-220.248.192.12 title = 江西聯通-220.248.192.12 host = 220.248.192.12 +++ dns-4 menu = 114-DNS-114.114.114.114 title = 114-DNS-114.114.114.114 host = 114.114.114.114 +++ dns-5 menu = 114安全版-114.114.114.119 title = 114安全版-114.114.114.119 host = 114.114.114.119 +++ dns-6 menu = 阿里-223.5.5.5 title = 阿里-223.5.5.5 host = 223.5.5.5 +++ dns-7 menu = 百度-180.76.76.76 title = 百度-180.76.76.76 host = 180.76.76.76 +++ dns-8 menu = DNSPOD-119.29.29.29 title = DNSPOD-119.29.29.29 host = 119.29.29.29 +++ dns-9 menu = CNNIC-1.2.4.8 title = CNNIC-1.2.4.8 host = 1.2.4.8 +++ dns-10 menu = DNS派-218.30.118.6 title = DNS派-218.30.118.6 host = 218.30.118.6 +++ dns-11 menu = 谷歌-8.8.8.8 title = 谷歌-8.8.8.8 host = 8.8.8.8 +++ dns-12 menu = IBMQ9-9.9.9.9 title = IBMQ9-9.9.9.9 host = 9.9.9.9 +++ dns-13 menu = CF-1.1.1.1 title = CF-1.1.1.1 host = 1.1.1.1 +++ dns-14 menu = 科莫多-8.26.56.26 title = 科莫多-8.26.56.26 host = 8.26.56.26 +++ dns-15 menu = GTEI-4.2.2.1 title = GTEI-4.2.2.1 host = 4.2.2.1 +++ dns-16 menu = PCCW-205.252.144.228 title = PCCW-205.252.144.228 host = 205.252.144.228 +++ dns-17 menu = HKIX-202.181.224.2 title = HKIX-202.181.224.2 host = 202.181.224.2 +++ dns-18 menu = 澳門-202.175.3.8 title = 澳門-202.175.3.8 host = 202.175.3.8 +++ dns-19 menu = 中華電信-168.95.192.1 title = 中華電信-168.95.192.1 host = 168.95.192.1 +++ dns-20 menu = 英國-193.0.14.129 title = 英國-193.0.14.129 host = 193.0.14.129 +++ dns-21 menu = 日本-202.12.27.33 title = 日本-202.12.27.33 host = 202.12.27.33 +++ dns-22 menu = 韓國-164.124.101.31 title = 韓國-164.124.101.31 host = 164.124.101.31 +++ dns-23 menu = 洛杉磯hostspace-162.212.181.53 title = 洛杉磯hostspace-162.212.181.53 host = 162.212.181.53 +++ dns-24 menu = 洛杉磯hostspace-1-192.126.112.53 title = 洛杉磯hostspace-2-192.126.112.53 host = 192.126.112.53 EOF
添加 smokeping 爲服務:bash
cat > /usr/lib/systemd/system/smokeping.service<<EOF [Unit] Description=Latency Logging and Graphing System After=syslog.target network.target [Service] #ExecStart=/usr/sbin/smokeping --nodaemon # 2.6 yum install ExecStart=/usr/local/smokeping/bin/smokeping --nodaemon --config=/usr/local/smokeping/etc/config --logfile=/var/log/smokeping.log # 2.7 src install ExecReload=/bin/kill -HUP $MAINPID StandardError=syslog [Install] WantedBy=multi-user.target EOF
/etc/httpd/conf/httpd.conf
的行 DocumentRoot "/var/www/html"
後添加內容,以下:服務器
DocumentRoot "/var/www/html" Alias /smokeping "/usr/local/smokeping/htdocs/" <Directory "/usr/local/smokeping"> AllowOverride None Options All AddHandler cgi-script .fcgi .cgi AllowOverride AuthConfig Order allow,deny Allow from all AuthName "Smokeping" AuthType Basic AuthUserFile /usr/local/smokeping/htdocs/htpasswd Require valid-user DirectoryIndex smokeping.fcgi </Directory>
htpasswd -c /opt/smokeping/htdocs/htpasswd admin
生成 basic 驗證密碼。網絡
中文支持,/usr/local/smokeping/etc/basepage.html.dist
的 head 內添加curl
<META charset="utf-8" />
啓動 smokeping 和 apache,而後訪問 http://10.10.23.103/smokeping/
systemctl daemon-reaload systemctl start smokeping systemctl start apache