Smokeping安装教程

2022-11-17,

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服务以及一些库文件

 # 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

 [root@LNMP wang]# tar zxvf rrdtool-1.4..tar.gz
[root@LNMP rrdtool-1.4.]# cd rrdtool-1.4.
[root@LNMP rrdtool-1.4.]# ./configure --prefix=/usr/local/rrdtool
[root@LNMP rrdtool-1.4.]#make
[root@LNMP rrdtool-1.4.]#make install
[root@LNMP rrdtool-1.4.]#/usr/local/rrdtool/bin/rrdtool -v
RRDtool 1.4. Copyright - by Tobias Oetiker
.........(省略N行)......

4、安装CGILIB

 [root@LNMP wang]# tar zxvf cgilib-0.5.tar.gz
[root@LNMP cgilib-0.5]# cd cgilib-0.5
[root@LNMP cgilib-0.5]# make
[root@LNMP cgilib-0.5]# cp libcgi.a /usr/local/lib64
[root@LNMP cgilib-0.5]# cp cgi.h /usr/include

5、安装FPING-2.4B_TO

 [root@LNMP wang]# tar zxvf fping.tar.gz
[root@LNMP wang]# cd fping-.4b2_to4-ipv6/
[root@LNMP fping-.4b2_to4-ipv6]# ./configure
[root@LNMP fping-.4b2_to4-ipv6]# make
[root@LNMP fping-.4b2_to4-ipv6]# make check
[root@LNMP fping-.4b2_to4-ipv6]# make install

6、安装echoping

 [root@LNMP ~]# yum install popt popt-devel gettext libidn libidn-devel
[root@LNMP wang]# tar zxvf echoping-6.0..tar.gz
[root@LNMP wang]# cd echoping-6.0.
[root@LNMP echoping-6.0.]# ./configure
[root@LNMP echoping-6.0.]# make
[root@LNMP echoping-6.0.]# make install

7、安装FCGI

 [root@LNMP wang]# tar zxvf FCGI-0.74.tar.gz
[root@LNMP wang]# cd FCGI-0.74
[root@LNMP FCGI-0.74]# perl Makefile.PL
[root@LNMP FCGI-0.74]# make
[root@LNMP FCGI-0.74]# make install

8、安装MOD_FASTCGI

 [root@LNMP wang]# tar zxvf mod_fastcgi-2.4..tar.gz
[root@LNMP wang]# cd mod_fastcgi-2.4.
[root@LNMP mod_fastcgi-2.4.]# apxs -o mod_fastcgi.so -c *.c
[root@LNMP mod_fastcgi-2.4.]# apxs -i -a -n fastcgi .libs/mod_fastcgi.so

9、安装smokeping

 [root@LNMP ]#yum install cpan
[root@LNMP wang]# tar zxvf smokeping-2.6..tar.gz
[root@LNMP wang]# cd smokeping-2.6.
[root@LNMP smokeping-2.6.]# cp /usr/local/rrdtool/lib/perl/5.10./x86_64-linux-thread-multi/RRDs.pm /usr/lib64/perl5
[root@LNMP smokeping-2.6.]# cp /usr/local/rrdtool/lib/perl/5.10./x86_64-linux-thread-multi/auto/RRDs/RRDs.so /usr/lib64/perl5
[root@LNMP smokeping-2.6.]# ./configure --prefix=/usr/local/smokeping
**可以用 && 依次执行4条命令(半小时)后再执行一次./configure --prefix=/usr/local/smokeping
[root@LNMP smokeping-2.6.]# ./setup/build-perl-modules.sh /usr/local/smokeping/thirdparty
[root@LNMP smokeping-2.6.]# perl -MCPAN -e 'install CGI'
[root@LNMP smokeping-2.6.]# perl -MCPAN -e 'install CGI::Fast'
[root@LNMP smokeping-2.6.]# perl -MCPAN -e 'Config::Grammar'
[root@LNMP smokeping-2.6.]# /usr/bin/gmake install

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

[root@LNMP smokeping-2.6.]# 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  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秒ping20个包
pings =
*** Presentation ***
template = /usr/local/smokeping/etc/basepage.html.dist
charset=UTF- 新添加的一行内容
+ FPing 修改fping的路径(whereis fping)
binary = /usr/local/sbin/fping
packetsize =
末行添加
++ CQDX menu = CQDX
title = CQDX
alerts = someloss
#slaves = boomer slave2
host = 61.128.128.68
[root@LNMP ~]# vi /usr/local/smokeping/bin/smokeping
注释#“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
在# 加入'--font TITLE:20:"WenQuanYi Zen Hei Mono"',
if ($mode =~ /[anc]/){
my $val = ;
for my $host (@hosts){
my ($graphret,$xs,$ys) = RRDs::graph
("dummy",
'--start', $tasks[][],
'--end', $tasks[][],
'--font TITLE:20:"WenQuanYi Zen Hei Mono"',
"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 -host 127.0.0.1: -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启动脚本(可省略)

 #!/bin/bash
PIDFILE=/usr/local/smokeping/var/smokeping.pid
SMOKEPING=/usr/local/smokeping/bin/smokeping
ERROR=
RUNNING=
ARGV="$@"
if [ "x$ARGV" = "x" ] ; then
ARGS=help
fi
for ARG in $@ $ARGS
do
if [ -f $PIDFILE ] ; then
PID=`cat $PIDFILE`
if kill - $PID >/dev/null ; then
# smokeping is running
RUNNING=
else
# smokeping not running but PID file exists => delete PID file
rm -f $PIDFILE
RUNNING=
fi
else
# smokeping (no pid file) not running
RUNNING=
fi
case $ARG in
start)
if [ $RUNNING -eq ] ; then
if $SMOKEPING > /dev/null; then
echo "$0 $ARG: smokeping started"
else
echo "$0 $ARG: smokeping could not be started"
ERROR=
fi
else
echo "$0 $ARG: smokeping is running with PID $PID"
ERROR=
fi
;;
stop)
if [ $RUNNING -eq ] ; then
if kill $PID ; then
echo "$0 $ARG: smokeping ($PID) stopped"
rm $PIDFILE
else
echo "$0 $ARG: smokeping could not be stopped"
ERROR=
fi
else
echo "$0 $ARG: smokeping not running"
ERROR=
fi
;;
restart)
if [ $RUNNING -eq ] ; then
if $SMOKEPING --restart > /dev/null; then
echo "$0 $ARG: smokeping restarted"
else
echo "$0 $ARG: smokeping could not be started"
ERROR=
fi
else
$ start
fi
;;
strace_debug)
rm -f /tmp/strace_smokeping
if [ $RUNNING -eq ] ; 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=
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=
fi
fi
;;
status)
if [ $RUNNING -eq ] ; 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 <<EOF
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

添加执行权限

# 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 -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安装教程的相关教程结束。

《Smokeping安装教程.doc》

下载本文的Word格式文档,以方便收藏与打印。