smokeping-2.6.8 安装

smokeping 2.4.2 的参照这篇文档就好了,可以把 chroot 安装在他默认的地方,这样需要修改的地方就大大减少了。

下面这个是 2.6.8 的记录,简单记录一下步骤,选择性的解释:
# rpm -ivh http://apt.sw.be/redhat/el5/en/x86_64/rpmforge/RPMS/rpmforge-release-0.3.6-1.el5.rf.x86_64.rp
# rpm -ivh http://dl.fedoraproject.org/pub/epel/6/x86_64/epel-release-6-7.noarch.rpm
# yum makecache
# yum install rrdtool fping  echoping curl dig
# yum install perl  perl-CPAN rrdtool-perl

# cpan
> install FCGI
> install FCGI::ProcManager
> install CGI::Fast
> install Config::Grammar
> install Digest::HMAC_MD5
> install Net::Telnet
> install Net::OpenSSH
> install Net::SNMP
> install Net::DNS
> install Getopt::Long
> install IO::All
> install Socket
> install LWP

# wget http://oss.oetiker.ch/smokeping/pub/smokeping-2.6.8.tar.gz -O /usr/local/src/smokeping-2.6.8.tar.gz ; cd /usr/local/src/
# tar zxvf smokeping-2.6.8.tar.gz
# cd smokeping-2.6.8
# ./configure --prefix=/usr/local/smokeping
# gmake install

在进行编译的时候,会出现一些如下的信息,有助于 debug,可以留意。

checking checking for gnu make availablility… /usr/bin/gmake is GNU make
checking checking for perl module 'RRDs'… Ok
checking checking for perl module 'FCGI'… Ok
checking checking for perl module 'CGI'… Ok
checking checking for perl module 'CGI::Fast'… Ok
checking checking for perl module 'Config::Grammar'… Failed
checking checking for perl module 'Digest::HMAC_MD5'… Ok
checking checking for perl module 'LWP'… Ok

上面安装 cpan 的步骤其实在源文件里面已经有了:
# pwd
/usr/local/src/smokeping-2.6.8/setup
# ll build-perl-modules.sh
-rwxr-xr-x. 1 jaseywang jaseywang 287 Oct  5  2011 build-perl-modules.sh

# cd /usr/local/smokeping/etc
# for foo in *.dist; do cp $foo `basename $foo .dist`; done

or
# find . -name '*.dist' -print -execdir sh -c 'mv {} $(basename {} .dist)' \;
# cd ..
# mkdir -p ./{data,cache,var}
# chmod -R 777 cache
# chmod 600 ./etc/smokeping_secrets
# ln -s htdocs/cropper/

检查语法:
# /usr/local/smokeping/bin/smokeping --check

开启 debug 模式,运行完退出:
# /usr/local/smokeping/bin/smokeping --config=/usr/local/smokeping/etc/config --debug

启动,将 log 输出至 smokeping.log 文件中:
# /usr/local/smokeping/bin/smokeping --config=/usr/local/smokeping/etc/config --logfile=/usr/local/logs/smokeping.log

init 文件:
# wget http://oss.oetiker.ch/smokeping/pub/contrib/smokeping-start-script -O /etc/init.d/smokeping
# chmod a+x /etc/init.d/smokeping
# sed s@PIDFILE=/usr/local/smokeping/etc/data/smokeping.pid@PIDFILE=/usr/local/smokeping/var/smokeping.pid@ /etc/init.d/smokeping

nginx 部分:
# wget http://code.google.com/p/autonagios/source/browse/trunk/autonagios-20100103/files/nginx-fcgi.txt -O /etc/nginx-fcgi
# chmod a+x /etc/nginx-fcgi
# /etc/nginx-fcgi -l /var/log/nginx-fcgi.log -pid /var/run/nginx-fcgi.pid -S /var/run/nginx-fcgi.sock
# cd /usr/local/nginx
# cat conf/nginx.conf


    server {
        listen       80;
        server_name  localhost;
        root   /usr/local/smokeping/;

        location ~ .*\.cgi$ {
                     root   /usr/local/smokeping/htdocs/;
                     fastcgi_pass unix:/var/run/nginx-fcgi.sock;
                     fastcgi_index   index.cgi;
                     include fastcgi_params;
                     fastcgi_param   SCRIPT_FILENAME /usr/local/smokeping/htdocs$fastcgi_script_name;
             }


# ./sbin/nginx  -t -c conf/nginx.conf
# ./sbin/nginx -s reload
# curl ip/smokeping.cgi

上面那个是 RH 的版本,Ubuntu 的很简单,以 10.04 为例,官方还是 2.3.6-5 的版本,自己下 deb 包安装:
# wget http://mirrors.163.com/ubuntu/pool/universe/s/smokeping/smokeping_2.6.8-1.1_all.deb
# apt-get install libcgi-fast-perl libconfig-grammar-perl libdigest-hmac-perl libfcgi-perl libio-socket-inet6-perl libjs-cropper libperl5.10 librrd4 librrds-perl libsnmp-session-perl libsocket6-perl perl perl-base perl-modules ttf-dejavu ttf-dejavu-extra libperl5.10 perl perl-base perl-modules fping
# dpkg -i smokeping_2.6.8-1.1_all.deb

修改下 config.d/ 下面的文件,先检查一下有没有语法错误,再 debug 一遍,最后以 daemon 的方式启动:
# smokeping  --config /etc/smokeping/config --check
# smokeping  --config /etc/smokeping/config --debug
# smokeping  --config /etc/smokeping/config --debug-daemon

关于 smokeping 的相关语法,官方文档说的很详细,不在此记录。这里有个别人写的安装脚本,比较老,对目前的版本不是很适合,不过可以供参考学习。

SP 相比其他,最突出的就是其 alert 做的很好,其阈值的设置可以具体到触发几次,丢包几次,丢包率达到多少的粒度去报警,具体的看配置文件的里面的几个注释应该就能懂了。每次修改完,记得使用 –check 检查一遍有没有语法错误再启动。

ref:
http://tomoconnor.eu/blogish/smokeping-nginx/
http://blog.icelandic.net/2011/07/17/smokeping-on-nginx/
http://ai.net.nz/gettinghelp/how-do-i/centos-servers/67-5-packages-04-smokeping.html
http://www.howtoforge.com/monitoring-network-latency-with-smokeping-ubuntu-9.04