Smokeping在CentOs中安装方法

1. 安装其他源

rpm  -Uvh http://apt.sw.be/redhat/el6/en/x86_64/rpmforge/RPMS/rpmforge-release-0.5.3-1.el6.rf.x86_64.rpm

 

rpm -Uvh ftp://195.220.108.108/linux/dag/redhat/el7/en/x86_64/dag/RPMS/rpmforge-release-0.5.3-1.el7.rf.x86_64.rpm

 

注:安装这个源后,接下来要安装的大量的依赖包就不会报错

 

2. 安装rrdtool与依赖库

yum -y install perl perl-Net-Telnet perl-Net-DNS perl-LDAP perl-libwww-perl perl-RadiusPerl perl-IO-Socket-SSL perl-Socket6 perl-CGI-SpeedyCGI perl-FCGI perl-CGI-SpeedCGI perl-Time-HiRes perl-ExtUtils-MakeMaker perl-RRD-Simple rrdtool rrdtool-perl curl fping echoping  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 mod_fastcgi screen

 

第二种:

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

 

 

 

注:perl-CGI-SpeedyCGI,perl-CGI-SpeedCGI这两个包在安装过程中会提示找不到,但没关系  注:用

yum安装大量的依赖包还是很方便的,而百度上有些关于安装smokeping的文档要求使用wget下载后再用make,make install方式安装,虽然make方式不复杂,但通过make编译再安装几十个包就显得有点繁锁了。

 

 

3.下载与安装smokeping

wget http://oss.oetiker.ch/smokeping/pub/smokeping-2.6.8.tar.gz

tar zxvf smokeping-2.6.8.tar.gz

cd smokeping-2.6.8

 ./configure --prefix=/usr/local/smokeping

出现问题是因为需要安装perl的模块,所以运行下面内容即可

 

./setup/build-perl-modules.sh /usr/local/smokeping/thirdparty    //这条有时不解决问题,根据提示失败的安装相关的模块,

例如:Config::Grammar模块

perl -MCPAN -e 'install Config::Grammar'

./configure --prefix=/usr/local/smokeping

/usr/bin/gmake install

 

现在smokeping安装完成

 

4. 配置smokeping

(1) 创建cache、data、var目录 

cd /usr/local/smokeping  

mkdir cache data var  

 

(2) 在创建日志 

touch /var/log/smokeping.log

 

(3) 授权 

chown apache:apache cache data var 

chown apache:apache /var/log/smokeping.log  

 

(4) 修改配置文件 

cd /usr/local/smokeping/htdocs/ 

mv smokeping.fcgi.dist smokeping.fcgi

cd /usr/local/smokeping/etc

mv config.dist config

vim config 

cgiurl  = http://some.url/smokeping.cgi

主要是修改这行,把some.url修改为你的ip或者域名

*** Database ***

step  = 300

pings  = 60 

然后修改step,从300改为60,这是检测的时间, pings 从20 改为60, 即60秒ping 60次

 

(5) .配置完成之后修改密码文件权限 

chmod 600 /usr/local/smokeping/etc/smokeping_secrets.dist 

 

5. 修改apache的配置

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 

DirectoryIndex smokeping.fcgi

</Directory> 

 

6. 设置开机启动httpd, smokeping

echo "/usr/local/smokeping/bin/smokeping --logfile=/var/log/smokeping.log 2>&1 &" >> /etc/rc.local

chkconfig httpd on      #开机启动httpd进程  

 

7. 启动http与smokeping 

/etc/init.d/httpd start 

/usr/local/smokeping/bin/smokeping --logfile=/var/log/smokeping.log 2>&1 &

 

 

8. 打开检测主机的Web页面

  在Web浏览器里输入http://您的监控主机IP/smokeping 

如果遇到500错误:

Internal Server Error 

The server encountered an internal error or misconfiguration and was unable to complete your request. 

Please contact the server administrator, root@localhost and inform them of the time the error occurred, and anything you might have done that may have caused the error. 

More information about this error may be available in the server error log. --------------------------------------------------------------------------------

Apache/2.2.15 (CentOS) Server at 192.168.2.101 Port 80 

 

说明没有关闭SElinux 选项,关闭就正常了        改文件可能要重启才能生效;setenforce 0 可以临时关闭,但重启之后还是会变成原来的状态。

vi /etc/sysconfig/selinux

SELINUX=permissive 

 

如果上面改文件了还关不掉,可以用下面命令关:

setenforce 0

 

[root@localhost ~]# getenforce     #查看SElinux 的命令 

Permissive                     #返回的结果是Permissive, 表示已经关闭SElinux了

 

输出的错误日志:

 

[Wed Oct 15 18:46:42.123788 2014] [authz_core:error] [pid 16857] [client 127.0.0.1:49422] AH01630: client denied by server configuration: /Applications/XAMPP/xamppfiles/docs/myapp.example.com/

 

