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

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

[复制链接]

尚未签到

发表于 2015-11-23 10:53:34 | 显示全部楼层 |阅读模式
  刚接触Linux中的smokeping监控时,什么也不懂,百度安装资料都不得心应手。根据多次尝试,总结得出的成功安装方法,很实用。相关的命令我也写出来了,供新手学习,大神就请跳过。在此就不多做解释什么是smokeping了,下面来开始安装吧。
  此方法安装的smokeping默认位置是/usr/share/nginx/html/smokeping下,nginx使用80端口,网页登入网址:IP/smokeping.fcgi,无需验证用户名和密码。
  1.操作系统的安装
  操作系统安装centos6.0以上版本 64位
  2.基本环境的设置
  网卡的设置 /etc/sysconfig/network-scripts/ifcfg-eth0
  DNS的设置 /etc/resolv.conf
  设置时区 tzselect
依次选择5-9-1-1所在大洲—所在国家—所使用的时区—确定所选时区。
检验 输入date 查看是否为CST时区
同步时间
ntpdate time.nist.gov
安装epel源 rpm -Uvh http://mirrors.sohu.com/fedora-epel/6/x86_64/epel-release-6-8.noarch.rpm

  3.web服务器的基本设置
安装PHP、nginx、spawn-fcgi等基础支持软件
yum install -y openssh-clients telnet wget nginx php-cgi php-cli spawn-fcgi mysql-server mysql rrdtool net-snmp net-snmp-utils net-snmp-devel php-mysql php-snmp
配置PHP管理器 vi /etc/sysconfig/spawn-fcgi
在文件改位置添加如下命令
       #SOCKET=/var/run/php-fcgi.sock
       #OPTIONS="-u apache -g apache -s $SOCKET -S -M 0600 -C 32 -F 1 -P /var/run/spawn-fcgi.pid -- /usr/bin/php-cgi"
       SOCKET=/var/run/php-fcgi.sock
       OPTIONS="-u nginx -g nginx -s $SOCKET -S -M 0600 -C 32 -F 1 -P /var/run/spawn-fcgi.pid -- /usr/bin/php-cgi"

重启php管理器及设置开机启动服务
/etc/init.d/spawn-fcgi restart
chkconfig spawn-fcgi on
创建/var/lib/php下session 目录
mkdir -p /var/lib/php/session
chown -R nginx.nginx /var/lib/php/session
修改PHP文件配置 vi /etc/php.ini
(1)修改PHP时区为Asia/ShangHai,在文件如下位置添加该句命令
;;;;;;;;;;;;;;;;;;;
; Module Settings ;
;;;;;;;;;;;;;;;;;;;
[Date]
; Defines the default timezone used by the date functions
; http://www.php.net/manual/en/datetime.configuration.php#ini.date.timezone
;date.timezone =
date.timezone = Asia/ShangHai
(2)修改PHP调用内存限制,在文件如下位置修改如下
;;;;;;;;;;;;;;;;;;;
; Resource Limits ;
;;;;;;;;;;;;;;;;;;;
; Maximum execution time of each script, in seconds
; http://www.php.net/manual/en/info.configuration.php#ini.max-execution-time
max_execution_time = 30
; Maximum amount of memory a script may consume (128MB)
; http://www.php.net/manual/en/ini.core.php#ini.memory-limit
#memory_limit = 128M
memory_limit = 512M
为nginx添加fcgi[不安装无法开启smokeping],支持fcgi支持需要一些组件支持,所有组件均下载到tmp目录下
安装组件FCGI
cd /tmp
yum -y install gcc wget perl-devel perl-CPAN
wget http://search.cpan.org/CPAN/authors/id/F/FL/FLORA/FCGI-0.74.tar.gz
tar zxvf FCGI-0.74.tar.gz
cd FCGI-0.74
perl Makefile.PL
make && make install

  安装组件FCGI-ProcManager
  cd /tmp
wget http://search.cpan.org/CPAN/authors/id/B/BO/BOBTFISH/FCGI-ProcManager-0.24.tar.gz
tar zxvf FCGI-ProcManager-0.24.tar.gz
cd FCGI-ProcManager-0.24
perl Makefile.PL
make && make install
  安装组件Getopt-Long
cd /tmp
wget http://search.cpan.org/CPAN/authors/id/J/JV/JV/Getopt-Long-2.42.tar.gz
tar zxvf Getopt-Long-2.42.tar.gz
cd Getopt-Long-2.42
perl Makefile.PL
make && make install
安装组件IO-String
cd /tmp
wget http://search.cpan.org/CPAN/authors/id/G/GA/GAAS/IO-String-1.08.tar.gz
tar zxvf IO-String-1.08.tar.gz
cd IO-String-1.08
perl Makefile.PL
make && make install

  安装组件IO
cd /tmp
wget http://search.cpan.org/CPAN/authors/id/G/GB/GBARR/IO-1.25.tar.gz
tar zxvf IO-1.25.tar.gz
cd IO-1.25
perl Makefile.PL
make && make install

   安装组件IO-All
