下载:http://oss.oetiker.ch/smokeping/pub/
部署参考:http://www.cnblogs.com/ahwwmb/archive/2013/03/12/2955678.html
部署参考http://www.mamicode.com/info-detail-1396960.html
第1章 基本概念
Smokeping 主要是监视网络性能,包括常规的 ping,用 echoping 监视 www 服务器性能,监视 dns 查询性能,监视 ssh 性能等。底层也是 rrdtool 做支持,特点是画的图非常漂亮,网络丢包和延迟用颜色和阴影来表示。
最新版本的 Smokeping 支持多个节点的检测结果从一个图上画出来。比如从 A、B 两个监视点检测 C 点的 ping 效果。可以把 A、B 的检测结果在一个图上表示出来,便于比较。
第2章 安装Smokeping
2.0 时间同步
yum -y install ntp
systemctl enable ntpd
systemctl start ntpd
ntpdate times.aliyun.com
2.1 安装依赖包
SmokePing不独立。它依赖于存在的各种其他工具和服务。
RRDtool 1.2.x或更高版本:Smokeping使用RRDtool进行日志和图形绘制。如果你的linux发行版提供了一个带有perl支持的rrdtool软件包,使用这个。如果你想获得最新和最伟大的版本,自己编译
FPing:注意fping必须安装 http://www.fping.org/dist/fping-3.13.tar.gz
EchoPing:需要它来运行EchoPing探针
curl:需要这个Curl探针
dig:需要此DNS探测器
SSH:需要此SSH探测器
Webserver:apache
rrdtool: 绘图的引擎:http://oss.oetiker.ch/rrdtool/pub/
Perl 5.8.8或更高版本
yum -y install groupinstall "Compatibility libraries" "Base" "Development tools"
yum -y install cpan perl perl-FCGI perl-CGI perl-Digest-HMAC perl-Net-Telnet perl-LDAP perl-Net-DNS perl-Crypt-SSLeay perl-Test-Simple perl-Sys-Syslog perl-libwww-perl perl-Socket6 perl-FCGI perl-Time-HiRes perl-ExtUtils-MakeMaker rrdtool rrdtool-perl curl fping httpd httpd-devel gcc make wget libxml2-devel libpng-devel pango pango-devel freetype freetype-devel fontconfig cairo cairo-devel libart_lgpl libart_lgpl-devel mod_fcgid screen perl-IO-*
2.2 安装echoping和FPing
mkdir -p /usr/local/echoping
tar -zxf echoping-6.0.2.tar.gz
./configure --prefix=/usr/local/echoping
报错:
configure: error: Missing popt library, get it from ftp://ftp.rpm.org/pub/rpm/dist/rpm-x.y.z
解决办法:
yum install -y popt-devel
继续报错:
configure: error: Get the GNU libidn library (http://www.josefsson.org/libidn/) in order to use Unicode - multi-script - domain names or use --without-libidn to disable it
解决办法:
./configure --prefix=/usr/local/echoping --with-ssl --without-libidn
报错:
configure: error: Get the OpenSSL library (http://www.openssl.org/)
解决办法:
yum install -y openssl openssl-devel
make && make install
2.3 安装smokeping
cd /opt
tar -zxf smokeping-2.6.11.tar.gz
./configure --prefix=/usr/local/smokeping
gmake install
报错故障解决方法:
如果./configure过程中提示找不到某些perl扩展,如下所示
checking checking for perl module‘Config::Grammar‘... Can‘t locate Config/Grammar.pm in @INC (@INC contains:/usr/local/smokeping/thirdparty/lib/perl5 /usr/local/lib64/perl5 /usr/local/share/perl5/usr/lib64/perl5/vendor_perl /usr/share/perl5/vendor_perl /usr/lib64/perl5/usr/share/perl5 .) at -e line 1.
BEGIN failed--compilation aborted at -e line 1.
请使用以下命令安装对应模块:
perl -MCPAN -e ‘install Config::Grammar‘
2.4 创建相关目录和日志文件
cd /usr/local/smokeping
mkdir cache data var
touch /var/log/smokeping.log
chown -R apache:apache cache/ data/ var/ /var/log/smokeping.log
因为这里的web服务使用的是httpd,所以相关文件的属主属组均为apache
2.5 创建相关配置文件
#fcgi文件
cp /usr/local/smokeping/htdocs/smokeping.fcgi.dist /usr/local/smokeping/htdocs/smokeping.fcgi
#主配置文件
cp /usr/local/smokeping/etc/config.dist /usr/local/smokeping/etc/config
2.6 修改配置文件
vim /usr/local/smokeping/bin/smokeping
#!/usr/bin/perl –w ##-w表示使用严格的语法控制,一不小心会出现许多警告,比如变量没有定义、没有初始化等。默认取消。
use lib qw(/usr/local/rrdtool/lib/perl);
use lib qw(/usr/local/smokeping/lib);
Smokeping::main("/usr/local/smokeping/etc/config");
vim /usr/local/smokeping/etc/conf
imgcache = /usr/local/smokeping/cache
imgurl = cache
datadir = /usr/local/smokeping/data
piddir = /usr/local/smokeping/var
#指定cgi的url地址为本机地址(sed -i ‘s#cgiurl = http://some.url/smokeping.cgi#cgiurl = http://10.0.56.12/smokeping.cgi#g’ /usr/local/smokeping/etc/config)
cgiurl = http://192.168.20.57/smokeping.cgi
binary = /usr/local/fping/sbin/fping
step = 60 #指定检测的时间为60秒
pings = 60 #指定ping的次数为60
将step和pings都设置为60表示每60秒ping60次
2.8 修改apache配置文件增加登录验证
htpasswd -c /usr/local/smokeping/htdocs/htpasswd smokeping
chmod 600 /usr/local/smokeping/etc/smokeping_secrets.dist #如何不设置权限,重启报错:File ‘smokeping_secrets.dist' is world-readable or writable, refusing it
2.9 修改httpd.conf增加smokeping的web界面
vim /etc/httpd/conf/httpd.conf
在文件末尾增加以下内容
Alias /cache "/usr/local/smokeping/cache/"
Alias /cropper "/usr/local/smokeping/htdocs/cropper/"
Alias /smokeping "/usr/local/smokeping/htdocs/smokeping.fcgi"
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
2.10 添加监控对象
配置文件常用的配置参数:
主/从 做分布式监控的时候有几点需要注意
1.主从服务器上面的密码文件权限必须为600 而且主服务器上面的密码文件的属主必须为apache的启动用户
2.从服务器上面的密码文件只需要一个密码就行,也就是主上面为它配置的那个密码。同样从服务器上面的密码文件的属主必须为smokeping的启动用户
#这里用于配置监控目标,以+号分层, +是第一层,++是第二层,+++ 是第三层
vim /usr/local/smokeping/etc/config
*** Targets ***
probe = FPing
menu = Top
title = Network Latency Grapher
remark = Welcome to the SmokePing website of xxx Company. \
Here you will learn all about the latency of our network.
###########################################################################################
+ jrl-server
menu = 公司内网
title = 内网服务器监控
++ Sangfor
menu = 深信服上网行为管理设备
title = 深信服设备充当路由器并管理公司网络行为-172.16.1.1
host = 172.16.1.1
++ CiscoSwitch
menu = 思科核心交换机
title = 8层机房思科核心交换机-192.168.1.1
host = 192.168.1.1
++ Vcenter
menu = vcenter
title = vcenter
host = 192.168.20.10
++ esxi11
menu = esxi-20.11
title = esxi-20.11
host = 192.168.20.11
++ esxi12
menu = esxi-20.12
title = esxi-20.12
host = 192.168.20.12
++ esxi13
menu = esxi-20.13
title = esxi-20.13
host = 192.168.20.13
++ esxi14
menu = esxi-20.14
title = esxi-20.14
host = 192.168.20.14
++ esxi15
menu = esxi-20.15
title = esxi-20.15
host = 192.168.20.15
2.11 添加监控节点
注意:每次修改配置文件后需要重启smokeping进程
[root@smokeping etc]# /usr/local/smokeping/bin/smokeping --restart
Note: logging to syslog as local0/info. ##正常启动输出内容
Daemonizing /usr/local/smokeping/bin/smokeping ... ##正常启动输出内容
2.12 启动服务并测试
echo "/usr/local/smokeping/bin/smokeping --logfile=/var/log/smokeping.log 2>&1 &" >>/etc/rc.local
systemctl start httpd
/usr/local/smokeping/bin/smokeping
在浏览器中访问:http://IP/smokeping
用户名和密码为htpasswd命令中设定用户名和密码
出现以下界面表示成功。