版本问题,新的apache版本使用黄色部分:

 

<VirtualHost *:80>

 

   DocumentRoot "/Applications/XAMPP/xamppfiles/docs/myapp.example.com"

 

   ServerName myapp.example.com

 

   ServerAlias www.myapp.example.com

 

   SetEnv APPLICATION_ENV "development"

 

   ErrorLog "logs/myapp.example.com-error_log"

 

   CustomLog "logs/myapp.example.com-access_log" common

 

   <Directory "/Applications/XAMPP/xamppfiles/docs/myapp.example.com">

 

       AllowOverride All

 

       Require all granted

 

   </Directory>

 

</VirtualHost>

 

 

9. 在Web页面增加验证用户名和密码(可选步骤) 

(1)修改httpd.conf里的内容 

<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>

 

  注:上面的内容部分已经添加,这里仅添加未重复的内容即可。

 

(2) 设置登录账户与密码 

进入cd /usr/local/smokeping/htdocs目录,

执行命令:htpasswd -c /usr/local/smokeping/htdocs/htpasswd admin

这个是设置登录账户为admin,密码在后面输入,然后重启httpd就可以实现密码验证登录 重新登录web页面,会要求输入用户名和密码,如下图

 

 

11. 一定要同步好时间    

在ESXI4的虚拟机中,定期执行ntpdate 210.72.145.44    #或者与本地的时间服务器同步   

在vmware workstation中,安装vmware-tools, 虚拟机的时间会自动与其宿主机时间同步    

注: 如果vmware workstation中的虚拟机不安装vmware-tools,则虚拟机时间会与宿主机时间相隔整整8个小时(虚拟机时间早于宿主机时间)           vmware-tools的安装不在此叙述  

 

12. 特别说明: 修改/usr/local/smokeping/etc/config 文件的配置参数,必须重启动smokeping程序    

(1)如果重启动smokeping程序失败,根据报错提示删除/usr/local/smokeping/data子文件夹的rrd文件    

(2)中文问题:如果需要在网页里展示中文,修改/usr/local/smokeping/etc的config文件

 

*** Presentation ***     

charset = utf-8 //注:在这里添加     

然后在menu与titile里修改中文,重启即可     

有一个要注意的地方就是,你输入的中文必须在utf-8的字符编码下输入的中文字符,不然会出现乱码。      

如果在xshel下,选择file-properities-terminal     

如果还是不显示就看看你系统里是否安装了中文字体,或者在安装一个 

    

[root@smokeping data]# ps -ef |grep smoke   #查找smokeping进程

root      8740     1  0 09:08 ?       00:00:00 /usr/local/smokeping/bin/smokeping [FPing]     

root     35552 35529  0 09:33 pts/2    00:00:00 grep smoke     

[root@smokeping data]# kill 8740     #杀掉smokeping进程     

[root@smokeping data]# ps -ef |grep smoke      

root     35554 35529  4 09:33 pts/2    00:00:00 grep smoke      

smokeping进程已经被杀掉     

[root@smokeping data]#screen    #如果通过SSH远程登录到监控主机,最后执行screen,在虚拟窗口中启动smokeping     /usr/local/smokeping/bin/smokeping --logfile=/var/log/smokeping.log 2>&1 &

 

需要安装fping

[root@mail /]# wget --limit-rate 500k http://www.fping.org/dist/fping-3.8.tar.gz

[root@mail /]# tar zxvf fping-3.8.tar.gz && cd fping-3.8

[root@mail /]# ./configure && make && make install

 

 

 

三. 添加需要监控的网站和节点(在/usr/local/smokeping/etc/config中添加)

* smokeping就这点不好,添加节点不能在前台Web页面添加,一定要在后台的配置文件中添加,希望以后的版本中能改进一下  *      

* 修改/usr/local/smokeping/etc/config 后,必须重启smokeping 程序,配置才会生效  *          

* smokeping 会根据配置文件config 在/usr/local/smokeping/data 之下添加moniter文件夹,其下包含website子文件夹 *       

* 用vmware workstation的虚拟机测试有一点好处,workstation下的虚拟网卡可以设置出入的丢包率,适合smokeping做丢包测试,

经过测试smokeping检测出的丢包率与vmware worksation虚拟网卡设置的丢包率基本相同,也就是说smokeping 能够反应网络的真实状况 *     

添加监控节点示例:注意+是第一层,++是第二层,+++ 是第三层

 

+ moniter

menu = moniter

  ++ To-DG

  menu =To-DG

  title = To-DG

  alerts = someloss

  host = 159.122.74.153

 

 原文件链接:https://files.cnblogs.com/files/simon4you/smokeping.7z

 

 

posted @ 2019-05-09 09:32  菜鸟Simon  阅读(1318)  评论(0编辑  收藏  举报