设为首页 收藏本站
查看: 2318|回复: 0

[经验分享] 基于Apache搭建的smokeping监控及配置

[复制链接]

尚未签到

发表于 2015-11-23 10:44:21 | 显示全部楼层 |阅读模式
Smokeping搭建可分多种web框架可选nginx、apache等,接口可选fcgi、cgi等。
操作系统:选择centOS6.5 版, 里面的RPM包基本上都是最新的。
一、基本环境的设置
1. 网卡的设置 /etc/sysconfig/network-scripts/ifcfg-eth0
  图略
2. DNS的设置 /etc/resolv.conf
图略
3. 设置时区 tzselect
依次选择5-9-1-1所在大洲—所在国家—所使用的时区—确定所选时区。
检验 输入date 查看是否为CST时区
图略
4. 同步时间
Ntpdate time.nist.gov


二、部署前期工作
1. 安装epel源
64位 rpm -Uvh http://apt.sw.be/redhat/el6/en/x86_64/rpmforge/RPMS/rpmforge-release-0.5.3-1.el6.rf.x86_64.rpm
32位 Rpm -Uvh http://apt.sw.be/redhat/el6/en/i386/rpmforge/RPMS/rpmforge-release-0.5.3-1.el6.rf.i686.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
注:perl-CGI-SpeedyCGI,perl-CGI-SpeedCGI这两个包在安装过程中会提示找不到,但没关系。


三、安装及配置Smokeping
1. 下载并安装Smokeping
cd /tmp
wget http://oss.oetiker.ch/smokeping/pub/smokeping-2.6.9.tar.gz
tar -zxvf smokeping-2.6.9.tar.gz
cd smokeping-2.6.9
mkdir /usr/local/smokeping
./configure --prefix=/usr/local/smokeping
出现问题是因为需要安装perl的模块,所以运行下面内容即可
解决 'Config::Grammar' ... Failed
Wget http://search.cpan.org/CPAN/authors/id/D/DS/DSCHWEI/Config-Grammar-1.10.tar.gz
tar zxvf Config-Grammar-1.10.tar.gz
cd Config-Grammar
perl Makefile.PL
make
make install
./setup/build-perl-modules.sh /usr/local/smokeping/thirdparty
./configure --prefix=/usr/local/smokeping
/usr/bin/gmake install
现在smokeping安装完成。
2. 配置Smokeping(基于Apache)
(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) 修改配置文件
mv cache ./htdocs/
cd /usr/local/smokeping/htdocs/
mv smokeping.fcgi.dist smokeping.fcgi
cd /usr/local/smokeping/etc
mv config.dist config
修改配置文件config
vim config
imgcache = /usr/local/smokeping/cache
imgcache = /usr/local/smokeping/htdocs/cache
修改cache的路径与Apache里修改的对应。
cgiurl   = http://some.url/smokeping.cgi
把some.url修改为你的ip或者域名
*** Database ***
step  = 300
pings  = 20
然后修改step,从300改为60,这是检测的时间, pings 从20 改为60, 即60秒ping 60次
(5) .配置完成之后修改密码文件权限
chmod 600 /usr/local/smokeping/etc/smokeping_secrets.dist
3. 修改apache的配置
vi /etc/httpd/conf/httpd.conf
在DocumentRoot "/var/www/html" 这一行之下添加如下内容:
Alias /cache "/usr/local/smokeping/htdocs/cache"
Alias /cropper "/usr/local/smokeping/htdocs/cropper"
Alias /smokeping "/usr/local/smokeping/htdocs"
<Directory &quot;/usr/local/smokeping/htdocs&quot;>
  AllowOverride None
  AddHandler cgi-script .fcgi .cgi
  Options ExecCGI
  <IfModule dir_module>
     DirectoryIndex smokeping.fcgi
  </IfModule>
  Order allow,deny
  Allow from all
</Directory>
4. 启动httpd服务并设置httpd开机启动及关闭防火墙
/etc/init.d/httpd start    #启动httpd服务或 service httpd start
chkconfig httpd on      #开机启动httpd进程
service iptables stop   #关闭防火墙
chkconfig iptables off  #开机不启动iptables服务

