首页 > 代码库 > Smokeping安装教程
Smokeping安装教程
Smokeping安装教程
#Smokeping2.6.8安装教程
#2016.3.6 改编v1.0
#Linux运维技术交流 347163978
环境
CentOS release 6.4 (Final)
kernel 2.6.32-358.el6.x86_64 x86_64
软件下载
http://pan.baidu.com/s/1kTTbnpH
ftp://195.220.108.108/linux/epel/6/x86_64/
1、换源163和epel
http://user.qzone.qq.com/1261507525/blog/1452949535
2、用yum安装httpd服务以及一些库文件
1 # yum -y install httpd httpd-devel gcc gcc-c++ make curl wget libxml2-devel libpng-devel glib pango pango-devel freetype freetype-devel fontconfig cairo cairo-devel libart_lgpl libart_lgpl-devel perl perl-Net-Telnet perl-Net-DNS perl-LDAP perl-libwww-perl perl-IO-Socket-SSL perl-Socket6 perl-CGI-SpeedyCGI perl-FCGI perl-Time-HiRes perl-ExtUtils-MakeMaker
3、安装rrdtool
1 [root@LNMP wang]# tar zxvf rrdtool-1.4.7.tar.gz 2 [root@LNMP rrdtool-1.4.7]# cd rrdtool-1.4.7 3 [root@LNMP rrdtool-1.4.7]# ./configure --prefix=/usr/local/rrdtool 4 [root@LNMP rrdtool-1.4.7]#make 5 [root@LNMP rrdtool-1.4.7]#make install 6 [root@LNMP rrdtool-1.4.7]#/usr/local/rrdtool/bin/rrdtool -v 7 RRDtool 1.4.7 Copyright 1997-2010 by Tobias Oetiker
.........(省略N行)......
4、安装CGILIB
1 [root@LNMP wang]# tar zxvf cgilib-0.5.tar.gz 2 [root@LNMP cgilib-0.5]# cd cgilib-0.5 3 [root@LNMP cgilib-0.5]# make 4 [root@LNMP cgilib-0.5]# cp libcgi.a /usr/local/lib64 5 [root@LNMP cgilib-0.5]# cp cgi.h /usr/include
5、安装FPING-2.4B_TO
1 [root@LNMP wang]# tar zxvf fping.tar.gz 2 [root@LNMP wang]# cd fping-2.4b2_to4-ipv6/ 3 [root@LNMP fping-2.4b2_to4-ipv6]# ./configure 4 [root@LNMP fping-2.4b2_to4-ipv6]# make 5 [root@LNMP fping-2.4b2_to4-ipv6]# make check 6 [root@LNMP fping-2.4b2_to4-ipv6]# make install
6、安装echoping
1 [root@LNMP ~]# yum install popt popt-devel gettext libidn libidn-devel 2 [root@LNMP wang]# tar zxvf echoping-6.0.0.tar.gz 3 [root@LNMP wang]# cd echoping-6.0.0 4 [root@LNMP echoping-6.0.0]# ./configure 5 [root@LNMP echoping-6.0.0]# make 6 [root@LNMP echoping-6.0.0]# make install
7、安装FCGI
1 [root@LNMP wang]# tar zxvf FCGI-0.74.tar.gz 2 [root@LNMP wang]# cd FCGI-0.74 3 [root@LNMP FCGI-0.74]# perl Makefile.PL 4 [root@LNMP FCGI-0.74]# make 5 [root@LNMP FCGI-0.74]# make install
8、安装MOD_FASTCGI
1 [root@LNMP wang]# tar zxvf mod_fastcgi-2.4.6.tar.gz 2 [root@LNMP wang]# cd mod_fastcgi-2.4.6 3 [root@LNMP mod_fastcgi-2.4.6]# apxs -o mod_fastcgi.so -c *.c 4 [root@LNMP mod_fastcgi-2.4.6]# apxs -i -a -n fastcgi .libs/mod_fastcgi.so
9、安装smokeping
1 [root@LNMP ]#yum install cpan 2 [root@LNMP wang]# tar zxvf smokeping-2.6.8.tar.gz 3 [root@LNMP wang]# cd smokeping-2.6.8 4 [root@LNMP smokeping-2.6.8]# cp /usr/local/rrdtool/lib/perl/5.10.1/x86_64-linux-thread-multi/RRDs.pm /usr/lib64/perl5 5 [root@LNMP smokeping-2.6.8]# cp /usr/local/rrdtool/lib/perl/5.10.1/x86_64-linux-thread-multi/auto/RRDs/RRDs.so /usr/lib64/perl5 6 [root@LNMP smokeping-2.6.8]# ./configure --prefix=/usr/local/smokeping 7 **可以用 && 依次执行4条命令(半小时)后再执行一次./configure --prefix=/usr/local/smokeping 8 [root@LNMP smokeping-2.6.8]# ./setup/build-perl-modules.sh /usr/local/smokeping/thirdparty 9 [root@LNMP smokeping-2.6.8]# perl -MCPAN -e ‘install CGI‘ 10 [root@LNMP smokeping-2.6.8]# perl -MCPAN -e ‘install CGI::Fast‘ 11 [root@LNMP smokeping-2.6.8]# perl -MCPAN -e ‘Config::Grammar‘ 12 [root@LNMP smokeping-2.6.8]# /usr/bin/gmake install
10、验证smokeping安装是否成功!
[root@LNMP smokeping-2.6.8]# cd /usr/local/smokeping/ [root@LNMP smokeping]# ls bin etc htdocs lib share thirdparty
11、创建data、var、cache、smokeing日志文件并修改权限
[root@localhost smokeping]# mkdir -p data var cache [root@LNMP ~]# touch /var/log/smokeping.log [root@LNMP ~]# chown apache.apache /var/log/smokeping.log [root@LNMP ~]# chown -R apache.apache /usr/local/smokeping/
12、给smokeping配置文件修改名字
[root@LNMP smokeping~]# cp -a htdocs/smokeping.fcgi.dist htdocs/smokeping.fcgi [root@LNMP smokeping~]# cp -a etc/config.dist etc/config
13、修改密码文件权限
# chmod 600 etc/smokeping_secrets.dist # ll etc/smokeping_secrets.dist
14、修改smokeping主配置文件
[root@LNMP ~]# vi /usr/local/smokeping/etc/config cgiurl = http://x.x.x.x/smokeping.cgi //这个是访问smokeping的路径 *** Database *** step = 60 60秒ping20个包 pings = 20 *** Presentation *** template = /usr/local/smokeping/etc/basepage.html.dist charset=UTF-8 新添加的一行内容 + FPing 修改fping的路径(whereis fping) binary = /usr/local/sbin/fping packetsize = 1024 末行添加 ++ CQDX menu = CQDX title = CQDX alerts = someloss #slaves = boomer slave2 host = 61.128.128.68 [root@LNMP ~]# vi /usr/local/smokeping/bin/smokeping 注释#8“use lib qw(); # PERL5LIB”并插入 use lib qw(/usr/local/rrdtool/lib/perl); use lib qw(/usr/local/smokeping/lib); 支持中文防止乱码 #yum -y install wqy-zenhei-fonts #vim /usr/local/smokeping/lib/Smokeping/Graphs.pm 在#148 加入‘--font TITLE:20:"WenQuanYi Zen Hei Mono"‘, 141 if ($mode =~ /[anc]/){ 142 my $val = 0; 143 for my $host (@hosts){ 144 my ($graphret,$xs,$ys) = RRDs::graph 145 ("dummy", 146 ‘--start‘, $tasks[0][1], 147 ‘--end‘, $tasks[0][2], 148 ‘--font TITLE:20:"WenQuanYi Zen Hei Mono"‘, 149 "DEF:maxping=$cfg->{General}{datadir}${host}.rrd:median:AVERAGE",
15、配置Apache服务的主配置文件
[root@LNMP ~]# yum -y install php-fpm [root@LNMP ~]# vim /etc/httpd/conf.d/fastcgi.php DirectoryIndex index.html index.shtml index.cgi index.php AddHandler php5-fcgi .php Action php5-fcgi /php5-fcgi Alias /php5-fcgi /var/www/cgi-bin/php5-fcgi FastCgiExternalServer /var/www/cgi-bin/php5-fcgi -idle-timeout 60 -host 127.0.0.1:9000 -pass-header Authorization [root@LNMP local]# vi /etc/httpd/conf/httpd.conf 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/htdocs"> 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>
16、创建登录smokeping的账户并设置密码(可省略)
[root@LNMP ~]# htpasswd -c /usr/local/smokeping/htdocs/htpasswd admin
17、编写一个smokeping启动脚本(可省略)
1 #!/bin/bash 2 PIDFILE=/usr/local/smokeping/var/smokeping.pid 3 SMOKEPING=/usr/local/smokeping/bin/smokeping 4 ERROR=0 5 RUNNING=0 6 ARGV="$@" 7 if [ "x$ARGV" = "x" ] ; then 8 ARGS=help 9 fi 10 for ARG in $@ $ARGS 11 do 12 if [ -f $PIDFILE ] ; then 13 PID=`cat $PIDFILE` 14 if kill -0 $PID 2>/dev/null ; then 15 # smokeping is running 16 RUNNING=1 17 else 18 # smokeping not running but PID file exists => delete PID file 19 rm -f $PIDFILE 20 RUNNING=0 21 fi 22 else 23 # smokeping (no pid file) not running 24 RUNNING=0 25 fi 26 case $ARG in 27 start) 28 if [ $RUNNING -eq 0 ] ; then 29 if $SMOKEPING > /dev/null; then 30 echo "$0 $ARG: smokeping started" 31 else 32 echo "$0 $ARG: smokeping could not be started" 33 ERROR=1 34 fi 35 else 36 echo "$0 $ARG: smokeping is running with PID $PID" 37 ERROR=2 38 fi 39 ;; 40 stop) 41 if [ $RUNNING -eq 1 ] ; then 42 if kill $PID ; then 43 echo "$0 $ARG: smokeping ($PID) stopped" 44 rm $PIDFILE 45 else 46 echo "$0 $ARG: smokeping could not be stopped" 47 ERROR=3 48 fi 49 else 50 echo "$0 $ARG: smokeping not running" 51 ERROR=4 52 fi 53 ;; 54 restart) 55 if [ $RUNNING -eq 1 ] ; then 56 if $SMOKEPING --restart > /dev/null; then 57 echo "$0 $ARG: smokeping restarted" 58 else 59 echo "$0 $ARG: smokeping could not be started" 60 ERROR=5 61 fi 62 else 63 $0 start 64 fi 65 ;; 66 strace_debug) 67 rm -f /tmp/strace_smokeping 68 if [ $RUNNING -eq 1 ] ; then 69 if strace -o/tmp/strace_smokeping $SMOKEPING --restart >/dev/null; then 70 echo "$0 $ARG: smokeping restarted with strace debug in /tmp/strace_smokeping" 71 else 72 echo "$0 $ARG: smokeping strace debug could not be started" 73 ERROR=6 74 fi 75 else 76 if strace -o/tmp/strace_smokeping $SMOKEPING >/dev/null; then 77 echo "$0 $ARG: smokeping started with strace debug in /tmp/strace_smokeping" 78 else 79 echo "$0 $ARG: smokeping strace debug could not be started" 80 ERROR=7 81 fi 82 fi 83 ;; 84 status) 85 if [ $RUNNING -eq 1 ] ; then 86 echo "$0 $ARG: smokeping is running with PID ($PID)" 87 else 88 echo "$0 $ARG: smokeping is not running" 89 fi 90 ;; 91 *) 92 echo "usage: $0 (start|stop|restart|status|strace_debug|help)" 93 cat <<EOF 94 start - start smokeping 95 stop - stop smokeping 96 restart - restart smokeping if running or start if not running 97 status - show status if smokeping is running or not 98 help - this screen 99 EOF 100 ;; 101 esac 102 done 103 exit $ERROR
添加执行权限
# chmod +x /etc/init.d/smokeping
18、解决目录安全并启动smokeping、httpd服务
[root@LNMP local]# chcon -R -t httpd_sys_content_t /usr/local/smokeping/ [root@LNMP local]#iptables -I INPUT -p tcp --dport 80 -j ACCEPT 检测smokeping配置 [root@LNMP ~]# /usr/local/smokeping/bin/smokeping --check [root@LNMP ~]# echo "/usr/local/smokeping/bin/smokeping --logfile=/var/log/smokeping.log 2>&1 &" >> /etc/rc.local #/etc/init.d/smokeping restart # service httpd restart # service php-fpm restart
19、访问smokeping页面
http://x.x.x.x/smokeping
Smokeping安装教程
声明:以上内容来自用户投稿及互联网公开渠道收集整理发布,本网站不拥有所有权,未作人工编辑处理,也不承担相关法律责任,若内容有误或涉及侵权可进行投诉: 投诉/举报 工作人员会在5个工作日内联系你,一经查实,本站将立刻删除涉嫌侵权内容。