centos安装smokeping

本文摘自网友博客,并亲自验证
博客地址:https://blog.csdn.net/erica_yue/article/details/78455101

1、安装依赖包:

yum install -y perl perl-Net-Telnet perl-Net-DNS perl-LDAP perl-libwww-perl perl-IO-Socket-SSL  
yum install -y perl-Socket6 perl-Time-HiRes perl-ExtUtils-MakeMaker rrdtool rrdtool-perl   
yum install -y curl httpd httpd-devel gcc make wget libxml2-devel libpng-devel glib pango pango-devel   
yum install -y freetype freetype-devel fontconfig cairo cairo-devel libart_lgpl  
yum install -y libart_lgpl-devel popt popt-devel libidn libidn-devel  perl-Sys-Syslog podofo

2、安装fping、echoping、smokeping源码包

下载链接http://pan.baidu.com/s/1i5AGvDN 密码kdqk

# 2.1、解压、编译安装fping

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

2.2、解压、编译安装echoping

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

2.3、解压、编译安装smokeping

tar xf smokeping-2.6.9.tar.gz  
cd smokeping-2.6.9  
./setup/build-perl-modules.sh /usr/local/smokeping/thirdparty  
./configure --prefix=/usr/local/smokeping  
/usr/bin/gmake install  

3、配置 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  

4、更改配置文件

vim /usr/local/smokeping/etc/config  

主要修改如下内容:

#cgiurl = http://some.url/smokeping.cgi  
cgiurl = http://10.0.0.62/smokeping.cgi  
*** Database ***  
#step = 300  
step = 60 #此处建议改为 60 , 一分钟采集一次数据  
pings = 20  

5、编辑apache配置文件(apache版本2.2)

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>  
如果apache版本是2.4版本,访问程序会报权限错误。在/var/log/httpd/error.log文件中会找到一下报错信息
[authz_core:error] [pid 30306] [client 192.168.2.149:65495] AH01630: client denied by server configuration: /usr/local/smokeping/htdocs/smokeping.fcgi

原因分析:出现这个错误的原因是因为apache2.2和apache2.4在虚拟主机的配置语法不同导致的
解决方法:将上述配置改成以下配置即可

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 All  
    Options All  
    AddHandler cgi-script .fcgi .cgi  
    Options Indexes FollowSymLinks ExecCGI
    Require all granted
    DirectoryIndex smokeping.fcgi  
</Directory>  

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

安装字体

yum -y install wqy-zenhei-fonts.noarch  

编辑smokeping的配置文件
vim /usr/local/smokeping/etc/config
第50行添加

charset = utf-8 #添加此行  

编辑Graphs.pmvim /usr/local/smokeping/lib/Smokeping/Graphs.pm#第147行下边插入下边一行

'--font TITLE:20:"WenQuanYi Zen Hei Mono"',

7、自定义测试内容

config 配置文件的最后边
vim /usr/local/smokeping/etc/config

 *** Targets ***

probe = FPing

menu = Top
title = Network Latency Grapher
remark = Welcome to the SmokePing website of WORKS Company. \
         Here you will learn all about the latency of our network.

+ InternetSites

menu = Internet Sites
title = Internet Sites

++ sjmy
menu = sjmy
title = sjmy
host = sjmy.dibtime.com

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

vim /usr/local/smokeping/etc/config

第110更改fping的目录为

binary = /usr/local/sbin/fping

9、启动apache和smokeping&设置环境变量

/etc/init.d/httpd start #启动httpd       
/usr/local/smokeping/bin/smokeping #启动smokeping  
echo 'export PATH=/usr/local/smokeping/bin/:$PATH' >> /etc/profile  

10、如果按照上面操作后,直接在网络上访问是十分不安全的,需要加入安全访问控制

修改apache的httpd.conf配置(将上面添加的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  
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>  

设置访问的用户名和密码(比如admin/admin)
[root@bastion-IDC etc]# htpasswd -c /usr/local/smokeping/htdocs/htpasswd admin  
New password:   
Re-type new password:   
Adding password for user admin  
重启apache
[root@bastion-IDC etc]# service httpd restart  
Stopping httpd: [ OK ]  
Starting httpd: [ OK ]  
再次访问smokeping界面,阿里云上暂时没实现
posted @ 2019-04-25 16:46  cdw0724  阅读(375)  评论(0编辑  收藏  举报