电脑疯子技术论坛|电脑极客社区

微信扫一扫 分享朋友圈

已有 2801 人浏览分享

centos7.2 安装smokeping

[复制链接]
2801 0
第1章 基本概念


第2章 安装

2.0 时间同步


  1. yum -y install ntpdate
  2. ntpdate times.aliyun.com
复制代码


2.1 安装依赖包
       
  1. yum groupinstall "Compatibility libraries" "Base" "Development tools" -y

  2. yum -y installcpan 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
复制代码



2.2 安装echoping
       
  1. tar xvfechoping-6.0.2.tar.gz
  2. cd echoping-6.0.2
  3. ./configure--prefix=/usr/local/echoping
  4. make && makeinstall
复制代码


2.3 安装smokeping

       
  1. cd /usr/local/src
  2. xf smokeping-2.6.11.tar.gz
  3. cd smokeping-2.6.11

  4. #exportPERL5LIB=/usr/local/smokeping/thirdparty/lib/perl5/
  5. ./setup/build-perl-modules.sh /usr/local/smokeping/thirdparty
  6. ./configure --prefix=/usr/local/smokeping
  7. gmake install
复制代码



如果./configure过程中提示找不到某些perl扩展,如下所示

  1. checking checking for perl module'Config::Grammar'... Can't locate Config/Grammar.pm in @INC (@INC contains:/usr/local/smokeping/thirdparty/lib/perl5 /usr/local/lib64/perl5 /usr/local/share/perl5/usr/lib64/perl5/vendor_perl /usr/share/perl5/vendor_perl /usr/lib64/perl5/usr/share/perl5 .) at -e line 1.
  2. BEGIN failed--compilation aborted at -e line 1.
复制代码


请使用以下命令安装对应模块:
       
perl -MCPAN -e 'install Config::Grammar'
注意:有时候需要重复安装几次才能装上模块。
注意要选择国内的的模块源,不然速度很慢。


2.4 创建相关目录和日志文件

  1. cd /usr/local/smokeping
  2. mkdir cache data var
  3. touch /var/log/smokeping.log
  4. chown apache.apache cache/ data/ var/ /var/log

  5. 因为这里的web服务使用的是httpd,所以相关文件的属主属组均为apache
复制代码


2.5 创建相关配置文件


  1. #fcgi文件
  2. cp /usr/local/smokeping/htdocs/smokeping.fcgi.dist /usr/local/smokeping/htdocs/smokeping.fcgi
  3. #主配置文件
  4. cp /usr/local/smokeping/etc/config.dist/usr/local/smokeping/etc/config
复制代码


2.6 修改配置文件

  1. #指定cgi的url地址为本机
  2. sed -i ‘s#cgiurl   = http://some.url/smokeping.cgi#cgiurl   = http://10.0.56.12/smokeping.cgi#g’/usr/local/smokeping/etc/config
  3. #指定检测的时间为60秒
  4. sed -i ‘s#step    = 300#step     = 60#g’/usr/local/smokeping/etc/config
  5. #指定ping的次数为60
  6. sed -i ‘s#pings   =20#pings    =60#g’/usr/local/smokeping/etc/config

  7. 将step和pings都设置为60表示每60秒ping60次。
复制代码


