歡迎您光臨本站 註冊首頁

Step by step安裝Xymon伺服器監控系統

←手機掃碼閱讀     火星人 @ 2014-03-09 , reply:0
Xymon (音同Simon /ˈsaɪmən/) 是一款開源的可跨平台的系統狀態監控軟體, 支持Windows系列, 各種發行版的Linux, AIX及Solaris等多種平台的伺服器, 通過網頁直觀查看各伺服器的運行狀態, 並支持Email及簡訊通知功能. 真是居家旅行必備之良藥. 以下是一些資源供參考:
  1. Demo 網站: http://www.xymon.com/
  2. 文檔: http://www.xymon.com/hobbit/help/install.html
  3. 下載: http://sourceforge.net/projects/hobbitmon/files/hobbitserver/
最近小弟因為工作上需要對此軟體作了一些研究, 發現目前網上還沒有相關的中文資料. 故斗膽在此將研究的一些心得貼出來和大家一起分享. 如有不妥之處,希望大家不吝指出. 介紹一下我的實驗環境, 所有的伺服器都是在虛擬機的實現: 1. AD DNS OS: Windows Server 2003 R2 Enterprice Chs FQDN: dc.contoso.com IP: 192.168.100.1 Submask: 255.255.255.0 Gateway: 192.168.100.254 DNS: 192.168.100.1 2. Gateway (使用Windows 2003的 "路由和遠程訪問" 服務實現NAT上網共享) OS: Windows Server 2003 R2 Enterprice Chs FQDN: gw.contoso.com Inside Network Interface IP: 192.168.100.254

Submask: 255.255.255.0 Gateway: N/A DNS: 192.168.100.1 Outside Network Interface (這裡的信息為我的物理內網環境) IP: 192.168.1.50 Submask: 255.255.255.0 Gateway: 192.168.1.1 DNS 1: 222.45.0.110 DNS 2: 221.6.4.66 3. Xymon Monitor Server OS: CentOS 5.3 FQDN: xymonsvr.contoso.com IP: 192.168.100.2 Submask: 255.255.255.0 Gateway: 192.168.100.254 DNS: 192.168.100.1 4. Linux Platform Client (正好電腦里有一個鏡像文件,用它來充一下吧) OS: Ubuntu 9.10 FQDN: linclt.contoso.com

IP: 192.168.100.3 Submask: 255.255.255.0 Gateway: 192.168.100.254 DNS: 192.168.100.1 下面開始在CentOS上安裝Xymon Server, 本部分內容參考了Xymon的官方安裝說明:http://www.xymon.com/hobbit/help/install.html 以及網上搜到另一份教程:http://en.wikibooks.org/wiki/System_Monitoring_with_Xymon/Administration_Guide/Compiling_on_CentOS 如本文中有未盡之處可自行前往參觀, 下面我們還是按步驟開始講述 (藍字部分為註釋說明,實際操作時不需輸入):1. 登入系統,用戶名:root 再輸入安裝系統設置的密碼,登入成功後進入命令操作狀態;
login as: root
root@192.168.1.50's password:
Last login: Mon Dec 14 14:29:51 2009 from 192.168.1.2
[root@xymonsvr ~]#
2. 這裡有一點小問題, 當時安裝OS時選擇的語言是簡體中文, 在通過終端操作時可能會出現亂碼, 在這裡把語言改成美國英語,如安裝系統時選擇是的英語則略過此步;
[root@xymonsvr ~]# echo $LANG #查看當前默認語言
zh_CN.UTF-8
[root@xymonsvr ~]# echo 'LANG="en_US.UTF-8"' >/etc/sysconfig/i18n #更改默認語言為美國英語
[root@xymonsvr ~]# echo $LANG #再次查看當前默認語言,可以看到已經變成美國英語

