环境准备
安装epel yum源
#
rpm -ivh http://mirrors.ustc.edu.cn/fedora/epel/6/x86_64/epel-release-6-8.noarch.rpm
#
修改/etc/yum.repos.d/epel.repo
#
安装rrdtool与依赖库
yum -y install perl perl-Net-Telnet perl-Net-DNS perl-LDAP perl-lib www-perl perl-RadiusPerl perl-IO-Socket-SSL perl-Socket6 perl-CGI-SpeedyCGI perl-FCGI perl-CGI-SpeedCGI perl-Time-HiRes perl-ExtUtils-MakeMaker perl-RRD-Simple rrdtool rrdtool-perl curl fping echoping httpd httpd-devel gcc make wget libxml2-devel libpng-devel glib pango pango-devel freetype freetype-devel fontconfig cairo cairo-devel libart_lgpl libart_lgpl-devel mod_fastcgi screen
安装Smokeping
#
wget http://oss.oetiker.ch/smokeping/pub/smokeping-2.6.11.tar.gz
#
tar -zxvf smokeping-2.6.11.tar.gz
#
cdsmokeping-2.6.11
#
./setup/build-perl-modules.sh /usr/local/smokeping/thirdparty
#
./configure--prefix=/usr/local/smokeping
#
/usr/bin/gmake install
#
配置Smokeping
创建cache、data、var目录
mkdir -p /usr/local/smokeping/cache /usr/local/smokeping/data /usr/local/smokeping/var
创建日志文件
touch /var/log/smokeping.log
授权
chown apache:apache /usr/local/smokeping/cache /usr/local/smokeping/data /usr/local/smokeping/var
chown apache:apache /var/log/smokeping.log
修改Smokeping配置文件
cd /usr/local/smokeping/htdocs/
mv smokeping.fcgi.dist smokeping.fcgi
cd /usr/local/smokeping/etc
mv config.dist config
vim config
cgiurl=http://127.0.0.1/smokeping.cgi
修改apache配置文件
vim /etc/httpd/conf/httpd.conf
# 在DocumentRoot "/var/www/html"添加如下配置
Alias /cache "/usr/local/smokeping/cache/"
Alias /cropper "/usr/local/smokeping/htdocs/cropper/"
Alias /smokeping "/usr/local/smokeping/htdocs/smokeping.fcgi"
<Directory "/usr/local/smokeping">
AllowOverride None
Options All
AddHandler cgi-script .fcgi .cgi
Order allow,deny
Allow from all
AuthName "Smokeping"
AuthType Basic
AuthUserFile /usr/local/smokeping/htdocs/htpasswd
Require valid-user
DirectoryIndex smokeping.fcgi
</Directory>
开机启动与安全策略
echo "/usr/local/smokeping/bin/smokeping--logfile=/var/log/smokeping.log 2>&1 &" >> /etc/rc.local
chkconfig httpd on
iptables -t filter -I INPUT -p tcp --dport 80 -j ACCEPT
setenforce 0
#
service httpd restart
/usr/local/smokeping/bin/smokeping --logfile=/var/log/smokeping.log
设置密码
htpasswd -c /usr/local/smokeping/htdocs/htpasswd root
启动Smokeping
/usr/local/smokeping/bin/smokeping --logfile=/var/log/smokeping.log
# 或者在/etc/init.d/目录创建smokeping启动脚本
#
#!/bin/bash
#
# chkconfig: 2345 80 05
# Description: Smokeping init.d script
# Get function from functions library
. /etc/init.d/functions
# Start the service Smokeping
function start() {
echo -n "Starting Smokeping: "
/usr/local/smokeping/bin/smokeping --logfile=/var/log/smokeping.log >/dev/null 2>&1
### Create the lock file ###
touch /var/lock/subsys/smokeping
success $"Smokeping startup"
echo
}
# Restart the service Smokeping
function stop() {
echo -n "Stopping Smokeping: "
kill -9 `ps ax |grep "/usr/local/smokeping/bin/smokeping" |grep -v grep | awk '{ print $1 }'` >/dev/null 2>&1
### Now, delete the lock file ###
rm -f /var/lock/subsys/smokeping
success $"Smokeping shutdown"
echo
}
#Show status about Smokeping
function status() {
NUM="`ps -ef|grep smokeping|grep -v grep|wc -l`"
if [ "$NUM" == "0" ];then
echo "Smokeping is not run"
else
echo "Smokeping is running"
fi
}
### main logic ###
case "$1" in
start)
start
;;
stop)
stop
;;
status)
status
;;
restart|reload)
stop
start
;;
*)
echo $"Usage: $0 {start|stop|restart|reload|status}"
exit 1
esac
exit 0
#
chmod 755 /etc/init.d/smokeping
chkconfig --add smokeping
chkconfig smokeping on
chkconfig httpd on
/etc/init.d/httpd restart
/etc/init.d/smokeping restart
#
增加监控点
/usr/local/smokeping/etc/config
#
+ Google-Cloud
menu = GCP-SSR
title = GCP-SSR-Monitor
++ HongKong
menu = HK-SSR
title = HK-SSR
alerts = someloss
host = *.*.*.*
step = 60
pings = 60
#如果遇到rd parameter mismatch报错,清理以下目录缓存即可
rm -rf /opt/smokeping/cache/*
rm -rf /opt/smokeping/data/*
#
展示效果
说明及扩展
待补充