一.Zabbix简介 
Zabbix 是一个提供 Web 管理界面的企业级的开源系统/网络监控分布式监控解决方案,由一个国外的团队持续维护更新,软件可以自由下载使用,运作团队靠提供收费的技术支持赢利。 
官方网站:http://www.zabbix.com 
英文安装文档 http://www.zabbix.com/wiki/howto/install/centos/centosinstall 
Zabbix通过C/S模式采集数据,通过B/S模式在web端展示和配置。 
被监控端:主机通过安装agent方式采集数据,网络设备通过SNMP方式采集数据 
Server端:通过收集SNMP和agent发送的数据,写入MySQL数据库,再通过php+apache在web前端展示。 
Zabbix运行条件: 
Server: 
Zabbix Server需运行在LAMP(Linux+Apache+Mysql+PHP)环境下,对硬件要求低 
Agent: 
目前已有的agent基本支持市面常见的OS,包含Linux、HPUX、Solaris、Sun、windows 
SNMP: 
支持各类常见的网络设备

二. Zabbix功能 
  具备常见的商业监控软件所具备的功能(主机的性能监控、网络设备性能监控、数据库性能监控、FTP等通用协议监控、多种告警方式、详细的报表图表绘制) 
支持自动发现网络设备和服务器,支持分布式,能集中展示、管理分布式的监控点,扩展性强,server提供通用接口,可以自己开发完善各类监控

三.优劣势 
优点: 
开源,无软件成本投入 
Server对设备性能要求低(实际测试环境:虚拟机Redhat EL AS5,2GCPU 1G内存,监控5台设备,CPU使用率基本保持在10%以下,内存剩余400M以上) 
支持设备多 
支持分布式集中管理 
开放式接口,扩展性强 
缺点: 
全英文,界面不友好 
无厂家支持,出现问题解决比较麻烦 
需在被监控主机上安装agent 
-------------------------------------------------------- 
安装开始 
安装条件:a.以root用户运行所有命令 b.连接网络 (建议搭建先搭建本地yum)

1.搭建YUM 
[root@rhel ~]# yum -y install httpd php php-mysql mysql-server mysql-client curl curl-devel net-snmp net-snmp-devel perl-DBI php-gd php-xml php-bcmath zlib-devel mysql-devel glibc-devel gcc automake libidn-devel openssl-devel net-snmp-devel rpm-devel OpenIPMI-devel

2. install zabbix 
(为zabbix创建自己的数据库,以便zabbix可以把收集到的数据信息存放在那里调用) 
[root@rhel src]# useradd zabbix 
[root@rhel src]# passwd zabbix 
[root@rhel src]# mysql -u root -p 
Enter password: 
Welcome to the MySQL monitor.  Commands end with ; or \g. 
Your MySQL connection id is 1 
Server version: 5.1.56-LTOPS-log Source distribution

Copyright (c) 2000, 2010, Oracle and/or its affiliates. All rights reserved. 
This software comes with ABSOLUTELY NO WARRANTY. This is free software, 
and you are welcome to modify and redistribute it under the GPL v2 license

Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.

mysql> create database zabbix; 
Query OK, 1 row affected (0.02 sec) 
mysql> grant all on zabbix.* to zabbix@localhost identified by 'zabbix' ; 
Query OK, 0 rows affected (0.08 sec) 
mysql> quit 
Bye

[root@rhel src]# tar xzvf zabbix-1.8.12.tar.gz 
[root@rhel src]# cd zabbix-1.8.12 
[root@rhel zabbix-1.8.12]# mysql -u root zabbix < create/schema/mysql.sql 
[root@rhel zabbix-1.8.12]# mysql -u root zabbix < create/data/data.sql 
[root@rhel zabbix-1.8.12]# mysql -u root zabbix < create/data/images_mysql.sql 
[root@rhel zabbix-1.8.12]# ./configure --enable-server --with-mysql --with-net-snmp --with-jabber --with-libcurl --with-openipmi --enable-agent

--prefix指定zabbix安装目录,--enable-server 支持zabbix服务器,--enable-agent支持zabbix代理,--enable-proxy 支持zabbix代理服务器,--with-mysql 使用MySQL客户端库可以选择指定路径mysql_config,--with-net-snmp 使用net-snmp软件包,择性地指定路径net-snmp配置, --with-libcurl 使用curl包

注意啦:请执行两次以上 ./configure ,检查是否有错误

[root@rhel zabbix-1.8.12]# make && make install

添加zabbix服务对应的端口

[root@rhel zabbix-1.8.12]# cat >> /etc/services << EOF 
zabbix-agent 10050/tcp Zabbix Agent 
zabbix-agent 10050/udp Zabbix Agent 
zabbix-trapper 10051/tcp Zabbix Trapper 
zabbix-trapper 10051/udp Zabbix Trapper 
EOF

