1. 安裝其他源
rpm -Uvh http://apt.sw.be/redhat/el6/en/x86_64/rpmforge/RPMS/rpmforge-release-0.5.3-1.el6.rf.x86_64.rpm
注:安裝這個源后,接下來要安裝的大量的依賴包就不會報錯
2. 安裝rrdtool與依賴庫
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 screen
第二種:
yum -y install cpan perl perl-FCGI perl-CGI perl-Digest-HMAC perl-Net-Telnet perl-Net-OpenSSH perl-Net-SNMPperl-LDAP perl-Net-DNS perl-IO-Pty-Easy perl-Test-Simple perl-Sys-Syslog perl-libwww-perlperl-IO-Socket-SSL perl-Socket6 perl-CGI-SpeedyCGI perl-FCGI perl-Time-HiResperl-ExtUtils-MakeMaker rrdtool rrdtool-perl curl fping httpd httpd-devel gccmake wget libxml2-devel libpng-devel glib pango pango-devel freetypefreetype-devel fontconfig cairo cairo-devel libart_lgpl libart_lgpl-devel mod_fcgidscreen
注:perl-CGI-SpeedyCGI,perl-CGI-SpeedCGI這兩個包在安裝過程中會提示找不到,但沒關系 注:用
yum安裝大量的依賴包還是很方便的,而百度上有些關於安裝smokeping的文檔要求使用wget下載后再用make,make install方式安裝,雖然make方式不復雜,但通過make編譯再安裝幾十個包就顯得有點繁鎖了。
3.下載與安裝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
出現問題是因為需要安裝perl的模塊,所以運行下面內容即可
./setup/build-perl-modules.sh /usr/local/smokeping/thirdparty //這條有時不解決問題,根據提示失敗的安裝相關的模塊,
例如:Config::Grammar模塊
perl -MCPAN -e 'install Config::Grammar'
./configure --prefix=/usr/local/smokeping
/usr/bin/gmake install
現在smokeping安裝完成
4. 配置smokeping
(1) 創建cache、data、var目錄
cd /usr/local/smokeping
mkdir cache data var
(2) 在創建日志
touch /var/log/smokeping.log
(3) 授權
chown apache:apache cache data var
chown apache:apache /var/log/smokeping.log
(4) 修改配置文件
cd /usr/local/smokeping/htdocs/
mv smokeping.fcgi.dist smokeping.fcgi
cd /usr/local/smokeping/etc
mv config.dist config
vim config
cgiurl = http://some.url/smokeping.cgi
主要是修改這行,把some.url修改為你的ip或者域名
*** Database ***
step = 300
pings = 60
然后修改step,從300改為60,這是檢測的時間, pings 從20 改為60, 即60秒ping 60次
(5) .配置完成之后修改密碼文件權限
chmod 600 /usr/local/smokeping/etc/smokeping_secrets.dist
5. 修改apache的配置
vim /etc/httpd/conf/httpd.conf
在DocumentRoot "/var/www/html" 這一行之下添加如下內容:
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
Order allow,deny
Allow from all
DirectoryIndex smokeping.fcgi
</Directory>
6. 設置開機啟動httpd, smokeping
echo "/usr/local/smokeping/bin/smokeping --logfile=/var/log/smokeping.log 2>&1 &" >> /etc/rc.local
chkconfig httpd on #開機啟動httpd進程
7. 啟動http與smokeping
/etc/init.d/httpd start
/usr/local/smokeping/bin/smokeping --logfile=/var/log/smokeping.log 2>&1 &
8. 打開檢測主機的Web頁面
在Web瀏覽器里輸入http://您的監控主機IP/smokeping
如果遇到500錯誤:
Internal Server Error
The server encountered an internal error or misconfiguration and was unable to complete your request.
Please contact the server administrator, root@localhost and inform them of the time the error occurred, and anything you might have done that may have caused the error.
More information about this error may be available in the server error log. --------------------------------------------------------------------------------
Apache/2.2.15 (CentOS) Server at 192.168.2.101 Port 80
說明沒有關閉SElinux 選項,關閉就正常了 改文件可能要重啟才能生效;setenforce 0 可以臨時關閉,但重啟之后還是會變成原來的狀態。
vi /etc/sysconfig/selinux
SELINUX=permissive
如果上面改文件了還關不掉,可以用下面命令關:
setenforce 0
[root@localhost ~]# getenforce #查看SElinux 的命令
Permissive #返回的結果是Permissive, 表示已經關閉SElinux了
輸出的錯誤日志:
[Wed Oct 15 18:46:42.123788 2014] [authz_core:error] [pid 16857] [client 127.0.0.1:49422] AH01630: client denied by server configuration: /Applications/XAMPP/xamppfiles/docs/myapp.example.com/
版本問題,新的apache版本使用黃色部分:
<VirtualHost *:80>
DocumentRoot "/Applications/XAMPP/xamppfiles/docs/myapp.example.com"
ServerName myapp.example.com
ServerAlias www.myapp.example.com
SetEnv APPLICATION_ENV "development"
ErrorLog "logs/myapp.example.com-error_log"
CustomLog "logs/myapp.example.com-access_log" common
<Directory "/Applications/XAMPP/xamppfiles/docs/myapp.example.com">
AllowOverride All
Require all granted
</Directory>
</VirtualHost>
9. 在Web頁面增加驗證用戶名和密碼(可選步驟)
(1)修改httpd.conf里的內容
<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>
注:上面的內容部分已經添加,這里僅添加未重復的內容即可。
(2) 設置登錄賬戶與密碼
進入cd /usr/local/smokeping/htdocs目錄,
執行命令:htpasswd -c /usr/local/smokeping/htdocs/htpasswd admin
這個是設置登錄賬戶為admin,密碼在后面輸入,然后重啟httpd就可以實現密碼驗證登錄 重新登錄web頁面,會要求輸入用戶名和密碼,如下圖
11. 一定要同步好時間
在ESXI4的虛擬機中,定期執行ntpdate 210.72.145.44 #或者與本地的時間服務器同步
在vmware workstation中,安裝vmware-tools, 虛擬機的時間會自動與其宿主機時間同步
注: 如果vmware workstation中的虛擬機不安裝vmware-tools,則虛擬機時間會與宿主機時間相隔整整8個小時(虛擬機時間早於宿主機時間) vmware-tools的安裝不在此敘述
12. 特別說明: 修改/usr/local/smokeping/etc/config 文件的配置參數,必須重啟動smokeping程序
(1)如果重啟動smokeping程序失敗,根據報錯提示刪除/usr/local/smokeping/data子文件夾的rrd文件
(2)中文問題:如果需要在網頁里展示中文,修改/usr/local/smokeping/etc的config文件
*** Presentation ***
charset = utf-8 //注:在這里添加
然后在menu與titile里修改中文,重啟即可
有一個要注意的地方就是,你輸入的中文必須在utf-8的字符編碼下輸入的中文字符,不然會出現亂碼。
如果在xshel下,選擇file-properities-terminal
如果還是不顯示就看看你系統里是否安裝了中文字體,或者在安裝一個
[root@smokeping data]# ps -ef |grep smoke #查找smokeping進程
root 8740 1 0 09:08 ? 00:00:00 /usr/local/smokeping/bin/smokeping [FPing]
root 35552 35529 0 09:33 pts/2 00:00:00 grep smoke
[root@smokeping data]# kill 8740 #殺掉smokeping進程
[root@smokeping data]# ps -ef |grep smoke
root 35554 35529 4 09:33 pts/2 00:00:00 grep smoke
smokeping進程已經被殺掉
[root@smokeping data]#screen #如果通過SSH遠程登錄到監控主機,最后執行screen,在虛擬窗口中啟動smokeping /usr/local/smokeping/bin/smokeping --logfile=/var/log/smokeping.log 2>&1 &
需要安裝fping
[root@mail /]# wget --limit-rate 500k http://www.fping.org/dist/fping-3.8.tar.gz
[root@mail /]# tar zxvf fping-3.8.tar.gz && cd fping-3.8
[root@mail /]# ./configure && make && make install
三. 添加需要監控的網站和節點(在/usr/local/smokeping/etc/config中添加)
* smokeping就這點不好,添加節點不能在前台Web頁面添加,一定要在后台的配置文件中添加,希望以后的版本中能改進一下 *
* 修改/usr/local/smokeping/etc/config 后,必須重啟smokeping 程序,配置才會生效 *
* smokeping 會根據配置文件config 在/usr/local/smokeping/data 之下添加moniter文件夾,其下包含website子文件夾 *
* 用vmware workstation的虛擬機測試有一點好處,workstation下的虛擬網卡可以設置出入的丟包率,適合smokeping做丟包測試,
經過測試smokeping檢測出的丟包率與vmware worksation虛擬網卡設置的丟包率基本相同,也就是說smokeping 能夠反應網絡的真實狀況 *
添加監控節點示例:注意+是第一層,++是第二層,+++ 是第三層
+ moniter
menu = moniter
++ To-DG
menu =To-DG
title = To-DG
alerts = someloss
host = 159.122.74.153
原文件鏈接:https://files.cnblogs.com/files/simon4you/smokeping.7z