en_US.UTF-8
3. 添加rpmforge軟體源;
[root@xymonsvr ~]# wget http://apt.sw.be/redhat/el5/en/i386/RPMS.dag/rpmforge-release-0.3.6-1.el5.rf.i386.rpm #下載安裝文件
[root@xymonsvr ~]# rpm --import http://dag.wieers.com/rpm/packages/RPM-GPG-KEY.dag.txt #導入驗證文件
[root@xymonsvr ~]# rpm -K rpmforge-release-0.3.6-1.el5.rf.i386.rpm
[root@xymonsvr ~]# rpm -i rpmforge-release-0.3.6-1.el5.rf.i386.rpm #安裝
4. 下載Xymon的源代碼文件包備用,這裡我們下載的是最新的穩定版,

[root@xymonsvr ~]# wget http://ncu.dl.sourceforge.net/project/hobbitmon/hobbitserver/4.2.3/xymon-4.2.3.tar.gz
--15:08:54-- http://ncu.dl.sourceforge.net/project/hobbitmon/hobbitserver/4.2.3/xymon-4.2.3.tar.gz
Resolving ncu.dl.sourceforge.net... 140.115.17.45
Connecting to ncu.dl.sourceforge.net|140.115.17.45|:80... connected.
HTTP request sent, awaiting response... 200 OK
Length: 2313567 (2.2M) [application/x-gzip]
Saving to: `xymon-4.2.3.tar.gz'10% [===> ] 253,933 24.2K/s eta 85s<以下省略>
5. 安裝Xymon需要用到的組件,這裡通CentOS的軟體管理軟體yum從軟體源直接下載並安裝;
[root@xymonsvr ~]# yum install fping #安裝fping
Loaded plugins: fastestmirror
Loading mirror speeds from cached hostfile

…<中間省略>...

Install 1 Package(s)
Update 0 Package(s)
Remove 0 Package(s)Total download size: 40 k
Is this ok [y/N]: y #輸入y確認安裝
Downloading Packages:
fping-2.4-1.b2.2.el5.rf.i386.rpm | 40 kB 00:02

…<中間省略>...

Installed: fping.i386 0:2.4-1.b2.2.el5.rf
Complete!
[root@xymonsvr ~]# yum install rrdtool-devel #安裝rrdtool-devel
Loaded plugins: fastestmirror
Loading mirror speeds from cached hostfile
* rpmforge: fr2.rpmfind.net
* base: ftp.isu.edu.tw
* updates: ftp.isu.edu.tw
* addons: ftp.isu.edu.tw
* extras: mirrors.163.com
Setting up Install Process


…<中間省略>...

Install 5 Package(s)
Update 0 Package(s)
Remove 0 Package(s)Total download size: 2.8 M
Is this ok [y/N]: y #輸入y確認安裝
Downloading Packages:
(1/5): rrdtool-devel-1.3.8-2.el5.rf.i386.rpm | 6.8 kB 00:00
(2/5): perl-rrdtool-1.3.8-2.el5.rf.i386.rpm | 51 kB 00:01
(3/5): ruby-1.8.5-5.el5_3.7.i386.rpm | 274 kB 00:14
(4/5): rrdtool-1.3.8-2.el5.rf.i386.rpm | 913 kB 00:16
(5/5): ruby-libs-1.8.5-5.el5_3.7.i386.rpm | 1.6 MB 01:56

…<中間省略>...

Installed: rrdtool-devel.i386 0:1.3.8-2.el5.rf
Dependency Installed: perl-rrdtool.i386 0:1.3.8-2.el5.rf rrdtool.i386 0:1.3.8-2.el5.rf ruby.i386 0:1.8.5-5.el5_3.7 ruby-libs.i386 0:1.8.5-5.el5_3.7
Complete!
[root@xymonsvr ~]# yum install pcre-devel #安裝pcre
Loaded plugins: fastestmirror
Loading mirror speeds from cached hostfile
* rpmforge: fr2.rpmfind.net
* base: mirror.centos.net.cn
* updates: mirror.centos.net.cn
* addons: mirror.centos.net.cn
* extras: mirror.centos.net.cn
Setting up Install Process


…<中間省略>...
Total download size: 176 k
Is this ok [y/N]: y #輸入y確認安裝
Downloading Packages:
pcre-devel-6.6-2.el5_1.7.i386.rpm | 176 kB 02:44
Running rpm_check_debug
Running Transaction Test
Finished Transaction Test
Transaction Test Succeeded
Running Transaction
Installing : pcre-devel [1/1]Installed: pcre-devel.i386 0:6.6-2.el5_1.7
Complete!
6. 創建一個用戶:xymon 以用於運行Xymon Monitor Server;

[root@xymonsvr ~]# useradd xymon #創建用戶
[root@xymonsvr ~]# passwd xymon #創建密碼(無密碼將無法登入)
Changing password for user xymon.
New UNIX password: #輸入一個密碼吧
BAD PASSWORD: it is too simplistic/systematic #說密碼太簡單?無視
Retype new UNIX password: #再輸入一次
passwd: all authentication tokens updated successfully.
7. OK,萬事俱備, 開始動手安裝了, 解壓縮源代碼
[root@xymonsvr ~]# tar -zxvf xymon-4.2.3.tar.gz
8. 查看一下當前目錄, 多了一個"xymon-4.2.3"的文件夾哦, 進去;
[root@xymonsvr ~]# ll #查看當前目錄中的文件和文件的詳細信息,等於ls -l
total 2340
-rw------- 1 root root 1308 Dec 4 04:40 anaconda-ks.cfg
-rw-r--r-- 1 root root 26738 Dec 4 04:40 install.log
-rw-r--r-- 1 root root 4740 Dec 4 04:39 install.log.syslog
-rw-r--r-- 1 root root 16698 Mar 9 2007 rpmforge-release-0.3.6-1.el5.rf.i386.rpm
drwxr-xr-x 15 xymon xymon 4096 Dec 14 16:08 xymon-4.2.3
-rw-r--r-- 1 root root 2313567 Feb 22 2009 xymon-4.2.3.tar.gz
[root@xymonsvr ~]# cd xymon-4.2.3 #切換目錄到xymon-4.2.3

[root@xymonsvr xymon-4.2.3]# #提示符變咯
9. 運行"configure"檢驗系統環境,生成Makefile
[root@xymonsvr xymon-4.2.3]# ./configure #運行configure,一定要加./ 因為當前目錄沒有加入至系統的環境變數Configuration script for XymonThis script asks a few questions and builds a Makefile to compile XymonChecking your make-utility
Checking pre-requisites for building XymonChecking for fping ...
Hobbit has a built-in ping utility (hobbitping)
However, it is not yet fully stable and therefore it
may be best to use the external fping utility instead.
I found fping in /usr/sbin/fping
Do you want to use it [Y/n] ? #輸入y確認
y
Checking to see if '/usr/sbin/fping 127.0.0.1' works ...
127.0.0.1 is alive

…<中間省略>...Checking for RRDtool ...

…<中間省略>...Do you want to be able to test SSL-enabled services (y) ? #輸入y確認
y
Checking for LDAP ...
Found LDAP include files in /usr/include
Found LDAP libraries in /usr/libXymon can use your OpenLDAP LDAP client library to test LDAP servers.Do you want to be able to test LDAP servers (y) ? #輸入y確認

y
Enable experimental support for LDAP/SSL (OpenLDAP 2.x only) (y) ? #回車應用默認值Checking for clock_gettime() requiring librt ...
clock_gettime() requires librtChecking for Large File Support ...
Large File Support OKSetting up for a Xymon serverWhat userid will be running Xymon [xymon] ? #回車應用默認值
Found passwd entry for user xymon:x:500:500::/home/xymon:/bin/bashWhere do you want the Xymon installation [/home/xymon] ? #回車應用默認值
OK, will configure to use /home/xymon as the Xymon toplevel directoryWhat URL will you use for the Xymon webpages [/xymon] ? #回車應用默認值
Where to put the Xymon CGI scripts [/home/xymon/cgi-bin] ? #回車應用默認值
(Note: This is the filesystem directory - we will get to the URL shortly)What is the URL for the Xymon CGI directory [/xymon-cgi] ? #回車應用默認值
(Note: This is the URL - NOT the filesystem directory)…<中間省略>...Where to put the Xymon Administration CGI scripts [/home/xymon/cgi-secure] ? #回車應用默認值
(Note: This is the filesystem directory - we will get to the URL shortly)What is the URL for the Xymon Administration CGI directory [/xymon-seccgi] ? #回車應用默認值
(Note: This is the URL - NOT the filesystem directory)** Note that you may need to modify your webserver configuration.
** After installing, see /home/xymon/server/etc/hobbit-apache.conf for an example configuration.To generate Xymon availability reports, your webserver
must have write-access to a directory below the Xymon
top-level directory. I can set this up if you tell me
what group-ID your webserver runs with. This is typically
'nobody' or 'apache' or 'www-data'What group-ID does your webserver use [nobody] ? #回車應用默認值

Where to put the Xymon logfiles [/var/log/xymon] ? #回車應用默認值
What is the name of this host [xymonsvr.contoso.com] ? #回車應用默認值
What is the IP-address of this host [127.0.0.1] ?
192.168.100.2 #輸入當前Server的IPWhere should I install the Xymon man-pages (/usr/local/man) ? #回車應用默認值
Using Linux Makefile settingsCreated Makefile with the necessary information to build Xymon
Some defaults are used, so do look at the Makefile before continuing.Configuration complete - now run make (GNU make) to build the tools
10. 運進make進行編譯, 此過程約需5,6分鐘;
[root@xymonsvr xymon-4.2.3]# make

…<中間省略>...
Build complete. Now run 'make install' as root
11. 編譯好后, 輸入make install進行安裝;
[root@xymonsvr xymon-4.2.3]# make install…<中間省略>...


Installation complete.You must configure your webserver for the Hobbit webpages and CGI-scripts.
A sample Apache configuration is in /home/xymon/server/etc/hobbit-apache.conf
If you have your Administration CGI scripts in a separate directory,
then you must also setup the password-file with the htpasswd command.To start Hobbit, as the xymon user run '/home/xymon/server/bin/hobbit.sh start'
To view the Hobbit webpages, go to http://xymonsvr.contoso.com/xymon
12. 設置Apache (Web service)開機自動啟動;
[root@xymonsvr ~]# chkconfig httpd on
[root@xymonsvr ~]# chkconfig --list httpd #查看httpd啟動狀態,可以看到runlevel為on,設定成功
httpd 0:off 1:off 2:on 3:on 4:on 5:on 6:off
13. 將Xymon Monitor Server的配置文件添加Apache配置文件的底部, 重啟httpd生效
[root@xymonsvr ~]# cat /home/xymon/server/etc/hobbit-apache.conf >>/etc/httpd/conf/httpd.conf #添加配置文件
[root@xymonsvr ~]# /etc/init.d/httpd restart #重啟服務

Stopping httpd: [ OK ]
Starting httpd: httpd: Could not reliably determine the server's fully qualified domain name, using xymonsvr.contoso.com for ServerName [ OK ]
14. 修改xymon主目錄許可權, 否則網頁將無法訪問;
[root@xymonsvr ~]# chmod 755 /home/xymon #更改許可權
[root@xymonsvr home]# ll –d /home/xymon #查看,可以看到other的許可權有讀和執行
drwxr-xr-x 8 xymon xymon 4096 Dec 14 16:14 xymon
15. 切換到xymon用登入並進入Xymon的安裝目錄運行服務端;

[root@xymonsvr ~]# su – xymon #切換到xymon
[xymon@xymonsvr ~]$ cd server
[xymon@xymonsvr server]$ ls
bin download etc ext hobbit.sh tmp web www
[xymon@xymonsvr server]$ ./hobbit.sh start #啟動服務端,一定要加./ 原因同前
Hobbit started
16. OK了, 找一台可能訪問到xymonsvr的電腦打開瀏覽器訪問網頁檢驗成果, 我這裡在gw.contoso.com將xymonsvr的80埠映射出來了, 直接在宿主機上訪問我的訪問地址為gw.contoso.com 的outside網卡的地址, 當然用虛擬機訪問也可以. 因為還沒有安裝任何客戶端,只看Server自已.綠色的笑臉表示正常,黃色就是警告,紅色就是報警咯; 各個圖標還可以點開查看詳情哦,下面是對各個項目的解釋:
  • bbd 表示Xymon網路服務的可用性.
  • bbgen表示bbgen tool的狀態, 它是用來更新網頁的.
  • bbtest表示bbtest-net 的狀態, 它是用來執行Xymon中配置的所有網路測試.
  • conn是對主機的Ping測試.
  • hobbitd是表示Xymon服務的狀態.
  • http是HTTP-Server的運行狀態
  • info包含此主機在Xymon中的配置, 例如IP地址等.
  • trends包含此主所有狀態的曲線圖.

17. 我們設置Xymon能夠開機自啟動, 這樣就不用每次手機啟動hobbit.sh了;
[root@xymonsvr ~]# cd /etc/init.d #進入/etc/init.d
[root@xymonsvr init.d]# wget http://iam8up.com/xymon-initd/hobbit #到網上下一個別人寫好的腳本
[root@xymonsvr init.d]# vim hobbit #使用vim打開它編輯,vim不熟悉的同學也可用"nano hobbit"
#將以下三行改成如下所示

…<省略>...


STARTBIN=hobbit.sh
STARTDIR=/home/xymon/server/
USERNAME=xymon

…<以下省略>...
[root@xymonsvr init.d]# chmod 755 hobbit #修改它的許可權,讓它可執行
[root@xymonsvr init.d]# ln -s /etc/init.d/hobbit /etc/rc3.d/S70hobbit #創建一個軟鏈接(快捷方式)到的啟動目錄

[root@xymonsvr init.d]# init 6 #重啟Server
下面就要在要監控的伺服器上安裝客戶端了. 在本次實驗中就以Windows 2003和Ubuntu來舉例說明.Windows 平台的客戶端安裝及配置:1. 到這裡下載bbwin:http://sourceforge.net/projects/bbwin/, 下載后安裝, next直到完成;2. 裝好后要注意要更改註冊表HKLMsoftwarebbwinhostname, 將hostname改成本機的FQDN, 如gw要改為: gw.contoso.com;3. 用記事本打開 c:program filesbbwinetcbbwin.cfg 進行編輯,
a. 將BBwin的Mode改為central, 這樣便於在服務端統一配置:
<!-- bbwin mode local or central -->   <setting name="mode" value="central" />   <setting name="configclass" value="win32" />
b. 設置伺服器的地址及埠:

<setting name="bbdisplay" value="192.168.100.2:1984" />
<!-- <setting name="bbdisplay" value="yoursecondbbdisplay:port" />-->
<!-- BB Pager Part -->
<!--<setting name="usepager" value="false" />
<setting name="bbpager" value="192.168.100.2:1984" />
<setting name="bbpager" value="192.168.100.2:1984" />
Linux下的客戶端安裝及配置:Linux客戶端我們這裡以一台Ubuntu的虛擬機來舉例, Ubuntu的安裝這裡就不作舉例了, 基本上目前已做的很簡單了, 除了磁碟分區, 其它都是點 "下一步"就可以了, 這部分如果哪位同學有疑問可以Google一下, 網上大把的教程, 這裡我們假設已經安裝好了, 網路設置見第一篇文章里介紹, 客戶端的安裝我們還是使用服務端的安裝包, 安裝步驟也大體類似:1. sudo useradd xymon創建一個用戶, sudo passwd xymon更改密碼;2. 解壓縮安裝文件, 進入其目錄 執行sudo ./configure –client進行配置2. 詢問client configuration模式時, 接受默認值 <Server>3. Server IP Address: 192.168.100.2;4. <重要>使用vim對Makefile進行編輯, 在裡面加入以下內容, 否則在下面編譯時會發生錯誤:
# clock_gettime() settings
LIBRTDEF = -lrt
5. make進行編譯, 完成make install安裝;6. 添加開機自啟動, 方法見前面Server端的安裝.至此, 客戶端的安裝就完成, 下面我們再回到服務端, 將這些客戶端加到監控列表內並對要監控的內容做進一步的設置:我們要配置的是 /home/xymon/server/etc/bbhosts這個文件, 將要監控的主機按照:IP-address hostname # tag1 tag2 ...的格式添加, 每個主機一行,如下表:

192.168.100.2 xymonsvr.contoso.com # bbd http://xymonsvr.contoso.com/xymon/
192.168.100.1 dc.contoso.com
192.168.100.254 gw.contoso.com
192.168.100.3 linclt.contoso.com
配置好后,我們使用su - xymon命令切換到xymon登錄, 執行/home/xymon/server/bin/hobbit.sh restart重啟xymon的服務, 打開網頁檢驗一下效果:從圖中可以看到四台主機都有了( 因為虛擬機重啟的原因,有幾個報警, 整個頁面都是紅色的了), 但是這樣看上去很亂, 我對bbhosts作進一步設置:

page xymon XymonServer
192.168.100.2 xymonsvr.contoso.com # bbd http://xymonsvr.contoso.com/xymon/page Windows WindowsServer
group DC
192.168.100.1 dc.contoso.com #DNS ldap NOCOLUMNS:files,ports
group GW
192.168.100.254 gw.contoso.com # NOCOLUMNS:filespage Linux LinuxServer
192.168.100.3 linclt.contoso.com
簡單的說明一下: page就是創建子頁面, 一個page下面到下一個page標誌之前的行都在這個子頁面下面.Group就是分組, 一個group下面到下一個group標誌之前的行都屬於同一個組,dc.contoso.com這個主機, 因為它是DC同時上面還有DNS服務,我們就啟用對DNS及LDAP服務的監視, 同時取消files和ports這兩列;同時我們對/home/xymon/server/etc/hobbit-client.cfg這個文件作一些定義, 能過編輯這個文件可以指定對某一個客戶端監視的內容及報警閥值, 同樣以DC這個主機為例, 對它的svchost這個進程進行監視, 即個允許有8個svchost.exe, 如果有9個就亮黃燈, 10個就是紅燈, 另外再對DNS服務的啟動狀態進行監視:
HOST=dc.contoso.com
UP 5m
LOAD 15.0 25.0
MEMPHYS 100 101
MEMSWAP 50 80
MEMACT 90 97
PROC svchost 8 9 yellow
SVC DNS startup=automatic status=started
下面是改過之後的結果,主頁面顯示示名個子頁面的鏈接:dc.contoso.com的監視效果:其它的主機我們同樣可以根據自己的需要來進行配置.關於bbhosts和hobbit-clients的更詳細的配置可以參考這個兩個文件的man page:
http://www.xymon.com/hobbit/help/manpages/man5/bb-hosts.5.html
http://www.xymon.com/hobbit/help/manpages/man5/hobbit-clients.cfg.5.html其它更詳細的信息:http://www.xymon.com/hobbit/help/hobbit-config.html至此, 關於Xymon這個東東就介紹完了, 當然我只是講到一點皮毛, 因為本人研究的也還不夠透徹, 還有很多很強的功能等待去發掘, 文中一定也有很多不妥的地方,大家如果有什麼建議或指教可以和我聯繫:tomshue AT gmail.com.


[火星人 ] Step by step安裝Xymon伺服器監控系統已經有3803次圍觀

http://coctec.com/docs/linux/show-post-52109.html