侧边栏壁纸
博主头像
落叶人生博主等级

走进秋风,寻找秋天的落叶

  • 累计撰写 130562 篇文章
  • 累计创建 28 个标签
  • 累计收到 9 条评论
标签搜索

目 录CONTENT

文章目录

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

2023-03-31 星期五 / 0 评论 / 0 点赞 / 77 阅读 / 7897 字

1、配置固定IP地址过程比较简单如需请参考https://blog.51cto.com/zhuneianxiang/20499832、关闭防火墙 #查看防火墙是否开启 systemctl sta

.

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.gzcd 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 NoneOptions AllAddHandler cgi-script .fcgi .cgiOrder allow,denyAllow from allDirectoryIndex 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 ErrorThe 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 0getenforce #查看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、主机添加以及配置文件结构解析

#配置文件示例+ yidongmenu = 移动title = 移动++ yidonghuizhongmenu = 移动汇总title = 移动汇总host = /yidong/XiAn-yidong/XA-CM120_192_227_1 /yidong/XiAn-yidong/120_192_227_38++ XiAn-yidongmenu = 西安移动title = 西安移动+++ 120_192_227_38probe = FPing16menu = 西安移动title = 西安移动-120.192.227.38host = 120.192.227.38+++ XA-CM120_192_227_1probe = FPing16menu = 西安移动120_192_227_1title = 西安移动120_192_227_1host = 120.192.227.1#在Smokeping配置文件中以树结构分为3级,一个+代表第一级,两个++代表第二级,同理三个+++代表第三级#如上配置文件示例第一级为yidong其次是两个2级一个汇总图一个按照地域区分,最后一级为实际的监控主机地址

16、添加Web密码验证

#修改/etc/httpd/conf/httpd.conf里的内容<Directory "/usr/local/smokeping">AllowOverride NoneOptions AllAddHandler cgi-script .fcgi .cgiAllowOverride AuthConfigOrder allow,denyAllow from allAuthName "Smokeping"AuthType BasicAuthUserFile /usr/local/smokeping/htdocs/htpasswdRequire valid-userDirectoryIndex 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/bashecho "当前Smokeping进程如下:`ps -ef | grep smokeping`"echo "正在杀掉进程:`killall smokeping`"        sleep 1echo `killall smokeping`echo "进程已杀掉:`ps -ef | grep smokeping`"echo "正在启动Smokeping:`/usr/local/smokeping/bin/smokeping --logfile=/var/log/smokeping.log 2>&1 &`"        sleep 2echo "重启完成,进程如下:`ps -ef | grep smokeping`"


.

广告 广告

评论区