安装和使用Smokeping
Posted
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了安装和使用Smokeping相关的知识,希望对你有一定的参考价值。
(一)简介smokeping是对IDC网络质量,稳定性等最好的检测工具,包括常规的 ping,dig,echoping,curl等,可以监视www服务器性能,监视dns查询性能,监视ssh性能等。底层也是 rrdtool 做支持,特点是画的图非常漂亮,网络丢包和延迟用颜色和阴影来表示。
smokeping的优点:
最佳的画图功能,延迟和丢包用颜色和阴影表示很直观。
免费和开源,作者是MRTG和RRDtool作者。
支持主从的分布式模式。
可以自定义报警功能。
smokeping架构组件:
smokeping 是一个用 perl 写的程序,所以不需要安装,但是他需要使用一些工具。Smokeping 有以下组件组成:RRDtool、Fping、Echoping、Curl、Dig、SSh、Perl 模块,Perl、FCGI、Apache 等。
Smokeping环境:
CentOS7.4 +Smokeping2.6.11
(二)安装
1,关闭selinux
[[email protected] tmp]# setenforce 0
[[email protected] tmp]# vim /etc/selinux/config
# This file controls the state of SELinux on the system.
# SELINUX= can take one of these three values:
# enforcing - SELinux security policy is enforced.
# permissive - SELinux prints warnings instead of enforcing.
# disabled - No SELinux policy is loaded.
SELINUX=disabled
# SELINUXTYPE= can take one of three two values:
# targeted - Targeted processes are protected,
# minimum - Modification of targeted policy. Only selected processes are protected.
# mls - Multi Level Security protection.
SELINUXTYPE=targeted
[[email protected] tmp]# source /etc/selinux/config
2,安装相关依赖的包[[email protected] tmp]# yum install -y rrdtool wqy* fping gcc 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,官网下载相应的安装包(https://oss.oetiker.ch/smokeping/)
[[email protected] tmp]# wget https://oss.oetiker.ch/smokeping/pub/smokeping-2.6.11.tar.gz
--2018-01-18 18:28:30-- https://oss.oetiker.ch/smokeping/pub/smokeping-2.6.11.tar.gz
Resolving oss.oetiker.ch (oss.oetiker.ch)... 46.140.183.210, 2a02:aa08:e000:1e00::d2
Connecting to oss.oetiker.ch (oss.oetiker.ch)|46.140.183.210|:443... connected.
HTTP request sent, awaiting response... 200 OK
Length: 417338 (408K) [application/x-gzip]
Saving to: ‘smokeping-2.6.11.tar.gz’
100%[=======================================================================================>] 417,338 63.2KB/s in 6.5s
2018-01-18 18:28:39 (63.2 KB/s) - ‘smokeping-2.6.11.tar.gz’ saved [417338/417338]
4,编译安装smokeping
#请注意在configure前需要先build相应的perl模块,否则有报错。
[[email protected] tmp]# ls
ks-script-HudzSv smokeping-2.6.11.tar.gz yum.log
[[email protected] tmp]# tar xf smokeping-2.6.11.tar.gz
[[email protected] tmp]# cd smokeping-2.6.11
[[email protected] smokeping-2.6.11]# ./setup/build-perl-modules.sh /usr/local/smokeping/thirdparty
[[email protected] smokeping-2.6.11]# ./configure --prefix=/usr/local/smokeping
[[email protected] smokeping-2.6.11]# gmake install
5,配置smokeping
1,创建相应的目录并赋予权限
[[email protected] smokeping-2.6.11]# cd /usr/local/smokeping/
[[email protected] smokeping]# ll
total 0
drwxr-xr-x. 2 root root 75 Jan 18 19:35 bin
drwxr-xr-x. 3 root root 137 Jan 18 19:35 etc
drwxr-xr-x. 3 root root 48 Jan 18 19:35 htdocs
drwxr-xr-x. 3 root root 100 Jan 18 19:35 lib
drwxr-xr-x. 3 root root 17 Jan 18 19:35 share
drwxr-xr-x. 6 root root 67 Jan 18 19:34 thirdparty
[[email protected] smokeping]# mkdir var cache data
[[email protected] smokeping]# chown apache.apache var/ cache/ data/
[[email protected] smokeping]# ll
total 0
drwxr-xr-x. 2 root root 75 Jan 18 19:35 bin
drwxr-xr-x. 2 apache apache 6 Jan 18 19:48 cache
drwxr-xr-x. 2 apache apache 6 Jan 18 19:48 data
drwxr-xr-x. 3 root root 137 Jan 18 19:35 etc
drwxr-xr-x. 3 root root 48 Jan 18 19:35 htdocs
drwxr-xr-x. 3 root root 100 Jan 18 19:35 lib
drwxr-xr-x. 3 root root 17 Jan 18 19:35 share
drwxr-xr-x. 6 root root 67 Jan 18 19:34 thirdparty
drwxr-xr-x. 2 apache apache 6 Jan 18 19:48 var
2,备份fcgi文件与config文件
[[email protected] smokeping]# cp /usr/local/smokeping/htdocs/smokeping.fcgi.dist /usr/local/smokeping/htdocs/smokeping.fcgi
[[email protected] smokeping]# cp /usr/local/smokeping/etc/config.dist /usr/local/smokeping/etc/config
3,修改config文件,把cgiurl = http://some.url/smokeping.cgi中的some.url换成你的IP地址
[[email protected] smokeping]# sed -i ‘s|some.url|172.20.66.111|g‘ /usr/local/smokeping/etc/config
[[email protected] smokeping]# vim etc/config
*** General ***
owner = Peter Random
contact = [email protected]
mailhost = my.mail.host
sendmail = /usr/sbin/sendmail
# NOTE: do not put the Image Cache below cgi-bin
# since all files under cgi-bin will be executed ... this is not
# good for images.
imgcache = /usr/local/smokeping/cache
imgurl = cache
datadir = /usr/local/smokeping/data
piddir = /usr/local/smokeping/var
cgiurl = http://172.20.66.111/smokeping.cgi
4,Alerts和database配置
*** Alerts ***
to = [email protected]
from = [email protected]
+someloss
type = loss
# in percent
pattern = >0%,*12*,>0%,*12*,>0%
comment = loss 3 times in a row
#新增rtt监测机制
+rttdetect
type = rtt
# in milliseconds
pattern = <55,<55,<55,>55,>55,>55
comment = 每次发出60个包,连续3次轮询检查延时超过55毫秒
*** Database ***
######默认300秒ping20次,修改为120秒ping30次
step = 120
pings = 30
5,presentation配置,添加utf-8字符集和在detail部分,修改历史数据展示的时间
*** Presentation ***
###添加UTF-8中文字符集
charset = utf-8
template = /usr/local/smokeping/etc/basepage.html.dist
+ 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
width = 600
height = 50
range = 10h
+ detail
width = 600
height = 200
unison_tolerance = 2
"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
#"Last 3 Hours" 3h
#"Last 30 Hours" 30h
#"Last 10 Days" 10d
#"Last 400 Days" 400d
6,修改账号文件权限
[[email protected] smokeping]# chmod 600 /usr/local/smokeping/etc/smokeping_secrets.dist
7,创建登录账号和密码
[[email protected] smokeping]# htpasswd -c /usr/local/smokeping/htdocs/htpasswd admin
New password:
Re-type new password:
Adding password for user admin
[[email protected] smokeping]#
7,设置httpd的访问路径
[[email protected] 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"
<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>
8,关闭防火墙
[[email protected] smokeping]# service firewalld stop
[[email protected] smokeping]# systemctl stop iptables.service
9.设置开机启动[[email protected] smokeping]# echo "/usr/local/smokeping/bin/smokeping &">> /etc/rc.local
以上是关于安装和使用Smokeping的主要内容,如果未能解决你的问题,请参考以下文章