[root@rhel zabbix-1.8.12]# 
[root@rhel zabbix-1.8.12]# mkdir /etc/zabbix 
[root@rhel zabbix-1.8.12]# cp misc/conf/* /etc/zabbix/ 
cp: omitting directory `misc/conf/zabbix_agentd' 
[root@rhel zabbix-1.8.12]# cp -r frontends/php/* /var/www/html/zabbix

修改zabbix连接的数据库的用户名和密码

[root@rhel zabbix-1.8.12]# vim /etc/zabbix/zabbix_server.conf    

86 DBName=zabbix 
102 DBUser=zabbix 
112 DBPassword=zabbix

为 zabbix 的启动、关闭和重启的脚本文件做链接,方便系统可以找得到

[root@rhel zabbix-1.8.12]# cd /usr/local/zabbix/bin/ 
[root@rhel bin]# for i in *;do ln -s /usr/local/zabbix/bin/${i} /usr/bin/${i};done 
[root@rhel bin]# cd /usr/local/zabbix/sbin/ 
[root@rhel sbin]# for i in *;do ln -s /usr/local/zabbix/sbin/${i} /usr/sbin/${i};done

把mysql的lib库文件添加到系统动态库配置文件中,方便系统可以找到mysql的lib库

[root@rhel sbin]# echo "/usr/local/mysql-5.1.56/lib/mysql/" >> /etc/ld.so.conf 
[root@rhel sbin]# ldconfig        (立即生效)

将zabbix相关的启动脚本等文件拷贝的/etc/init.d/下,方便日后对 zabbix 的启动关闭操作

[root@rhel sbin]# cd /usr/local/src/zabbix-1.8.12 
[root@rhel zabbix-1.8.12]# cp misc/init.d/redhat/8.0/zabbix_server /etc/init.d/ 
[root@rhel zabbix-1.8.12]# chmod +x /etc/init.d/zabbix_server 
[root@rhel zabbix-1.8.12]# cp misc/init.d/redhat/8.0/zabbix_agentd /etc/init.d/ 
[root@rhel zabbix-1.8.12]# chmod +x /etc/init.d/zabbix_agentd

修改zabbix server和agentd程序目录的位置

[root@rhel zabbix-1.8.12]# vim /etc/init.d/zabbix_server

17 progdir="/usr/local/zabbix/sbin/"

[root@rhel zabbix-1.8.12]# vim /etc/init.d/zabbix_agentd

17 progdir="/usr/local/zabbix/sbin/"

添加开机启动服务

[root@rhel zabbix-1.8.12]# chkconfig --add zabbix_server 
[root@rhel zabbix-1.8.12]# chkconfig --add zabbix_agentd 
[root@rhel zabbix-1.8.12]# chkconfig --level 345 zabbix_server on 
[root@rhel zabbix-1.8.12]# chkconfig --level 345 zabbix_agentd on 
[root@rhel zabbix-1.8.12]# chkconfig --list | grep zabbix                
(使用 chkconfig --list 检查一下)

对php配置文件做相应的调整,使其满足zabbix运行的最低环境要求

[root@rhel zabbix-1.8.12]# vim /usr/local/php-5.2.17/etc/php.ini

255 max_execution_time = 300     
256 max_input_time = 300    
439 post_max_size = 16M 
663 [Date] 
664 ; Defines the default timezone used by the date functions 
665 date.timezone = Asia/Shanghai

[root@rhel ~]# cd /data/www/wwwroot/zabbix/ 
[root@rhel zabbix]# chmod 777 conf   
;             (权限不给的话web界面安装到最后一步会报错) 
[root@rhel ~]# /etc/init.d/zabbix_agentd restart 
[root@rhel ~]# /etc/init.d/zabbix_server restart 
[root@rhel ~]# /etc/init.d/fastcgi restart 
[root@rhel ~]# /etc/init.d/mysqld restart 
[root@rhel ~]# /etc/init.d/snmpd restart

web enter install zabbix:http://IP/zabbix/,用户名和密码为默认:admin/zabbix,进入zabbix安装界面,同意许可协议,环境最低要求(前面对 php 配置文件的修改),数据库连接配置 (连接mysql的用户名和密码之前以配置,zabbix/zabbix),zabbix server的信息,next,next,完成安装,

-------------------------------------------------------------------------------

zabbix客户端软件安装配置(Linux操作系统)

groupadd zabbix 
useradd zabbix -g zabbix 
password zabbix

从zabbix Server上拷贝一份zabbix.agentd.conf 拷贝配置文件到/etc/zabbix目录下,修改配置文件中主机名和监控服务器

vim /etc/zabbix/zabbix_agentd.conf

     81 Server=服务器断IP 
     92 Hostname=被监控端IP

在客户端服务器上添加zabbix监控端口

cat >> /etc/services << EOF 
zabbix-agent 10050/tcp Zabbix Agent 
zabbix-agent 10050/udp Zabbix Agent 
zabbix-trapper 10051/tcp Zabbix Trapper 
zabbix-trapper 10051/udp Zabbix Trapper 
EOF

下载客户端 
tar -xzvf zabbix_agents_1.8.5.linux2_6.i386.tar.gz -C /usr/local/zabbix

拷贝启动脚本到/etc/init.d目录下

cd /usr/local/zabbix/sbin/ 
cp zabbix_agentd /etc/init.d/ 
chmod a+x /etc/init.d/zabbix_agentd

/etc/init.d/zabbix_agentd start 
ps -ef | grep zabbix_agentd

iptables -A INPUT -p tcp -s 服务器IP -m multiport --dports 10050,10051 -jACCEPT