2.7 修改字符集和字体支持中文

  1. vim /usr/local/smokeping/etc/config
  2. ***Presentation ***
  3. charset= utf-8

  4. yum -y install wqy-zenhei-fonts
  5. vim/usr/local/smokeping/lib/Smokeping/Graphs.pm
  6.         my$val = 0;
  7.         formy $host (@hosts){
  8.             my ($graphret,$xs,$ys) = RRDs::graph
  9.            ("dummy",
  10.            '--start', $tasks[0][1],
  11.            '--end', $tasks[0][2],
  12.             '--font TITLE:20"WenQuanYiZen Hei Mono"',
  13.            "DEF:maxping=$cfg->{General}{datadir}${host}.rrd:median:AVERAGE",
  14.            'PRINT:maxping:MAX:%le' );
  15.            my $ERROR = RRDs::error();
复制代码

2.8 修改apache配置文件增加登录验证

       
  1. htpasswd -c /usr/local/smokeping/htdocs/htpasswd smokeping
  2. chmod 600 /usr/local/smokeping/etc/smokeping_secrets.dist
复制代码


2.9 修改httpd.conf增加smokeping的web界面

在httpd.conf末尾添加如下内容
vim /etc/httpd/conf/httpd.conf

  1. #########changed by ggvylf 2016/06/13##############
  2. Alias /cache"/usr/local/smokeping/cache/"
  3. Alias /cropper"/usr/local/smokeping/htdocs/cropper/"
  4. Alias /smokeping "/usr/local/smokeping/htdocs/smokeping.fcgi"
  5. <Directory "/usr/local/smokeping">
  6. AllowOverride None
  7. Options All
  8. AddHandler cgi-script .fcgi .cgi
  9. AllowOverride AuthConfig
  10. Order allow,deny
  11. Allow from all
  12. AuthName "Smokeping"
  13. AuthType Basic
  14. AuthUserFile /usr/local/smokeping/htdocs/htpasswd
  15. Require valid-user
  16. DirectoryIndex smokeping.fcgi
  17. </Directory>
复制代码




2.10 添加监控对象

  1. vim /usr/local/smokeping/etc/config
  2. *** Targets ***
  3. ++ Localhost
  4. menu = Localhost
  5. title = Localhost
  6. alerts = someloss
  7. #slaves = boomer slave2
  8. host = 10.0.56.12
复制代码


2.11 添加监控节点

注意:每次修改配置文件后需要重启smokeping进程

  1. /usr/local/smokeping/bin/smokeping --restart

  2. /usr/local/smokeping/bin/smokeping --reload

  3. pkill smokeping
  4. /usr/local/smokeping/bin/smokeping

  5. 监控节点样例如下,注意+是第一层,++是第二层,+++ 是第三层:
  6. vim /usr/local/smokeping/etc/config
  7. + Other
  8. menu = 三大网络监控
  9. title = 监控统计
  10. ++ dianxin
  11. menu = 电信网络监控
  12. title = 电信网络监控列表
  13. host = /Other/dianxin/dianxin-bj/Other/dianxin/dianxin-hlj /Other/dianxin/dianxin-tj  /Other/dianxin/dianxin-sc  /Other/dianxin/dianxin-sh/Other/dianxin/dianxin-gz
  14. +++ dianxin-bj
  15. menu = 北京电信
  16. title = 北京电信
  17. alerts = someloss
  18. host = 202.96.199.133
复制代码

  1. +++ dianxin-hlj
  2. menu = 黑龙江电信
  3. title = 黑龙江电信
  4. alerts = someloss
  5. host = 219.147.198.242

  6. +++ dianxin-tj
  7. menu = 天津电信
  8. title = 天津电信
  9. alerts = someloss
  10. host = 219.150.32.132

  11. +++ dianxin-sc
  12. menu = 四川电信
  13. title = 四川电信
  14. alerts = someloss
  15. host = 61.139.2.69

  16. +++ dianxin-sh
  17. menu = 上海电信
  18. title = 上海电信
  19. alerts = someloss
  20. host = 116.228.111.118

  21. +++ dianxin-gz
  22. menu = 广东电信
  23. title = 广东电信
  24. alerts = someloss
  25. host = 113.111.211.22

  26. ++ liantong
  27. menu = 联通网络监控
  28. title = 联通网络监控列表
  29. host = /Other/liantong/liantong-bj/Other/liantong/liantong-hlj /Other/liantong/liantong-tj  /Other/liantong/liantong-sc/Other/liantong/liantong-sh /Other/liantong/liantong-gz

  30. +++ liantong-bj
  31. menu = 北京联通
  32. title = 北京联通
  33. alerts = someloss
  34. host = 61.135.169.121

  35. +++ liantong-hlj
  36. menu = 黑龙江联通
  37. title = 黑龙江联通
  38. alerts = someloss
  39. host = 202.97.224.69

  40. +++ liantong-tj
  41. menu = 天津联通
  42. title = 天津联通
  43. alerts = someloss
  44. host = 202.99.96.68

  45. +++ liantong-sc
  46. menu = 四川联通
  47. title = 四川联通
  48. alerts = someloss
  49. host = 119.6.6.6

  50. +++ liantong-sh
  51. menu = 上海联通
  52. title = 上海联通
  53. alerts = someloss
  54. host = 210.22.84.3

  55. +++ liantong-gz
  56. menu = 广东联通
  57. title = 广东联通
  58. alerts = someloss
  59. host = 221.5.88.88

  60. ++ yidong
  61. menu = 移动网络监控
  62. title = 移动网络监控列表
  63. host = /Other/yidong/yidong-bj/Other/yidong/yidong-hlj /Other/yidong/yidong-tj  /Other/yidong/yidong-sc  /Other/yidong/yidong-sh/Other/yidong/yidong-gz

  64. +++ yidong-bj
  65. menu = 北京移动
  66. title = 北京移动
  67. alerts = someloss
  68. host = 221.130.33.52

  69. +++ yidong-hlj
  70. menu = 黑龙江移动
  71. title = 黑龙江移动
  72. alerts = someloss
  73. host = 211.137.241.35

  74. +++ yidong-tj
  75. menu = 天津移动
  76. title = 天津移动
  77. alerts = someloss
  78. host = 211.137.160.5

  79. +++ yidong-sc
  80. menu = 四川移动
  81. title = 四川移动
  82. alerts = someloss
  83. host = 218.201.4.3

  84. +++ yidong-sh
  85. menu = 上海移动
  86. title = 上海移动
  87. alerts = someloss
  88. host = 117.131.19.23

  89. +++ yidong-gz
  90. menu = 广东移动
  91. title = 广东移动
  92. alerts = someloss
  93. host = 211.136.192.6
复制代码

  1. smokeping会根据配置文件中配置监控节点的内容,在/usr/local/smokeping/data目录下生成对应的moniter文件夹,其下包含website子文件夹。
  2. [root@linux-node2 smokeping]# tree/usr/local/smokeping/data/
  3. /usr/local/smokeping/data/
  4. ├── Other
  5. │   ├── dianxin
  6. │   │   ├── dianxin-bj.rrd
  7. │   │   ├── dianxin-gd.rrd
  8. │   │   ├── dianxin-gs.rrd
  9. │   │   ├── dianxin-gz.rrd
  10. │   │   ├── dianxin-hlj.rrd
  11. │   │   ├── dianxin-sc.rrd
  12. │   │   ├── dianxin-sh.rrd
  13. │   │   └── dianxin-tj.rrd
  14. │   ├── liantong
  15. │   │   ├── liantong-bj.rrd
  16. │   │   ├── liantong-gz.rrd
  17. │   │   ├── liantong-hlj.rrd
  18. │   │   ├── liantong-sc.rrd
  19. │   │   ├── liantong-sh.rrd
  20. │   │   └── liantong-tj.rrd
  21. │   └── yidong
  22. │      ├── yidong-bj.rrd
  23. │      ├── yidong-gz.rrd
  24. │      ├── yidong-hlj.rrd
  25. │      ├── yidong-sc.rrd
  26. │      ├── yidong-sh.rrd
  27. │      └── yidong-tj.rrd
  28. ├── __sortercache
  29. │   └── data.FPing.storable
  30. └── Test
  31.     ├──James~boomer.rrd
  32.     ├──James.rrd
  33.     ├──James~slave2.rrd
  34.     └──Localhost.rrd
复制代码


2.12 启动服务并测试


  1. systemctl start httpd
  2. /usr/local/smokeping/bin/smokeping


  3. 在浏览器中访问
  4. http://10.0.56.12/smokeping

  5. 用户名和密码为htpasswd命令中设定用户名和密码

  6. 出现以下界面表示成功。





  7. 可以看到添加的节点的相关信息。





  8. 可以看到添加的监控点的ping状态
复制代码



附录:
更改CPAN源的方法:

  1. [root@linux-node2 smokeping-2.6.11]# cpan
  2. Sorry, we have to rerun the configuration dialogfor CPAN.pm due to
  3. some missing parameters. Configuration will bewritten to
  4. <</root/.cpan/CPAN/MyConfig.pm>>


  5. CPAN.pm requires configuration, but most of it canbe done automatically.
  6. If you answer 'no' below, you will enter aninteractive dialog for each
  7. configuration option instead.

  8. Would you like to configure as much as possibleautomatically? [yes] yes

  9. <install_help>

  10. Warning: You do not have write permission for Perllibrary directories.

  11. To install modules, you need to configure a localPerl library directory or
  12. escalate your privileges.  CPAN can help you by bootstrapping thelocal::lib
  13. module or by configuring itself to use 'sudo' (ifavailable).  You may also
  14. resolve this problem manually if you need tocustomize your setup.

  15. What approach do you want?  (Choose 'local::lib', 'sudo' or 'manual')
  16. [local::lib]

  17. Autoconfigured everything but 'urllist'.

  18. Now you need to choose your CPAN mirror sites.  You can let me
  19. pick mirrors for you, you can select them from alist or you
  20. can enter them by hand.

  21. Would you like me to automatically choose someCPAN mirror
  22. sites for you? (This means connecting to theInternet) [yes] no

  23. Would you like to pick from the CPAN mirror list?[yes] yes
  24. Found a cached mirror list as of Mon Jun 1307:01:48 2016

  25. If you'd like to just use the cached copy, answer'yes', below.
  26. If you'd like an updated copy of the mirror list,answer 'no' and
  27. I'll get a fresh one from the Internet.

  28. Shall I use the cached mirror list? [yes] yes
  29. First, pick a nearby continent and country bytyping in the number(s)
  30. in front of the item(s) you want to select. Youcan pick several of
  31. each, separated by spaces. Then, you will bepresented with a list of
  32. URLs of CPAN mirrors in the countries youselected, along with
  33. previously selected URLs. Select some of thoseURLs, or just keep the
  34. old list. Finally, you will be prompted for anyextra URLs -- file:,
  35. ftp:, or http: -- that host a CPAN mirror.

  36. You should select more than one (just in case thefirst isn't available).

  37. (1) Africa
  38. (2) Asia
  39. (3) Europe
  40. (4) North America
  41. (5) Oceania
  42. (6) South America
  43. Select your continent (or several nearbycontinents) [] 2
  44. (1) Bangladesh
  45. (2) China
  46. (3) India
  47. (4) Indonesia
  48. (5) Iran
  49. (6) Israel
  50. (7) Japan
  51. (8) Kazakhstan
  52. (9) Philippines
  53. (10) Qatar
  54. (11) Republic of Korea
  55. (12) Singapore
  56. (13) Taiwan
  57. (14) Turkey
  58. (15) Viet Nam
  59. Select your country (or several nearby countries)[] 2
  60. (1) ftp://ftp.cuhk.edu.hk/pub/packages/perl/CPAN/
  61. (2) ftp://mirrors.ustc.edu.cn/CPAN/
  62. (3) ftp://mirrors.xmu.edu.cn/CPAN/
  63. (4) http://cpan.communilink.net/
  64. (5) http://ftp.cuhk.edu.hk/pub/packages/perl/CPAN/
  65. (6) http://mirror.lzu.edu.cn/CPAN/
  66. (7) http://mirrors.163.com/cpan/
  67. (8) http://mirrors.hust.edu.cn/CPAN/
  68. (9) http://mirrors.neusoft.edu.cn/cpan/
  69. (10) http://mirrors.sohu.com/CPAN/
  70. (11) http://mirrors.ustc.edu.cn/CPAN/
  71. (12) http://mirrors.xmu.edu.cn/CPAN/
  72. (13) http://mirrors.zju.edu.cn/CPAN/
  73. Select as many URLs as you like (by number),
  74. put them on one line, separated by blanks,hyphenated ranges allowed
  75. e.g. '1 45' or '7 1-4 8' [] 7
  76. Now you can enter your own CPAN URLs by hand. Alocal CPAN mirror can be
  77. listed using a 'file:' URL like'file:///path/to/cpan/'

  78. Enter another URL or ENTER to quit: []
  79. New urllist
  80. http://mirrors.163.com/cpan/

  81. Autoconfiguration complete.

  82. Attempting to bootstrap local::lib...

  83. Writing /root/.cpan/CPAN/MyConfig.pm forbootstrap...
  84. commit: wrote '/root/.cpan/CPAN/MyConfig.pm'
  85. Fetching with LWP:
  86. http://mirrors.163.com/cpan/authors/01mailrc.txt.gz
  87. Reading'/root/.cpan/sources/authors/01mailrc.txt.gz'
  88. ............................................................................DONE
  89. Fetching with LWP:
  90. http://mirrors.163.com/cpan/modules/02packages.details.txt.gz
  91. Reading'/root/.cpan/sources/modules/02packages.details.txt.gz'
  92.   Databasewas generated on Thu, 09 Jun 2016 22:53:42 GMT
  93. .............
  94.   NewCPAN.pm version (v2.10) available.
  95.   [Currentlyrunning version is v1.9800]
  96.   You mightwant to try
  97.     install CPAN
  98.     reloadcpan
  99.   to bothupgrade CPAN.pm and run the new version without leaving
  100.   thecurrent session.


  101. ...............................................................DONE
  102. Fetching with LWP:
  103. http://mirrors.163.com/cpan/modules/03modlist.data.gz
  104. Reading'/root/.cpan/sources/modules/03modlist.data.gz'
  105. DONE
  106. Writing /root/.cpan/Metadata
  107. Running make forH/HA/HAARG/local-lib-2.000019.tar.gz
  108. Fetching with LWP:
  109. http://mirrors.163.com/cpan/authors/id/H/HA/HAARG/local-lib-2.000019.tar.gz
  110. Fetching with LWP:
  111. http://mirrors.163.com/cpan/authors/id/H/HA/HAARG/CHECKSUMS
  112. Checksum for/root/.cpan/sources/authors/id/H/HA/HAARG/local-lib-2.000019.tar.gz ok

  113.   CPAN.pm:Building H/HA/HAARG/local-lib-2.000019.tar.gz


  114. Checking if your kit is complete...
  115. Looks good
  116. Warning: prerequisite Test::More 0 not found.
  117. Generating a Unix-style Makefile
  118. Writing Makefile for local::lib
  119. Writing MYMETA.yml and MYMETA.json
  120. ---- Unsatisfied dependencies detected during ----
  121. ----     HAARG/local-lib-2.000019.tar.gz    ----
  122.     Test::More [build_requires]
  123. Running make test
  124.   Delayeduntil after prerequisites
  125. Running make install
  126.   Delayeduntil after prerequisites
  127. Tried to deactivate inactive local::lib'/root/perl5'

  128. local::lib is installed. You must now add thefollowing environment variables
  129. to your shell configuration files (or registry, ifyou are on Windows) and
  130. then restart your command line shell and CPANbefore installing modules:

  131. Use of uninitialized value $deactivating innumeric eq (==) at /usr/share/perl5/vendor_perl/local/lib.pm line 381.
  132. Use of uninitialized value $deactivating innumeric eq (==) at /usr/share/perl5/vendor_perl/local/lib.pm line 383.
  133. Use of uninitialized value$options{"interpolate"} in numeric eq (==) at /usr/share/perl5/vendor_perl/local/lib.pmline 424.
  134. Use of uninitialized value$options{"interpolate"} in numeric eq (==) at/usr/share/perl5/vendor_perl/local/lib.pm line 424.
  135. Use of uninitialized value$options{"interpolate"} in numeric eq (==) at /usr/share/perl5/vendor_perl/local/lib.pmline 424.
  136. exportPERL_LOCAL_LIB_ROOT="$PERL_LOCAL_LIB_ROOT:/root/perl5";
  137. export PERL_MB_OPT="--install_base/root/perl5";
  138. exportPERL_MM_OPT="INSTALL_BASE=/root/perl5";
  139. exportPERL5LIB="/root/perl5/lib/perl5:$PERL5LIB";
  140. export PATH="/root/perl5/bin:$PATH";

  141. Would you like me to append that to /root/.bashrcnow? [yes]


  142. commit: wrote '/root/.cpan/CPAN/MyConfig.pm'

  143. You can re-run configuration any time with 'o confinit' in the CPAN shell
  144. Terminal does not support AddHistory.

  145. cpan shell -- CPAN exploration and modulesinstallation (v1.9800)
  146. Enter 'h' for help.

  147. cpan[1]> exit
  148. Terminal does not support GetHistory.
  149. Lockfile removed.

  150. *** Remember to restart your shell before runningcpan again ***


  151. # perl -MCPAN -e shell
  152. cpan> o conf urllist unshift http://mirrors.aliyun.com/CPAN/
  153. cpan> o conf commit
复制代码



您需要登录后才可以回帖 登录 | 注册

本版积分规则

1

关注

0

粉丝

9021

主题
精彩推荐
热门资讯
网友晒图
图文推荐

Powered by Pcgho! X3.4

© 2008-2022 Pcgho Inc.