Xymon (音同Simon /ˈsaɪmən/) 是一款开源的可跨平台的系统状态监控软件, 支持Windows系列, 各种发行版的Linux, AIX及Solaris等多种平台的服务器, 通过网页直观查看各服务器的运行状态, 并支持Email及短信通知功能. 真是居家旅行必备之良药. 以下是一些资源供参考:
- Demo 网站: http://www.xymon.com/
- 文档: http://www.xymon.com/hobbit/help/install.html
- 下载: 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 Xymon
This script asks a few questions and builds a Makefile to compile Xymon
Checking your make-utility
Checking pre-requisites for building Xymon
Checking 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/lib
Xymon 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 librt
Checking for Large File Support ...
Large File Support OK
Setting up for a Xymon server
What userid will be running Xymon [xymon] ?
#回车应用默认值
Found passwd entry for user xymon:x:500:500::/home/xymon:/bin/bash
Where do you want the Xymon installation [/home/xymon] ?
#回车应用默认值
OK, will configure to use /home/xymon as the Xymon toplevel directory
What 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的IP
Where should I install the Xymon man-pages (/usr/local/man) ?
#回车应用默认值
Using Linux Makefile settings
Created 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. 装好后要注意要更改注册表HKLM\software\bbwin\hostname, 将hostname改成本机的FQDN, 如gw要改为: gw.contoso.com;
3. 用记事本打开 c:\program files\bbwin\etc\bbwin.cfg 进行编辑,
a. 首先将BBwin的Mode改为central, 这样便于在服务端统一配置:
a. 首先将BBwin的Mode改为central, 这样便于在服务端统一配置:
<!-- bbwin mode local or central --> <setting name="mode" value="" /> <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:files
page 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/manpages/man5/bb-hosts.5.html
http://www.xymon.com/hobbit/help/manpages/man5/hobbit-clients.cfg.5.html
至此, 关于Xymon这个东东就介绍完了, 当然我只是讲到一点皮毛, 因为本人研究的也还不够透彻, 还有很多很强的功能等待去发掘, 文中一定也有很多不妥的地方,大家如果有什么建议或指教可以和我联系:tomshue AT gmail.com.
转载于:https://blog.51cto.com/tshue/269635