Centos6.3系统下Smokeping2.6.8安装教程

                        Centos6.3系统下Smokeping2.6.8安装教程

    smokeping是对IDC网络质量,稳定性等最好的检测工具,包括常规的 ping,dig,echoping,curl等,可以监视www服务器性能,监视dns查询性能,监视ssh性能等.


1、关闭防火墙和selinux服务

[root@YZW ~]# service iptables stop

[root@YZW ~]# setenforce 0


2、用yum安装httpd服务以及一些库文件

[root@YZW ~]# yum -y install httpd httpd-devel gcc make curl wget 

[root@YZW ~]# yum -y install libxml2-devel libpng-devel glib pango pango-devel \ freetype freetype-devel fontconfig cairo cairo-devel \ libart_lgpl libart_lgpl-dev


3、安装rrdtool

wget http://oss.oetiker.ch/rrdtool/pub/rrdtool-1.4.7.tar.gz

[root@YZW ~]# 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 \

[root@YZW wang]# tar zxvf rrdtool-1.4.7.tar.gz

[root@YZW rrdtool-1.4.7]# cd rrdtool-1.4.7

[root@YZW rrdtool-1.4.7]# ./configure --prefix=/usr/local/rrdtool

[root@YZW rrdtool-1.4.7]#make

[root@YZW rrdtool-1.4.7]#make install

[root@YZW rrdtool-1.4.7]#/usr/local/rrdtool/bin/rrdtool -v 如果出现以下信息表示安装成功了!

RRDtool 1.4.7  Copyright 1997-2010 by Tobias Oetiker 

               Compiled Jun 17 2012 09:50:49

Usage: rrdtool [options] command command_options

Valid commands: create, update, updatev, graph, graphv,  dump, restore,

              last, lastupdate, first, info, fetch, tune,

              resize, xport, flushcached

RRDtool is distributed under the Terms of the GNU General

Public License Version 2. (www.gnu.org/copyleft/gpl.html)

For more information read the RRD manpages


4、安装CGILIB

wget http://down1.chinaunix.net/distfiles/cgilib-0.5.tar.gz

[root@YZW wang]# tar zxvf cgilib-0.5.tar.gz

[root@YZW cgilib-0.5]# cd cgilib-0.5

[root@YZW cgilib-0.5]# make

[root@YZW cgilib-0.5]# cp libcgi.a /usr/local/lib

[root@YZW cgilib-0.5]# cp libcgi.a /usr/local/lib64

[root@YZW cgilib-0.5]# cp cgi.h /usr/include


5、安装FPING-2.4B_TO

wget http://oss.oetiker.ch/smokeping/pub/fping-2.4b2_to4-ipv6.tar.gz

[root@YZW wang]# tar zxvf fping.tar.gz

[root@YZW wang]# cd fping-2.4b2_to4-ipv6/

[root@YZW fping-2.4b2_to4-ipv6]# ./configure

[root@YZW fping-2.4b2_to4-ipv6]# make 

[root@YZW fping-2.4b2_to4-ipv6]# make check

[root@YZW fping-2.4b2_to4-ipv6]# make install


6、安装echoping

wget http://jaist.dl.sourceforge.net/project/echoping/echoping/6.0.0/echoping-6.0.0.tar.gz

[root@YZW ~]# yum install popt popt-devel gettext libidn libidn-devel

[root@YZW wang]# tar zxvf echoping-6.0.0.tar.gz

[root@YZW wang]# cd echoping-6.0.0

[root@YZW echoping-6.0.0]# ./configure

[root@YZW echoping-6.0.0]# make

[root@YZW echoping-6.0.0]# make install


7、安装FCGI

wget http://cpan.communilink.net/authors/id/F/FL/FLORA/FCGI-0.74.tar.gz

[root@YZW wang]# tar zxvf FCGI-0.74.tar.gz

[root@YZW wang]# cd FCGI-0.74

[root@YZW FCGI-0.74]# perl Makefile.PL

[root@YZW FCGI-0.74]# make

[root@YZW FCGI-0.74]# make install


8、安装MOD_FASTCGI,DSO

[root@YZW wang]# tar zxvf mod_fastcgi-2.4.6.tar.gz

[root@YZW wang]# cd mod_fastcgi-2.4.6

[root@YZW mod_fastcgi-2.4.6]# apxs -o mod_fastcgi.so -c *.c

[root@YZW mod_fastcgi-2.4.6]# apxs -i -a -n fastcgi .libs/mod_fastcgi.so


9、安装smokeping

wget http://oss.oetiker.ch/smokeping/pub/smokeping-2.6.8.tar.gz

[root@YZW ]#yum install cpan

[root@YZW wang]# tar zxvf smokeping-2.6.8.tar.gz

[root@YZW wang]# cd smokeping-2.6.8

[root@YZW smokeping-2.6.8]# cp /usr/local/rrdtool/lib/perl/5.10.1/x86_64-linux-thread-multi/RRDs.pm /usr/lib64/perl5

