您的位置:首页 > 运维架构 > Linux

Centos 7.x Smokeping部署安装及使用

2020-06-30 20:27 1051 查看

1、配置固定IP地址

过程比较简单如需请参考https://blog.51cto.com/zhuneianxiang/2049983

2、关闭防火墙

 #查看防火墙是否开启
    systemctl status firewalld.service

 

    

  

    #关闭防火墙
    systemctl stop firewalld.service 
    
    #禁用防火墙开机自启
    systemctl disable firewalld.service

3、关闭selinux

    

vim /etc/sysconfig/selinux
#修改SELINUX=enforcing参数为SELINUX=disabled并保存退出

#临时关闭selinux重启失效
setenforce 0

4、在CentOS 7上启用epel版本

yum -y install epel-release

5、安装依赖包

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 httpd
#注:perl-CGI-SpeedyCGI,perl-CGI-SpeedCGI这两个包在安装过程中会提示找不到,但没关系
#注:用yum安装大量的依赖包还是很方便的,而百度上有些关于安装smokeping的文档要求使用wget下载后再用make,make install方式安装,虽然make方式不复杂,但通过make编译再安装几十个包就显得有点繁锁了

6、下载并安装Smokeping

    

#下载
wget https://oss.oetiker.ch/smokeping/pub/smokeping-2.7.3.tar.gz
#本次下载安装版本为2.7.3可根据自己需求进行下载安装,对应版本官网下载链接https://oss.oetiker.ch/smokeping/pub/
#安装

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
./configure --prefix=/usr/local/smokeping
/usr/bin/gmake install

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

8、修改密码权限

    

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

9、修改Httpd服务配置文件

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>

11、设置开机启动Httpd、Smokeping

#添加Smokeping开机启动
echo "/usr/local/smokeping/bin/smokeping --logfile=/var/log/smokeping.log 2>&1 &" >> /etc/rc.local

#Httpd并开机自启动
systemctl enable httpd.service

12、启动服务

#启动Httpd服务
systemctl start httpd.service

#启动Smokeping服务
/usr/local/smokeping/bin/smokeping --logfile=/var/log/smokeping.log 2>&1 &

13、访问Web界面验证

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

14、访问遇错误

1)如遇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选项
vim /etc/sysconfig/selinux
#修改SELINUX=enforcing参数为SELINUX=disabled并保存退出
#临时关闭selinux重启失效
setenforce 0
getenforce #查看SElinux状态如返回Permissive, 表示已经关闭SElinux了

2)Web界面出现软件错误执行如下
mv /usr/local/smokeping/thirdparty/lib/perl5/Carp/Heavy.pm /usr/local/smokeping/thirdparty/lib/perl5/Carp/Heavy.pm.bak

15、主机添加以及配置文件结构解析

#配置文件示例

+ yidong
menu = 移动
title = 移动

++ yidonghuizhong
menu = 移动汇总
title = 移动汇总
host = /yidong/XiAn-yidong/XA-CM120_192_227_1 /yidong/XiAn-yidong/120_192_227_38

++ XiAn-yidong
menu = 西安移动
title = 西安移动

+++ 120_192_227_38
probe = FPing16
menu = 西安移动
title = 西安移动-120.192.227.38
host = 120.192.227.38

+++ XA-CM120_192_227_1
probe = FPing16
menu = 西安移动120_192_227_1
title = 西安移动120_192_227_1
host = 120.192.227.1

#在Smokeping配置文件中以树结构分为3级,一个+代表第一级,两个++代表第二级,同理三个+++代表第三级
#如上配置文件示例第一级为yidong其次是两个2级一个汇总图一个按照地域区分,最后一级为实际的监控主机地址

16、添加Web密码验证

#修改/etc/httpd/conf/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>

进入cd /usr/local/smokeping/htdocs目录, 执行命令:htpasswd -c /usr/local/smokeping/htdocs/htpasswd admin
这个是设置登录账户为admin,密码在后面输入,然后重启httpd就可以实现密码验证登录

17、最终效果图

    1)汇总效果图

    

    #图中-nan为IP地址已不通~

    2)按照地域区分

    

    3)单独节点查看

    

18、因为每次修改配置文件都需要重启服务,附上重启脚本。

    

#!/bin/bash
echo "当前Smokeping进程如下:`ps -ef | grep smokeping`"
echo "正在杀掉进程:`killall smokeping`"
        sleep 1
echo `killall smokeping`
echo "进程已杀掉:`ps -ef | grep smokeping`"
echo "正在启动Smokeping:`/usr/local/smokeping/bin/smokeping --logfile=/var/log/smokeping.log 2>&1 &`"
        sleep 2
echo "重启完成,进程如下:`ps -ef | grep smokeping`"


内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: