CentoOS下Smokeping的安裝與配置
由於公司需要監控機房的網路品質無奈只能安裝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
wgethttp://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
wgethttp://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
wgethttp://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@Cactilocal]#servicehttpdstart
Startinghttpd:httpd:apr_sockaddr_info_get()failedforCacti
httpd:Couldnotreliablydeterminetheserver'sfullyqualifieddomainname,using127.0.0.1forServerName
修改 httpd.conf 裡的 ServerName localhost:80
設定開機啟動httpd
chkconfigurehttpd on
好了,至此安裝配置完成;
訪問http://IP/smokeping
報錯資訊
Can'tlocateRRDs.pmin@INC(@INCcontains:.............................
執行 yuminstallperl-rrdtool