[root@YZW 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

[root@YZW smokeping-2.6.8]# ./configure --prefix=/usr/local/smokeping

执行完下面4条命令后在执行一次./configure --prefix=/usr/local/smokeping否则当你在执行/usr/bin/gmake install会报错

[root@YZW smokeping-2.6.8]# ./setup/build-perl-modules.sh /usr/local/smokeping/thirdparty

[root@YZW smokeping-2.6.8]# perl -MCPAN -e 'install CGI'D

[root@YZW smokeping-2.6.8]# perl -MCPAN -e 'install CGI::Fast '

[root@YZW smokeping-2.6.8]# perl -MCPAN -e ' Config::Grammar '

[root@YZW smokeping-2.6.8]# /usr/bin/gmake install


10、验证smokeping安装是否成功!

[root@YZW smokeping-2.6.8]# cd /usr/local/smokeping/

[root@YZW smokeping]# ls 

如果发现有以下几个目录代表你安装smokeping成功了!

bin  etc  htdocs  lib  share  thirdparty


11、创建data、var、cache、smokeing日志文件并修改权限

[root@YZW ~]# mkdir /usr/local/smokeping/data

[root@YZW ~]# mkdir /usr/local/smokeping/var

[root@YZW ~]# mkdir /usr/local/smokeping/cache

[root@YZW ~]# touch /var/log/smokeping.log

[root@YZW ~]# chown apache.apache /var/log/smokeping.log

[root@YZW ~]# chown -R apache.apache /usr/local/smokeping/


12、给smokeping配置文件修改名字

[root@YZW ~]# cp -a /usr/local/smokeping/htdocs/smokeping.fcgi.dist smokeping.fcgi

[root@YZW ~]# cp -a /usr/local/smokeping/etc/config.dist config


13、修改密码文件权限

[root@YZW ~]# chmod 600 /usr/local/smokeping/etc/smokeping_secrets.dist

[root@YZW ~]# ls -lh /usr/local/smokeping/etc/smokeping_secrets.dist


14、修改smokeping主配置文件

[root@YZW ~]# vi /usr/local/smokeping/etc/config

cgiurl   = http://192.168.1.10/smokeping.cgi    //这个是访问smokeping的路径


*** Database ***

step     = 60  60秒ping20个包

pings    = 20


*** Presentation ***

template = /usr/local/smokeping/etc/basepage.html.dist

charset=UTF-8  新添加的一行内容


+ FPing        修改fping的路径

binary = /usr/local/sbin/fping

packetsize = 2000 


[root@YZW ~]# vi /usr/local/smokeping/bin/smokeping

use lib qw(/usr/local/rrdtool/lib/perl);

use lib qw(/usr/local/smokeping/lib);


15、配置Apache服务的主配置文件

[root@YZW 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">


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@YZW ~]# htpasswd -c /usr/local/smokeping/htdocs/htpasswd admin


17、编写一个smokeping启动脚本

[root@YZW ~]# vi /etc/init.d/smokeping

#!/bin/bash

PIDFILE=/usr/local/smokeping/var/smokeping.pid

SMOKEPING=/usr/local/smokeping/bin/smokeping

ERROR=0

RUNNING=0

ARGV="$@"

if [ "x$ARGV" = "x" ] ; then

ARGS=help

fi

for ARG in $@ $ARGS

do

if [ -f $PIDFILE ] ; then

PID=`cat $PIDFILE`

if kill -0 $PID 2>/dev/null ; then

# smokeping is running

RUNNING=1

else

# smokeping not running but PID file exists => delete PID file

rm -f $PIDFILE

RUNNING=0

fi

else

# smokeping (no pid file) not running

RUNNING=0

fi

case $ARG in

start)

if [ $RUNNING -eq 0 ] ; then

if $SMOKEPING > /dev/null; then

echo "$0 $ARG: smokeping started"

else

echo "$0 $ARG: smokeping could not be started"

ERROR=1

fi

else

echo "$0 $ARG: smokeping is running with PID $PID"

ERROR=2

fi

;;

stop)

if [ $RUNNING -eq 1 ] ; then

if kill $PID ; then

echo "$0 $ARG: smokeping ($PID) stopped"

rm $PIDFILE

else

echo "$0 $ARG: smokeping could not be stopped"

ERROR=3

fi

else

echo "$0 $ARG: smokeping not running"

ERROR=4

fi

;;

restart)

if [ $RUNNING -eq 1 ] ; then

if $SMOKEPING --restart > /dev/null; then

echo "$0 $ARG: smokeping restarted"

else

echo "$0 $ARG: smokeping could not be started"

ERROR=5

fi

else

$0 start

fi

;;

strace_debug)

rm -f /tmp/strace_smokeping

if [ $RUNNING -eq 1 ] ; then

if strace -o/tmp/strace_smokeping $SMOKEPING --restart >/dev/null; then

echo "$0 $ARG: smokeping restarted with strace debug in /tmp/strace_smokeping"

else

