zabbix深入玩转
Part1.Zabbix简介
一、 Zabbix简介
Zabbix Zabbix 是一个提供 Web 管理界面的企业级的开源系统/网络监控分布式监控解决方案,由一个国外的团队持续维护更新,软件可以自由下载使用,运作团队靠提供收费的技术支持赢利。 官方网站:http://www.zabbix.com
Zabbix 1.8官方文档:http://www.zabbix.com/documentation/1.8/start 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
安装前先配置好PHP,要求支持 php-gd、php-bcmath、php-xml、php-mysql、php-net-socket、php-mbstring,即 configure 参数中加上 –with-gd –enable-bcmath –enable-xml –with-mysql –enable-sockets –enable-mbstring
下面开始安装 Zabbix:
下载并解压:http://nchc.dl.sourceforge.net/project/zabbix/ZABBIX Latest Stable/1.8.2/zabbix-1.8.2.tar.gz tar zxvf zabbix-1.8.2.tar.gz cd zabbix-1.8.2
* 创建 zabbix 用户组和用户: groupadd zabbix useradd zabbix -g zabbix * 创建 mysql 数据库:
create database zabbix character set utf8;
* 创建 mysql 用户:
grant all on zabbix.* to zabbix@localhost identified by 'zabbix'; * 导入表和数据:
mysql -uroot -p zabbix < create/schema/mysql.sql mysql -uroot -p zabbix < create/data/data.sql
mysql -uroot -p zabbix < create/data/images_mysql.sql
* 配置编译:./configure --enable-server --enable-proxy --enable-agent --with-mysql=/usr/local/mysql/bin/mysql_config --with-net-snmp --with-libcurl make && make install 配置参数说明:
–enable-server 安装 Zabbix Server –enable-proxy 安装 Zabbix Proxy –enable-agent 安装 Zabbix Agent –with-mysql 使用 mysql 做数据库服务器 –with-net-snmp 支持 SNMP
–with-libcurl 支持 curl,用于 web 监控 * 服务端口定义:
编辑 /etc/services,在后面追加:
zabbix-agent 10050/tcp #Zabbix Agent zabbix-agent 10050/udp #Zabbix Agent zabbix-trapper 10051/tcp #Zabbix Trapper zabbix-trapper 10051/udp #Zabbix Trapper
* 复制配置文件: mkdir /etc/zabbix
cp misc/conf/zabbix_server.conf /etc/zabbix/ cp misc/conf/zabbix_proxy.conf /etc/zabbix/
cp misc/conf/zabbix_agent.conf /etc/zabbix/ cp misc/conf/zabbix_agentd.conf /etc/zabbix/
* 修改 zabbix server 配置文件 /etc/zabbix/zabbix_server.conf 中的数据库用户名和密码:
DBUser=zabbix
DBPassword=zabbix
* 安装启动脚本
cp misc/init.d/redhat/zabbix_server_ctl /etc/init.d/zabbix-server cp misc/init.d/redhat/zabbix_agentd_ctl /etc/init.d/zabbix-agentd 添加可执行权限:
chmod +x /etc/init.d/zabbix-server chmod +x /etc/init.d/zabbix-agentd 修改 zabbix-server 变量定义:
BASEDIR= /usr/local
ZABBIX_SUCKERD=$BASEDIR/sbin/zabbix_server 修改 zabbix-agentd 头部变量定义: BASEDIR= /usr/local
ZABBIX_AGENTD=$BASEDIR/sbin/zabbix_agentd
* 添加到启动服务:
chkconfig --add zabbix-server chkconfig --add zabbix-agentd chkconfig zabbix-server on chkconfig zabbix-agentd on 如何让 Zabbix Server 和 Zabbix agentd 开机自动运行,免得每次都要手动运行,步骤如下: 1. 复制 zabbix 源程序 misc/init.d/redhat 下的启动脚本到 /etc/init.d 目录下 cp /zabbix/zabbix-1.6.6/misc/init.d/redhat/zabbix_server_ctl /etc/init.d/zabbix_server cp /zabbix/zabbix-1.6.6/misc/init.d/redhat/zabbix_agentd_ctl /etc/init.d/zabbix_agentd 2. 修改启动脚本使其支持 redhat 的 chkconfig,分别在两个脚本的 #!/bin/sh 后加入如下两行注释,注意要行前要加“#” 哦 # chkconfig: - 95 95 # description: Zabbix Server 3. 修改启动脚本中 BASEDIR 和 ZABBIX_SUCKERD ,制定到 zabbix_server 和 zabbix_agentd 的安装位置,如: BASEDIR=/usr/local/sbin ZABBIX_SUCKERD=$BASEDIR/zabbix_server 4. 使用 chkconfig 将其加入 init 的启动服务 chkconfig --add zabbix_server chkconfig --add zabbix_agentd chkconfig --level 345 zabbix_server on chkconfig --level 345 zabbix_agentd on 4. 使用 chkconfig --list 检查一下 chkconfig --list | grep zabbix 输出如下: zabbix_agentd 0:off 1:off 2:off 3:on 4:on 5:on 6:off zabbix_server 0:off 1:off 2:off 3:on 4:on 5:on 6:off * 启动 Zabbix Server:
/etc/init.d/zabbix-server start
* 启动 Zabbix Agentd /etc/init.d/zabbix-agentd start
* 复制 Web Interface 到 web 目录:
cp -r frontends/php /data/wwwroot/nagios.91linux.cn/webroot/zabbix
Zabbix会使用到fping,可以使用yum install fping 安装,如果yum无此软件,可使用源码安装 http://fping.sourceforge.net/ 进入 fping 解压后的源代码目录 ./configure make install
修改/etc/zabbix/zabbix_server.conf FpingLocation=/usr/local/sbin/fping
* 开始安装 Zabbix Web Interface
打开 http://192.168.9.23/zabbix/,看到提示:
?
date() [function.date]: It is not safe to rely on the system's timezone settings.
Please use the date.timezone setting, the TZ environment variable or the date_default_timezone_set() function. In case you used any of those methods and you are still getting this warning, you most likely misspelled the timezone identifier. We selected 'Asia/Chongqing' for 'CST/8.0/no DST'
instead[/data/wwwroot/nagios.91linux.cn/webroot/zabbix/include/page_header.php:149]
?
Timezone for PHP is not set. Please set \
相关推荐: