使用smokeping監測機房網絡質量

smokeping服務端測試:

1、調整防火牆的設置

[root@C65-A1 ~]# /etc/init.d/iptables stop
iptables: Setting chains to policy ACCEPT: filter          [  OK  ]
iptables: Flushing firewall rules:                         [  OK  ]
iptables: Unloading modules:                               [  OK  ]
[root@C65-A1 ~]# chkconfig iptables off
[root@C65-A1 ~]# getenforce 
Enforcing
[root@C65-A1 ~]# setenforce 0
[root@C65-A1 ~]# vim /etc/sysconfig/selinux
將“SELINUX=enforcing”改爲“SELINUX=disabled”

2、修改yum安裝源

[root@C65-A1 ~]# vim /etc/sysconfig/selinux 
[root@C65-A1 ~]# rpm -Uvh http://apt.sw.be/redhat/el6/en/x86_64/rpmforge/RPMS/rpmforge-release-0.5.3-1.el6.rf.x86_64.rpm
Retrieving http://apt.sw.be/redhat/el6/en/x86_64/rpmforge/RPMS/rpmforge-release-0.5.3-1.el6.rf.x86_64.rpm
warning: /var/tmp/rpm-tmp.7A2TOZ: Header V3 DSA/SHA1 Signature, key ID 6b8d79e6: NOKEY
Preparing...                ########################################### [100%]
   1:rpmforge-release       ########################################### [100%]

3、安裝rrdtool與依賴庫

[root@C65-A1 ~]# 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 perl-RRD-Simple rrdtool rrdtool-perl curl fping echoping  httpd httpd-devel gcc make  wget libxml2-devel libpng-devel glib pango pango-devel freetype freetype-devel fontconfig cairo cairo-devel libart_lgpl libart_lgpl-devel mod_fastcgi

4、安裝smokeping

[root@C65-A1 ~]# tar zxvf smokeping-2.6.9.tar.gz
[root@C65-A1 ~]# cd smokeping-2.6.9
出現問題是因爲需要安裝perl的模塊,所以運行下面內容即可
[root@C65-A1 ~]# ./setup/build-perl-modules.sh /usr/local/smokeping/thirdparty
[root@C65-A1 ~]# ./configure --prefix=/usr/local/smokeping
[root@C65-A1 ~]# /usr/bin/gmake install

5、配置smokeping

[root@C65-A1 smokeping-2.6.9]# cd /usr/local/smokeping/
[root@C65-A1 smokeping]# mkdir -p var cache data
[root@C65-A1 smokeping]# touch /var/log/smokeping.log
[root@C65-A1 smokeping]# chown apache:apache var cache data
[root@C65-A1 smokeping]# chown apache:apache /var/log/smokeping.log 
[root@C65-A1 smokeping]# ls
bin  cache  data  etc  htdocs  lib  share  thirdparty  var
[root@C65-A1 smokeping]# cd /usr/local/smokeping/htdocs/
[root@C65-A1 htdocs]# ls
cropper  smokeping.fcgi.dist
[root@C65-A1 htdocs]# cp -p smokeping.fcgi.dist /tmp/
[root@C65-A1 htdocs]# mv smokeping.fcgi.dist smokeping.fcgi
[root@C65-A1 htdocs]# cd /usr/local/smokeping/etc/
[root@C65-A1 etc]# ls
basepage.html.dist  examples        smokeping_secrets.dist
config.dist         smokemail.dist  tmail.dist
[root@C65-A1 etc]# cp -p config.dist /tmp/
[root@C65-A1 etc]# mv config.dist config
[root@C65-A1 etc]# vim config 
a. 將“cgiurl   = http://some.url/smokeping.cgi”修改爲“cgiurl   = http://192.168.1.14/smokeping.cgi”
b. 將 *** Database *** 中的“step     = 300”修改爲"step     = 60",每分鐘取樣一次
      step     = 300
      pings    = 20
[root@C65-A1 etc]# chmod 600 /usr/local/smokeping/etc/smokeping_secrets.dist
備註:修改密碼文件權限

6、調整apache的配置

[root@C65-A1 etc]# vim /etc/httpd/conf/httpd.conf
添加如下信息:
###set for smokeping###
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>
[root@C65-A1 etc]# cd /usr/local/smokeping/htdocs/
[root@C65-A1 htdocs]# htpasswd -c /usr/local/smokeping/htdocs/htpasswd admin
New password: 
Re-type new password: 
Adding password for user admin

7、設置smokeping開機啓動

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

8、添加smokeping開機腳本

在/etc/init.d目錄下新建smokeping的文件,內容如下:

#!/bin/bash
#
# chkconfig: 2345 80 05
# Description: Smokeping init.d script
# Hacked by : jeff kang - http://www.jffnms.net
# 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

9、開啓smokeping服務

[root@C65-A1 init.d]# chmod +x smokeping

[root@C65-A1 init.d]# /etc/init.d/smokeping start

Starting Smokeping:                                        [  OK  ]

[root@C65-A1 init.d]# ps -ef | grep smokeping 

root       9670      1  0 17:42 ?        00:00:00 /usr/local/smokeping/bin/smokeping [FPing]

root       9673   1264  0 17:42 pts/0    00:00:00 grep smokeping


然後我們可以通過http://192.168.1.144/smokeping.cgi,輸入用戶名和密碼進入smokeping了

10、smokeping裏面開啓中文支持並安裝中文字體

[root@C65-A1 htdocs]# vim /usr/local/smokeping/etc/config 
如果需要在網頁裏展示中文,修改/usr/local/smokeping/etc/config文件
*** Presentation ***
charset = utf-8 //注:在這裏添加
[root@C65-A1 htdocs]# yum -y install wqy*

11、添加監控信息,重啓服務,使配置生效

[root@C65-A1 htdocs]# vim /usr/local/smokeping/etc/config 
[root@C65-A1 htdocs]# /etc/init.d/smokeping stop
Stopping Smokeping:                                        [  OK  ]
[root@C65-A1 htdocs]# /etc/init.d/smokeping start
Starting Smokeping:                                        [  OK  ]
[root@C65-A1 htdocs]# ps -ef | grep smokeping
root       9861      1  0 18:04 ?        00:00:00 /usr/local/smokeping/bin/smokeping [FPing]
root       9864   1442  0 18:04 pts/1    00:00:00 grep smokeping

12、其它資料

檢查smokeping的配置文件

[root@C65-A1 htdocs]# /usr/local/smokeping/bin/smokeping --check
Configuration file '/usr/local/smokeping/bin/../etc/config' syntax OK.
[root@C65-A1 htdocs]# /usr/local/smokeping/bin/smokeping --help
說明:
+ Gansu //注意,這裏加號後面的必須是英文,不能是中文
menu = 甘肅
title = 甘肅
++ Daliang //同樣,這裏‘++’後面的必須是英文,+和++後面的內容是不會被現實的,只是起一個命名的作用。
menu =大梁
title =大梁:10.138.1.11
host = 10.138.1.11
alerts = someloss
一級、二級、三級目錄的結構:
+ yiji
menu = 一級
title = 一級
++ erji
menu = 二級
title = 二級
+++ sanji
menu = sanji
title =sanji:10.138.16.54
host = 10.138.16.54
alerts = someloss

說明:title代表的是右邊圖片顯示的標題,memu代表的是左邊的菜單

13、監控顯示界面

wKiom1jl217DmnUlAAEXEX2cvjw780.jpg



發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章