c4rt1y

网络监控之smokeping安装部署

0x01 介绍

在centos7下安装smokeping。smokeping来监控idc机房的网络质量情况,类似于站长之家的全国或者全球ping操作,从而获取各地网络质量情况。

0x02 安装部署

#安装第三方依赖源
yum -y install epel-release

#设置时间服务器,同步时间
yum install ntpdate -y 
ntpdate times.aliyun.com


#保证依赖环境一致
yum groupinstall "Compatibility libraries" "Base" "Development tools" -y 
#安装rrdtool与依赖库
yum  -y install cpan perl perl-FCGI perl-CGI perl-Digest-HMAC perl-Net-Telnet perl-Net-OpenSSH perl-Net-SNMPperl-LDAP perl-Net-DNS perl-IO-Pty-Easy perl-Test-Simple perl-Sys-Syslog perl-libwww-perlperl-IO-Socket-SSL perl-Socket6 perl-CGI-SpeedyCGI perl-FCGI perl-Time-HiResperl-ExtUtils-MakeMaker rrdtool rrdtool-perl curl fping httpd httpd-devel gccmake wget libxml2-devel libpng-devel glib pango pango-devel freetypefreetype-devel fontconfig cairo cairo-devel libart_lgpl libart_lgpl-devel mod_fcgidscreen

#安装echoping会报错,所以提前把这俩安装了
yum install -y popt
yum install -y libidn
yum install -y openssl openssl-devel
wget https://fossies.org/linux/misc/old/echoping-6.0.2.tar.gz
tar zxf echoping-6.0.2.tar.gz && cd  echoping-6.0.2 && ./configure --prefix=/usr/local/echoping --with-ssl --without-libidn && make && make install


#下载smokeping
wget https://oss.oetiker.ch/smokeping/pub/smokeping-2.6.11.tar.gz
#解压smokeping
tar zxf smokeping-2.6.11.tar.gz
cd smokeping-2.6.11
#初始化
./setup/build-perl-modules.sh /usr/local/smokeping/thirdparty
#配置参数
./configure --prefix=/usr/local/smokeping
#编译
/usr/bin/gmake install

#修改配置文件
cd /usr/local/smokeping/ && mkdir cache data var && chown apache:apache cache data var
touch /var/log/smokeping.log  && chown apache:apache /var/log/smokeping.log  
mv /usr/local/smokeping/htdocs/smokeping.fcgi.dist /usr/local/smokeping/htdocs/smokeping.fcgi
mv /usr/local/smokeping/etc/config.dist /usr/local/smokeping/etc/config 


#设置页面访问权限401认证
htpasswd -c /usr/local/smokeping/htdocs/htpasswd admin
chmod 600 /usr/local/smokeping/etc/smokeping_secrets.dist

#在httpd.conf加入如下内容
vi /etc/httpd/conf/httpd.conf
#########changed by c4rt1y##############
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
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>

#修改config配置文件,IP为本机,每60秒执行一次,10秒ping一次
vim /usr/local/smokeping/etc/config 
giurl   = http://10.10.10.30/smokeping.cgi 
step     = 300     ==>     step     = 60
pings    = 20      ==>     pings   = 10


#开机启动
echo "/usr/local/smokeping/bin/smokeping --logfile=/var/log/smokeping.log 2>&1 &" >> /etc/rc.local
#启动httpd和smokeping
/etc/init.d/httpd start
/usr/local/smokeping/bin/smokeping --logfile=/var/log/smokeping.log 2>&1 &

#浏览器访问(首次出现401验证,输入你配置的账号和密码)
http://10.10.10.30/smokeping



#修改字符集(增加中文功能)
#安装字体包
yum -y install wqy-zenhei-fonts       
#修改配置文件
vi /usr/local/smokeping/etc/config
*** Presentation ***
charset = utf-8                #在Presentation 下添加charset = utf-8然后保存退出

#修改配置文件
vi /usr/local/smokeping//lib/Smokeping/Graphs.pm
        my $val = 0;
        for my $host (@hosts){
            my ($graphret,$xs,$ys) = RRDs::graph
            ("dummy",
            '--start', $tasks[0][1],
            '--end', $tasks[0][2],
            '--font TITLE:20""',            #增加这一行
            "DEF:maxping=$cfg->{General}{datadir}${host}.rrd:median:AVERAGE",
            'PRINT:maxping:MAX:%le' );
            my $ERROR = RRDs::error();

编辑/usr/local/smokeping/etc/config文件,删除test模块

new-centos

#在下面加入以下内容(#有个问题需要我们注意+是第一层,++是第二层,+++ 是第三层,添加监控节点一定要按照此规范哦,此时如果启动的话中文是如下所示乱码情况,所以我们先解决再启动)
##添加如下数据并保存
+ Other
menu = 三大网络监控
title = 监控统计
++ dianxin
menu = 电信网络监控
title = 电信网络监控列表
+++ dianxin-bj
menu = 北京电信
title = 北京电信
alerts = someloss
host = 202.96.199.133
+++ dianxin-hlj
menu = 黑龙江电信
title = 黑龙江电信
alerts = someloss
host = 219.147.198.242
+++ dianxin-tj
menu = 天津电信
title = 天津电信
alerts = someloss
host = 219.150.32.132
+++ dianxin-sc
menu = 四川电信
title = 四川电信
alerts = someloss
host = 61.139.2.69
+++ dianxin-sh
menu = 上海电信
title = 上海电信
alerts = someloss
host = 116.228.111.118
+++ dianxin-gz
menu = 广东电信
title = 广东电信
alerts = someloss
host = 113.111.211.22
++ liantong
menu = 联通网络监控
title = 联通网络监控列表
+++ liantong-bj
menu = 北京联通
title = 北京联通
alerts = someloss
host = 61.135.169.121
+++ liantong-hlj
menu = 黑龙江联通
title = 黑龙江联通
alerts = someloss
host = 202.97.224.69
+++ liantong-tj
menu = 天津联通
title = 天津联通
alerts = someloss
host = 202.99.96.68
+++ liantong-sc
menu = 四川联通
title = 四川联通
alerts = someloss
host = 119.6.6.6
+++ liantong-sh
menu = 上海联通
title = 上海联通
alerts = someloss
host = 210.22.84.3
+++ liantong-gz
menu = 广东联通
title = 广东联通
alerts = someloss
host = 221.5.88.88
++ yidong
menu = 移动网络监控
title = 移动网络监控列表
+++ yidong-bj
menu = 北京移动
title = 北京移动
alerts = someloss
host = 221.130.33.52
+++ yidong-hlj
menu = 黑龙江移动
title = 黑龙江移动
alerts = someloss
host = 211.137.241.35
+++ yidong-tj
menu = 天津移动
title = 天津移动
alerts = someloss
host = 211.137.160.5
+++ yidong-sc
menu = 四川移动
title = 四川移动
alerts = someloss
host = 218.201.4.3
+++ yidong-sh
menu = 上海移动
title = 上海移动
alerts = someloss
host = 117.131.19.23
+++ yidong-gz
menu = 广东移动
title = 广东移动
alerts = someloss
host = 211.136.192.6


#重启smokeping
/usr/local/smokeping/bin/smokeping --reload

#这里需要等待片刻(关于自己的网络问题,会下载配置文件,上述我们设置的采集时间是60s),结果如下

new-centos

0x03 资料来源

http://www.aclstack.com/454.html
GoTop