cd /tmp
wget http://search.cpan.org/CPAN/authors/id/I/IN/INGY/IO-All-0.66.tar.gz
tar zxvf IO-All-0.66.tar.gz
cd IO-All-0.66
perl Makefile.PL
make && make install
安装组件ExtUtils-Constant
cd /tmp
wget http://search.cpan.org/CPAN/authors/id/N/NW/NWCLARK/ExtUtils-Constant-0.23.tar.gz
tar zxvf ExtUtils-Constant-0.23.tar.gz
cd ExtUtils-Constant-0.23
perl Makefile.PL
make && make install

  安装组件Socket
cd /tmp
wget http://search.cpan.org/CPAN/authors/id/P/PE/PEVANS/Socket-2.014.tar.gz
tar zxvf Socket-2.014.tar.gz
cd Socket-2.014
perl Makefile.PL
make && make install
安装nginx-fcgi
cd /tmp
wget http://122.228.213.147/nginx-fcgi
cp nginx-fcgi /etc/
chmod +x /etc/nginx-fcgi
cd /etc/nginx
mkdir log
cd log/
touch nginx-fcgi.log
chown nginx:nginx  nginx-fcgi.log

   注册fcgi
cd /tmp
wget http://122.228.213.147/fcgi
cp ./fcgi /etc/init.d/
chmod +x /etc/init.d/fcgi
chkconfig --add fcgi

  设置fcgi开机启动及重启fcgi服务
chkconfig fcgi on
service fcgi restart

4.smokeping安装
安装smokeping的依赖包
yum install -y rrdtool fping  curl perl-Net-Telnet perl-Net-DNS perl-LDAP perl-CGI-SpeedyCGI perl-libwww-perl  perl-IO-Socket-SSL  rrdtool-perl gcc gcc-c++ zlib-devel pcre-devel perl-devel rrdtool-devel ntp perl-Perl-OSType perl-IPC-Cmd
安装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/share/nginx/html/smokeping
./configure --prefix=/usr/share/nginx/html/smokeping
#出现提示缺少部分组件
安装FCGI、CGI、CGI::Fast、Config::Grammar、Digest::HMAC_MD5、Net::Telnet、Net::OpenSSH、Net::SNMP、Net::LDAP、Net::DNS、IO::Pty、LWP
根据提示执行相关语句
./setup/build-perl-modules.sh /usr/share/nginx/html/smokeping/thirdparty
./configure --prefix=/usr/share/nginx/html/smokeping
/usr/bin/gmake install
初始化环境
mkdir /usr/share/nginx/html/smokeping/{cache,data,var}
chmod 400 /usr/share/nginx/html/smokeping/etc/smokeping_secrets.dist
cp /usr/share/nginx/html/smokeping/htdocs/smokeping.fcgi.dist  /usr/share/nginx/html/smokeping/htdocs/smokeping.fcgi
(出现报错后把smokeping重新安装一遍,最后执行根据提示执行相关语句/usr/bin/gmake install)
cp /usr/share/nginx/html/smokeping/etc/config.dist  /usr/share/nginx/html/smokeping/etc/config
chown -R nginx:nginx /usr/share/nginx/html/smokeping
添加smokeping为系统服务,在/etc/init.d建立smokeping文件
wget http://122.228.213.147/smokeping.sh
mv smokeping.sh smokeping
cp ./smokeping /etc/init.d/
chmod +x /etc/init.d/smokeping
chkconfig --add smokeping
chkconfig smokeping on
service smokeping restart
有警告正常情况。
编辑ngingx配置文件 vi /etc/nginx/conf.d/default.conf
在文件中添加对于smokeping的支持(红色部分为添加、修改内容)
location / {
        root   /usr/share/nginx/html/smokeping;
        index  index.html index.htm;
        }
        location  ~\.(pl|fcgi)$
        {
          root /usr/share/nginx/html/smokeping/htdocs/;
          include fastcgi_params;
          fastcgi_pass unix:/tmp/nginx-fcgi.sock;
          fastcgi_index index.pl;
          fastcgi_param  SCRIPT_FILENAME  $document_root$fastcgi_script_name;
        }

设置nginx开机启动及重启nginx服务
chkconfig nginx on
service nginx restart

  添加smokeping中文支持
页面支持中文 vi /usr/share/nginx/html/smokeping/etc/config
cd /usr/share/nginx/html/smokeping/etc   
vi config
在配置文件的*** Presentation ***下添加(红色部分为添加内容)
*** Presentation ***
charset = utf-8
template = /usr/local/smokeping/etc/basepage.html.dist
vi basepage.html.dist
如页面左侧层里文字依然是乱码  vi /usr/share/nginx/html/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;>

添加rrd图片支持中文
安装中文字库  yum -y install wqy-zenhei-fonts.noarch
修改配置文件  vi /usr/share/nginx/html/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' );

安装完成后,重启smokeping服务  /etc/init.d/smokeping restart

  浏览器输入:IP/smokeping.fcgi 即可。

运维网声明 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-142548-1-1.html 上篇帖子: Smokeping 安装 下篇帖子: CentOS 6.5 下 Smokeping 安装
您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

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

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

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

扫描微信二维码查看详情

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


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


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


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



合作伙伴: 青云cloud

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