、添加smokeping中文支持及rrd图片支持中文
1. 页面支持中文 vi /usr/local/smokeping/etc/config
在配置文件的*** Presentation ***下添加(红色部分为添加内容)
*** Presentation ***
charset = utf-8
template = /usr/local/smokeping/etc/basepage.html.dist
vi basepage.html.dist
2. 如页面左侧层里文字依然是乱码  vi /usr/local/smokeping/etc/basepage.html.dist
可在basepage.html.dist文件头部位置中添加一句。
<HEAD>
<META charset=&quot;utf-8&quot; />
<META HTTP-EQUIV=&quot;Cache-Control&quot; content=&quot;no-cache&quot;>
3. 添加rrd图片支持中文,安装中文字库
yum -y install wqy-zenhei-fonts.noarch
修改配置文件 vi /usr/local/smokeping/lib/Smokeping/Graphs.pm
My ($graphret,$xs,$ys) = RRDs::graph
(&quot;dummy&quot;,
'--start', $tasks[0][1],
'--end', $tasks[0][2],
'--font TITLE:20:&quot;WenQuanYi Zen Hei Mono&quot;',
&quot;DEF:maxping=$cfg->{General}{datadir}${host}.rrd:median:AVERAGE&quot;,
'PRINT:maxping:MAX:%le' );
4. 重启smokeping服service smokeping restart 或者/etc/init.d/smokeping restart
修改/usr/local/smokeping/etc/config 文件的配置参数,必须重启动smokeping程序。
如果重启动smokeping程序失败,根据报错提示删除/usr/local/smokeping/data子文件夹的rrd文件。

七、打开检测主机的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
[iyunv@localhost ~]# getenforce     #查看SElinux 的命令
Permissive                      #返回的结果是Permissive, 表示已经关闭SElinux了

八、在Web页面增加验证用户名和密码(可选步骤)
1. 修改httpd.conf里的内容
vi /etc/httpd/conf/httpd.conf
<Directory &quot;/usr/local/smokeping&quot;>
AllowOverride None
Options All
AddHandler cgi-script .fcgi .cgi
AllowOverride AuthConfig
Order allow,deny
Allow from all
AuthName &quot;Smokeping&quot;
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就可以实现密码验证登录。
service httpd restart
重新登录web页面,会要求输入用户名和密码。

运维网声明 1、欢迎大家加入本站运维交流群:群②:261659950 群⑤:202807635 群⑦870801961 群⑧679858003
2、本站所有主题由该帖子作者发表,该帖子作者与运维网享有帖子相关版权
3、所有作品的著作权均归原作者享有,请您和我们一样尊重他人的著作权等合法权益。如果您对作品感到满意,请购买正版
4、禁止制作、复制、发布和传播具有反动、淫秽、色情、暴力、凶杀等内容的信息,一经发现立即删除。若您因此触犯法律,一切后果自负,我们对此不承担任何责任
5、所有资源均系网友上传或者通过网络收集,我们仅提供一个展示、介绍、观摩学习的平台,我们不对其内容的准确性、可靠性、正当性、安全性、合法性等负责,亦不承担任何法律责任
6、所有作品仅供您个人学习、研究或欣赏,不得用于商业或者其他用途,否则,一切后果均由您自己承担,我们对此不承担任何法律责任
7、如涉及侵犯版权等问题,请您及时通知我们,我们将立即采取措施予以解决
8、联系人Email:admin@iyunv.com 网址:www.yunweiku.com

所有资源均系网友上传或者通过网络收集,我们仅提供一个展示、介绍、观摩学习的平台,我们不对其承担任何法律责任,如涉及侵犯版权等问题,请您及时通知我们,我们将立即处理,联系人Email:kefu@iyunv.com,QQ:1061981298 本贴地址:https://www.yunweiku.com/thread-142542-1-1.html 上篇帖子: 使用smokeping监测网络 下篇帖子: centos smokeping nginx 部署,监控网络状况
您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

扫码加入运维网微信交流群X

扫码加入运维网微信交流群

扫描二维码加入运维网微信交流群,最新一手资源尽在官方微信交流群!快快加入我们吧...

扫描微信二维码查看详情

客服E-mail:kefu@iyunv.com 客服QQ:1061981298


QQ群⑦:运维网交流群⑦ QQ群⑧:运维网交流群⑧ k8s群:运维网kubernetes交流群


提醒:禁止发布任何违反国家法律、法规的言论与图片等内容;本站内容均来自个人观点与网络等信息,非本站认同之观点.


本站大部分资源是网友从网上搜集分享而来,其版权均归原作者及其网站所有,我们尊重他人的合法权益,如有内容侵犯您的合法权益,请及时与我们联系进行核实删除!



合作伙伴: 青云cloud

快速回复 返回顶部 返回列表