echo "$0 $ARG: smokeping strace debug could not be started"

ERROR=6

fi

else

if strace -o/tmp/strace_smokeping $SMOKEPING >/dev/null; then

echo "$0 $ARG: smokeping started with strace debug in /tmp/strace_smokeping"

else

echo "$0 $ARG: smokeping strace debug could not be started"

ERROR=7

fi

fi

;;

status)

if [ $RUNNING -eq 1 ] ; then

echo "$0 $ARG: smokeping is running with PID ($PID)"

else

echo "$0 $ARG: smokeping is not running"

fi

;;

*)

echo "usage: $0 (start|stop|restart|status|strace_debug|help)"

cat 

start - start smokeping

stop - stop smokeping

restart - restart smokeping if running or start if not running

status - show status if smokeping is running or not

help - this screen

EOF

;;

esac

done

exit $ERROR



17、给脚本执行权限

[root@YZW ~]# chmod +x /etc/init.d/smokeping


18、检查smokeping配置文件是否有错误,启动smokeping、httpd服务

[root@YZW ~]# service httpd retsart

[root@YZW ~]# /usr/local/smokeping/bin/smokeping --check


[root@YZW ~]# echo "/usr/local/smokeping/bin/smokeping --logfile=/var/log/smokeping.log 2>&1 &" >> /etc/rc.local


19、访问smokeping页面

http://192.168.1.10/smokeping

wKioL1P3PN7Qu6p1AAFNNZz0qPs430.jpg20、简单的介绍下smokeping主配置文件内容的用途

General 属于基本配置。需要注意的是imgcache和imgurl这两个参数和apache配置相关联,如果配置不正确的话,打开web的时候图片会显示不出来我这里边的路径是默认的,如果你改过路径这里边的路径也需要改动。

wKioL1TM6MWRnFiOAAI1RBQf7zs061.jpg

Alerts是属于报警设置

wKioL1P3P0Lwg2dyAAEZXoTny-8952.jpg

Database是 RRD数据库配置,step和pings这两个参数要在启动smokeping之前配置好,如果在smokeping启动后再配置这两个参数,需要把原来的rrd文件都删除,然后再启动smokeping才可以。step=30pings=20 是每300s内执行20次ping的动作.

wKiom1P3QEmB7_9PAAC-VwgEcNA831.jpg

Presentation 是关于网络状态的一些配置和解释,基本不需要更改

wKioL1P3Qp2iYnM8AAGY9YvjNMM806.jpg

Probes指针配置,确保fping路径正确,packetsize参数是设置Fping值的。

wKioL1P3QxHBy12gAABRRmjSqH0096.jpg

Targets配置你所监控的对象

wKiom1P3RE6wYmcMAAH6R-gQU6U755.jpg

21、安装Smokeping遇到的问题总结

以下这几个问题都是因为本人操作失误造成的算不上什么问题,如果大家细心的话这些问题都是可以避免的。

(1)smokeping安装完后http://192.168.1.10/smokeping访问smokeping时一直提示404错误?

原因是在我执行cp -a /usr/local/smokeping/htdocs/smokeping.fcgi.cgi smokeping.fcgi时名字没有改变所以一直报错,解决办法是进入该目录修改名字即可。

(2)启动smokeping时提示ERROR: slave 'boomer' is not defined in the '*** Slaves ***' section?

解决办法是vi /usr/local/smokeping/etc/config在slaves中添加一个节点问题解决。

(3)Smokeping安装成功后有图但是没有数据?

检查smokeping以下两个主配置文件有没有生成rrd和png文件

/usr/local/smokeping/data/Test  rrd生成文件路径

/usr/local/smokeping/cache/Test/ cache和Test 目录下查看是否有png文件

(4)访问Smokeping时报500错误

wKioL1U4qoqzuIIDAAFvMTsY0H0290.jpg问题原因是因为Selinux没有关闭造成的,配置文件修改必须重启服务器生效!

[root@YZW ~]# vi /etc/sysconfig/selinux  

SELINUX=disabled

[root@YZW ~]# setforce 0 临时修改生效

[root@YZW ~]# getenforce 查看结果

Permissive


查看smokeping主目录权限

ls -lh /usr/local/smokeping/


查看你所监控的设备是否正常,监控本身的selinux和iptables是否关闭


在smokeping主配置文件里边添加监控设备的时候要以以下格式否则会造成出图不出数据的情况而且标题目录必须是英文。

+ qitawangluo

++ dianxin-hlj

+++ dianxin-zongliebiao

我这里没有显示数据的原因是因为我把我添加的监控节点添加到了Targets的一级目录里边去了,应该单独另起一个一级目录然后二级、三级还有一个我写成中文了!

正常的图如下:

wKiom1P3Sa-hvYEzAALRNU0DtJQ781.jpg

Smokeping安装以及配置到此为止,对于初次安装Smokeping的希望可以帮到大家!




















你可能感兴趣的:(centos6.3,安装教程,Smokeping2.6.8)