参考文档:
- 官网:http://oss.oetiker.ch/smokeping/
- 参考:http://jaminzhang.github.io/monitoring/smokeping-deploy-practice/#top15
本文简单介绍smokeping的安装配置操作。
一.环境
1. OS
Server:10.11.4.250/CentOS-7-x86_64-1511
2. Smokeping版本
smokeping-2.6.11:http://oss.oetiker.ch/smokeping/pub/smokeping-2.6.11.tar.gz
二.安装Smokeping
1. 安装EPEL
#epel版本有可能变更,变更后不一定能下载 [root@smokeping ~]# rpm -Uvh http://download.fedoraproject.org/pub/epel/7/x86_64/e/epel-release-7-10.noarch.rpm [root@smokeping ~]# yum install foo -y
2. 安装依赖&环境
#其中本人遇到的问题有,未预安装"wqy*"导致中文显示的问题;没有预安装"perl-Sys-Syslog",在"gmake install"阶段有报错 [root@smokeping ~]# yum install -y rrdtool wqy* fping echoping curl bind-utils httpd httpd-devel perl perl-FCGI perl-CGI perl-CGI-SpeedyCGI perl-CGI-SpeedyCGI perl-libwww-perl perl-Socket6 perl-Net-Telnet perl-Net-OpenSSH perl-Net-DNS perl-LDAP perl-IO-Socket-SSL perl-ExtUtils-MakeMaker rrdtool-perl perl-Sys-Syslog perl-RadiusPerl perl-Time-HiRes perl-RRD-Simple libxml2-devel libpng-devel glib pango pango-devel freetype freetype-devel fontconfig cairo cairo-devel libart_lgpl libart_lgpl-devel mod_fastcgi
3. 编译安装
#请注意在configure前需要先build相应的perl模块,否则有报错。 [root@smokeping ~]# cd /usr/local/src/ [root@smokeping src]# wget http://oss.oetiker.ch/smokeping/pub/smokeping-2.6.11.tar.gz [root@smokeping src]# tar -zxvf smokeping-2.6.11.tar.gz [root@smokeping src]# cd smokeping-2.6.11 [root@smokeping smokeping-2.6.11]# ./setup/build-perl-modules.sh /usr/local/smokeping/thirdparty [root@smokeping smokeping-2.6.11]# ./configure --prefix=/usr/local/smokeping [root@smokeping smokeping-2.6.11]# gmake install
三.配置Smokeping
1. config文件配置
#创建程序运行相关目录并赋权 [root@smokeping smokeping-2.6.11]# cd /usr/local/smokeping/ [root@smokeping smokeping]# mkdir var cache data [root@smokeping smokeping]# chown apache:apache var/ cache/ data/ #生成cgi文件与config文件 [root@smokeping smokeping]# cp /usr/local/smokeping/htdocs/smokeping.fcgi.dist /usr/local/smokeping/htdocs/smokeping.fcgi [root@smokeping smokeping]# cp /usr/local/smokeping/etc/config.dist /usr/local/smokeping/etc/config
1)General配置
#修改 cgiurl,General及Alerts等是config文件多个section之一 [root@smokeping smokeping]# sed -i 's|some.url|10.11.4.250|g' /usr/local/smokeping/etc/config
2)Alerts配置
#someloss部分注释默认配置,重设监测机制 [root@smokeping smokeping]# vim /usr/local/smokeping/etc/config +someloss type = loss # in percent #pattern = >0%,*12*,>0%,*12*,>0% #comment = loss 3 times in a row pattern = ==0%,>2%,>2%,>2% comment = 每次发出60个包,连续3次轮询检查丢包率在2%以上 #新增rtt监测机制 +rttdetect type = rtt # in milliseconds pattern = <55,<55,<55,>55,>55,>55 comment = 每次发出60个包,连续3次轮询检查延时超过55毫秒
3)Database配置
# 默认300秒 ping 20次,修改为120秒 ping 30次 [root@smokeping smokeping]# sed -i 's|step = 300|step = 120|g' /usr/local/smokeping/etc/config [root@smokeping smokeping]# sed -i 's|pings = 20|pings = 30|g' /usr/local/smokeping/etc/config
4)Presentation配置
#在presentation下添加utf-8中文字符集 *** Presentation *** charset = utf-8 #在presentation下detail部分,注释默认历史数据展示时间,重设数值 + detail width = 600 height = 200 unison_tolerance = 2 #"Last 3 Hours" 3h #"Last 30 Hours" 30h #"Last 10 Days" 10d #"Last 400 Days" 400d "Last 10 Minutes" 10m "Last 30 Minutes" 30m "Last 4 Hours" 4h "Last 12 Hours" 12h "Last 1 Days" 24h "Last 3 Days" 3d "Last 1 Weeks" 7d "Last 1 Mouths" 30d "Last Half years" 180d "Last 1 years" 365d
2. 修改账号文件权限
#修改密码文件权限为root只读 [root@smokeping smokeping]# chmod 600 /usr/local/smokeping/etc/smokeping_secrets.dist
3. Apache配置
#设置登录账户及密码 [root@smokeping smokeping]# htpasswd -c /usr/local/smokeping/htdocs/htpasswd mcloudadmin New password: Re-type new password: #httpd文件配置,在“DocumentRoot "/var/www/html"”段下新增smokeping相关配置,请注意路径等强相关设置的前后一致性 [root@smokeping smokeping]# 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"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
4. 设置iptables
[root@smokeping smokeping]# vim /etc/sysconfig/iptables -A INPUT -p tcp -m state --state NEW -m tcp --dport 80 -j ACCEPT [root@smokeping smokeping]# service iptables restart
5. 设置开机启动
[root@smokeping smokeping]# echo "/usr/local/smokeping/bin/smokeping &">> /etc/rc.local
四.添加Smokeping监控点
1. 注意事项
添加smokeping监控点本质上还是修改config文件,主要修改"Targets"章节。
注意事项:
-
监控点不能在web前端添加,只能通过后台config文件添加;
-
配置文件:/usr/local/smokeping/etc/config;
-
修改config文件后,服务必须重启;
-
监控节点可以分目录层级,+为第一级目录,++为第二级目录,+++为第三级目录,依次类推,可以发现config文件的其他章节也是采用这样的层级目录形式;
-
层级目录必须采用英文描述;
-
根据目录层级,在/usr/local/smokeping/data/目录下生成相应目录及子目录文件夹。
2. 配置示例
#以下是一个简单的两层目录层级配置示例: [root@smokeping smokeping]# vim /usr/local/smokeping/etc/config *** Targets *** probe = FPing menu = Top title = 网络质量监测系统 remark = SmokePing.
\ 您在这里可以观察到网络质量. + IDC menu = IDC网络质量 title = 网络质量监控统计 ++ All_Monitor menu = 网络质量总图 title = 网络质量总图 host = /IDC/CoreSwitch /IDC/AccessSwitch ++ CoreSwitch menu = 监控点至核心 title = 监控点至核心 alerts = someloss host = 10.10.24.1 ++ AccessSwitch menu = 监控点至接入 title = 监控点至接入 alerts = someloss host = 10.11.4.1
五.验证
1. 启动服务
[root@smokeping ~]# systemctl start httpd [root@smokeping ~]# /usr/local/smokeping/bin/smokeping &
2. URL登陆
URL登录:http://10.11.4.250/smokeping
输入前文设置的apache账号/密码登录,即可登录smokeping控制台。
1)HomePage
可以看到,登录账号为前文设置的mcloudadmin,首页及左侧目录都是在config文件的"Targets"章节做的设置。
2)目录层级
3)历史数据展示时间
在config文件Presentation章节的detail部分设置。
4)监测取样点
在config文件Database章节。