网络监控smokeping搭建配置(一)

网络监控smokeping搭建配置(一)

注:本次smokeping搭建采用centos7编译安装

一、安装步骤

1、添加yum镜像源

wget -O /etc/yum.repos.d/CentOS-Base.repo http://mirrors.aliyun.com/repo/Centos-7.repo

2、安装Apache

yum -y install httpd httpd-devel gcc make curl wget

3、安装rrdtool
a.安装依赖的库

yum -y install libxml2-devel libpng-devel glib pango pango-devel \ 
freetype freetype-devel fontconfig cairo cairo-devel \ 
libart_lgpl libart_lgpl-devel

b.安装rrdrool

yum -y install perl perl-Net-Telnet perl-Net-DNS perl-LDAP perl-libwww-perl
yum -y install perl-RadiusPerl perl-IO-Socket-SSL perl-Socket6 perl-CGI-SpeedyCGI 
yum -y install perl-FCGI perl-CGI-SpeedCGI perl-Time-HiRes perl-ExtUtils-MakeMaker
yum -y install perl-RRD-Simple rrdtool rrdtool-per

4、安装smokeping依赖的软件

yum install mod_fcgid bind-utils -y

5、本地安装

#下载安装包:
cd /tmp
wget http://www.fping.org/dist/fping-3.10.tar.gz
wget https://fossies.org/linux/misc/old/echoping-6.0.2.tar.gz
wget https://oss.oetiker.ch/smokeping/pub/smokeping-2.6.11.tar.gz

a.安装依赖包:

yum install perl perl-Net-Telnet perl-Net-DNS perl-LDAP perl-libwww-perl perl-IO-Socket-SSL \
perl-Socket6 perl-Time-HiRes perl-ExtUtils-MakeMaker rrdtool rrdtool-perl curl 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 popt popt-devel libidn libidn-dev 

b.解压、编译安装fping

tar xf fping-3.10.tar.gz
cd fping-3.10
./configure
make && make install

c.解压、编译安装echoping

tar xf echoping-6.0.2.tar.gz
cd echoping-6.0.2
./configure
make && make install

d.解压、编译安装smokeping

tar -xzvf smokeping-2.6.11.tar.gz
cd smokeping-2.6.11
#用Smokeping自带脚本安装依赖包,如果出现超时安装失败的情况在安装结束后再次执行命令,多执行几次,这边软件装不全后面无法进行编译
./setup/build-perl-modules.sh /usr/local/smokeping/thirdparty  
#指定安装路径
./configure --prefix=/usr/local/smokeping 
/usr/bin/gmake install

如果出现报错:

Can’t locate Sys/Syslog.pm in @INC (@INC contains:
/usr/local/smokeping/thirdparty/lib/perl5/x86_64-linux-thread-multi
/usr/local/smokeping/thirdparty/lib/perl5 …/lib
/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 …/lib/Smokeping.pm line 16.

解决办法:

yum -y install perl-Sys-Syslog #缺包了,安装这个就OK

二、修改配置文件

1、配置smokeping

cd /usr/local/smokeping/  
mkdir cache data var  
touch /var/log/smokeping.log      
chown apache:apache cache data var  
chown apache:apache /var/log/smokeping.log  
chmod 600 /usr/local/smokeping/etc/smokeping_secrets.dist  
cd /usr/local/smokeping/htdocs   
mv smokeping.fcgi.dist smokeping.fcgi  
cd /usr/local/smokeping/etc  
mv config.dist config
vi /usr/local/smokeping/etc/config 
#修改如下内容:
cgiurl=http://你的ip/smokeping.cgi   #第14行将ip修改为本机ip

*** Database ***   #第33行
step = 300  此处建议改为 120    #刷新时间秒

2、编辑apache配置文件

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"
<Directory "/usr/local/smokeping">
AllowOverride None
Options All
AddHandler cgi-script .fcgi .cgi
Order allow,deny
Allow from all
DirectoryIndex smokeping.fcgi
</Directory>
#102行修改如下内容
<Directory />  
    Options Indexes FollowSymLinks  
    AllowOverride None  
</Directory></span>  

3、图像浏览界面的中文支持

yum -y install wqy-zenhei-fonts.noarch  #安装字体
vi /usr/local/smokeping/etc/config
charset = utf-8     #第51行添加一行

4、编辑Graphs.pm

vi /usr/local/smokeping/lib/Smokeping/Graphs.pm
#在第147行,下边插入这一行代码
'--font TITLE:20:"WenQuanYi Zen Hei Mono"',

5、smokeping的默认配置文件110行的fping安装目录与此次安装目录不相符需修改!

vi /usr/local/smokeping/etc/config
#第110更改fping的目录为,根据自己安装的位置进行修改
binary = /usr/local/sbin/fping

6、设置配置文件与日志文件位置

/usr/local/smokeping/bin/smokeping --config=/usr/local/smokeping/etc/config --logfile=/usr/local/smokeping/var/smokeping.log  
#重启服务
systemctl restart httpd  
/usr/local/smokeping/bin/smokeping --restart
  • 注意:如果重启失败,那是由于案例中的部分节点地址有问题导致无法识别ipv4,将案例节点删除或者改成自身ip也行。
    OK 现在可以打开页面了 http://ip/smokeping

7、添加监控项目192.168.1.1

vi /usr/local/smokeping/etc/config   #编辑smokeping配置文件
#末尾添加:
+ gateway
menu = 网关
title = 网关(192.168.1.1)
host = 192.168.1.1
alerts = someloss

页面显示如下:
网络监控smokeping搭建配置(一)_第1张图片
https://blog.csdn.net/yujia_666/article/details/80973771

你可能感兴趣的:(linux,监控,smokeping)