CentoOS下Smokeping的安装与配置
时间:2015-09-05 15:00 来源:blog.51cto.com 作者:huawei306
由于公司需要监控机房的网络质量无奈只能安装smokeping,鉴于网上的教程大多都是老版本的,所以今天我就讲诉一下我在centos上安装新版本的过程,有些得不好的地方还请大家多多原谅。
以下所有安装包请到这里下载:http://download.chinaunix.net/
1.先关闭selinux和清空iptables
vim /etc/selinux/config
SELINUX=disabled
iptables -F
2.更改国内比较快的yum源,我修改为ustc的,个人感觉他比较快。
cd /etc/yum.repos.d/
mv CentOS-Base.repo CentOS-Base.repo.bak
vim CentOS-Base.repo
# CentOS-Base.repo
#
# The mirror system uses the connecting IP address of the client and the
# update status of each mirror to pick mirrors that are updated to and
# geographically close to the client. You should use this for CentOS updates
# unless you are manually picking other mirrors.
#
# If the mirrorlist= does not work for you, as a fall back you can try the
# remarked out baseurl= line instead.
#YunVN.com
#
[base]
name=CentOS-$releasever - Base - mirrors.ustc.edu.cn
baseurl=http://mirrors.ustc.edu.cn/centos/$releasever/os/$basearch/
#mirrorlist=http://mirrorlist.centos.org/?release=$releasever&arch=$basearch&repo=os
gpgcheck=1
gpgkey=http://mirrors.ustc.edu.cn/centos/RPM-GPG-KEY-CentOS-6
#released updates
[updates]
name=CentOS-$releasever - Updates - mirrors.ustc.edu.cn
baseurl=http://mirrors.ustc.edu.cn/centos/$releasever/updates/$basearch/
#mirrorlist=http://mirrorlist.centos.org/?release=$releasever&arch=$basearch&repo=updates
gpgcheck=1
gpgkey=http://mirrors.ustc.edu.cn/centos/RPM-GPG-KEY-CentOS-6
#additional packages that may be useful
[extras]
name=CentOS-$releasever - Extras - mirrors.ustc.edu.cn
baseurl=http://mirrors.ustc.edu.cn/centos/$releasever/extras/$basearch/
#mirrorlist=http://mirrorlist.centos.org/?release=$releasever&arch=$basearch&repo=extras
gpgcheck=1
gpgkey=http://mirrors.ustc.edu.cn/centos/RPM-GPG-KEY-CentOS-6
#additional packages that extend functionality of existing packages
[centosplus]
name=CentOS-$releasever - Plus - mirrors.ustc.edu.cn
baseurl=http://mirrors.ustc.edu.cn/centos/$releasever/centosplus/$basearch/
#mirrorlist=http://mirrorlist.centos.org/?release=$releasever&arch=$basearch&repo=centosplus
gpgcheck=1
enabled=0
gpgkey=http://mirrors.ustc.edu.cn/centos/RPM-GPG-KEY-CentOS-6
#contrib - packages by Centos Users
[contrib]
name=CentOS-$releasever - Contrib - mirrors.ustc.edu.cn
baseurl=http://mirrors.ustc.edu.cn/centos/$releasever/contrib/$basearch/
#mirrorlist=http://mirrorlist.centos.org/?release=$releasever&arch=$basearch&repo=contrib
gpgcheck=1
enabled=0
gpgkey=http://mirrors.ustc.edu.cn/centos/RPM-GPG-KEY-CentOS-6
ok,准备工作已做好,下面我们开始安装了。
3.安装环境所需要的yum包
yum -y install libxml2-devel libpng-devel glib pango pango-devel freetypefreetype-devel fontconfig cairo cairo-devel libart_lgpl libart_lgpl-devel perl perl-Net-Telnet perl-Net-DNSperl-LDAP perl-libwww-perl perl-RadiusPerl perl-IO-Socket-SSL perl-Socket6perl-CGI-SpeedyCGI rrdtool-perl
4.安装rrdtool
wget http://down1.chinaunix.net/distfiles/rrdtool-1.4.5.tar.gz
tar zxvf rrdtool-1.4.7.tar.gz
cd rrdtool-1.4.7
./configure --prefix=/usr/local/rrdtool
make && make install
5.安装smokeping依赖的软件
【cgilib】
wget http://down1.chinaunix.net/distfiles/cgilib-0.5.tar.gz
tar zxvf cgilib-0.5.tar.gz
cd cgilib-0.5
make
cp libcgi.a /usr/local/lib
cp cgi.h /usr/include
【fping-2.4b2_to】
tar zxvf fping.tar.gz
cd fping-2.4b2_to
./configure
make
make check
make install
whereis fping
fping: /usr/local/sbin/fping
5.安装 echoping
wget http://down1.chinaunix.net/distfiles/echoping-5.2.0.tar.gz
tar zxvf echoping-5.2.0.tar.gz
cd echoping-5.2.0
报错信息:
./configure
configure: error: Popt libraries is required
yum install popt-devel gettext
./configure
echo $?
configure: error: GNU --without-libidn
./configure --without-libidn
echo $?
make && make install
6.安装smokeping
wget http://oss.oetiker.ch/smokeping/pub/smokeping-2.6.8.tar.gz
tar zxvf smokeping-2.6.8.tar.gz
cd smokeping-2.6.8
./configure –prefix=/usr/local/smokeping
编译的时候会报错提示缺少很多的扩展程序,这时候我们只需要执行一个安装脚本就好了
./setup/build-perl-modules.sh /usr/local/smokeping/thirdparty
等他安装完再继续编译安装
./configure –prefix=/usr/local/smokeping
make && make install
/usr/bin/gmake install
安装完毕,下面修改配置文件。
/usr/local/smokeping/bin
进入bin目录,修改smokeping文件
#vim smokeping
第八行: use lib qw(); # PERL5LIB
修改为: use lib qw(/usr/local/rrdtool/lib/perl);
进入htdocs目录
# mv smokeping.fcgi.dist smokeping.fcgi
进入etc目录
cp config.dist config
修改config文件
#vim config
以下自行修改为自己需要的
owner = sundong
contact =
mailhost =
修改报警邮箱
*** Alerts ***
to = 1578980735@qq.com
from = 18062069926@163.com
*** Probes ***
+ FPing
binary = /usr/sbin/fping##修改为实际路径
binary = /usr/local/sbin/fping
监控主机是分层结构的,用+号表示
例如+第一层 ++第二层 +++第三层 根据自己情况修改;
在这里,设备名中不能有”.”和“-”,应该还有其他的字符我没有遇到的。
master/slave方式以及其他的一些功能后续补充
+ Test
menu= local
#parents = owner:/Test/James location:/
++ Yunvn
menu = localhost
title =localhost
host = localhost
下面附录我的配置文件,仅供参考。
创建存放数据文件的目录
mkdir -p /usr/local/smokeping/data /usr/local/smokeping/var /usr/local/smokeping/cache
修改smokeping的目录为apache运行用户的属主、组
chown -R daemon.daemon smokeping/
chmod 600 /usr/local/smokeping/etc/smokeping_secrets.dist
chmod 777 /usr/local/smokeping/cache /usr/local/smokeping/data /usr/local/smokeping/var
创建smokeping的log文件
touch /var/log/smokeping.log
chown daemon.daemon /var/log/smokeping.log
启动smokeping
perl /usr/local/smokeping/bin/smokeping --logfile=/var/log/smokeping.log
建立smokeping启动脚本,方便启动
vim /etc/init.d/smokeping
添加为以下内容:
#!/bin/bash
#
# chkconfig: 2345 80 05
# Description: Smokeping init.d script
# Hacked by : sundong
# Get function from functions library
. /etc/init.d/functions
# Start the service Smokeping
start() {
echo -n "Starting Smokeping: "
/usr/local/smokeping/bin/smokeping >/dev/null 2>&1
### Create the lock file ###
touch /var/lock/subsys/smokeping
success $"Smokeping startup"
echo
}
# Restart the service Smokeping
stop() {
echo -n "Stopping Smokeping: "
kill -9 `ps ax | grep "/usr/local/smokeping/bin/smokeping" | grep -v grep | awk '{ print $1 }'` >/dev/null 2>&1
### Now, delete the lock file ###
rm -f /var/lock/subsys/smokeping
success $"Smokeping shutdown"
echo
}
### main logic ###
case "$1" in
start)
start
;;
stop)
stop
;;
status)
status Smokeping
;;
restart|reload|condrestart)
stop
start
;;
*)
echo $"Usage: $0 {start|stop|restart|reload|status}"
exit 1
esac
exit 0
给脚本有可执行权限
# chmod 755 /etc/init.d/smokeping
设置开机启动smokeping
chkconfigure smokeping on
配置apache
#vim /etc/httpd/conf/httpd.conf
最后加入
Alias /smokeping "/usr/local/smokeping/htdocs/smokeping.fcgi"
Alias /cache "/usr/local/smokeping/cache"
Alias /cropper "/usr/local/smokeping/htdocs/cropper/"
<Directory /usr/local/smokeping>
AllowOverride None
AddHandler cgi-script cgi fcgi
Options ExecCGI
Order allow,deny
Allow from all
DirectoryIndex smokeping.cgi
</Directory>
保存
报错信息
[root@Cacti local]# service httpd start
Starting httpd: httpd: apr_sockaddr_info_get() failed for Cacti
httpd: Could not reliably determine the server's fully qualified domain name, using 127.0.0.1 for ServerName
修改 httpd.conf 里的 ServerName localhost:80
设置开机启动httpd
chkconfigurehttpd on
好了,至此安装配置完成;
访问http://IP/smokeping
报错信息
Can't locate RRDs.pm in @INC (@INC contains:.............................
执行 yum install perl-rrdtool
(责任编辑:IT)
由于公司需要监控机房的网络质量无奈只能安装smokeping,鉴于网上的教程大多都是老版本的,所以今天我就讲诉一下我在centos上安装新版本的过程,有些得不好的地方还请大家多多原谅。 以下所有安装包请到这里下载:http://download.chinaunix.net/
1.先关闭selinux和清空iptables
wget http://down1.chinaunix.net/distfiles/cgilib-0.5.tar.gz
5.安装 echoping
tar zxvf echoping-5.2.0.tar.gz
报错信息: ./configure configure: error: Popt libraries is required yum install popt-devel gettext ./configure echo $? configure: error: GNU --without-libidn ./configure --without-libidn echo $? make && make install
6.安装smokeping
/usr/bin/gmake install
/usr/local/smokeping/bin
监控主机是分层结构的,用+号表示
报错信息
[root@Cacti local]# service httpd start 修改 httpd.conf 里的 ServerName localhost:80 设置开机启动httpd chkconfigurehttpd on
好了,至此安装配置完成; 访问http://IP/smokeping
报错信息 Can't locate RRDs.pm in @INC (@INC contains:.............................
执行 yum install perl-rrdtool |