zabbix简介
zabbix(音同 zbix)是一个基于WEB界面的提供分布式系统监视以及网络监视功能的企业级的开源解决方案。
zabbix能监视各种网络参数,保证服务器系统的安全运营;并提供灵活的通知机制以让系统管理员快速定位/解决存在的各种问题。
zabbix由2部分构成,zabbix server与可选组件zabbix agent。
zabbix server可以通过SNMP,zabbix agent,ping,端口监视等方法提供对远程服务器/网络状态的监视,数据收集等功能,它可以运行在Linux,Solaris,HP-UX,AIX,Free BSD,Open BSD,OS X等平台上。
--------------------------------------------------------------------------------------------------------------
Zabbix构成
zabbix_agentd zabbix客户端守护进程,此进程收集客户端数据。
zabbix_proxy zabbix代理端守护进程。
zabbix_server zabbix服务端守护进程。
zabbix_get zabbix工具,单独使用的命令。
zabbix_sender zabbix工具,用于发送数据给server或者proxy。
(zabbix_java_gateway) zabbix2.0之后引入的一个工程。类似agentd,但只用于java方面。
---------------------------------------------------------------------------------------------------------------
zabbix安装
yum install -y curl curl-devel net-snmp net-snmp-devel perl-DBI
PHP准备
yum install gcc make gd-devel libjpeg-devel libpng-devel libxml2-devel bzip2-devel libcurl-devel -y
yum install freetype*
tar zxvf php-5.5.12.tar.gz
cd php-5.5.12
./configure --prefix=/usr/local/php-5.5.12 --with-config-file-path=/usr/local/php-5.5.12/etc --with-bz2 --with-curl --enable-ftp --enable-sockets --disable-ipv6 --with-gd --with-jpeg-dir=/usr/local --with-png-dir=/usr/local --with-freetype-dir=/usr/local --enable-gd-native-ttf --with-iconv-dir=/usr/local --enable-mbstring --enable-calendar --with-gettext --with-libxml-dir=/usr/local --with-zlib --with-pdo-mysql=mysqlnd --with-mysqli=mysqlnd --with-mysql=mysqlnd --enable-dom --enable-xml --enable-fpm --with-libdir=lib64 --enable-bcmath
make
make install
cp php.ini-production /usr/local/php-5.5.12/etc/php.ini
cp /usr/local/php-5.5.12/etc/php-fpm.conf.default /usr/local/php-5.5.12/etc/php-fpm.conf
vim php.ini
max_execution_time = 300
max_input_time = 300
memory_limit = 128M
post_max_size = 16M
date.timezone = Asia/Shanghai
/usr/local/php-5.5.12/sbin/php-fpm
-----------------------------------------------------------------------------------------------------------------
MySql准备
yum install php-mysql sql-devel *snmp*
yum install mysql*
service mysqld start
-----------------------------------------------------------------------------------------------------------------
Zabbix安装
groupadd zabbix
useradd -g zabbix zabbix
tar zxf zabbix-2.4.4.tar.gz
cd zabbix-2.4.4
./configure --prefix=/jeremy/zabbix-2.4.4 --enable-server --enable-agent --with-mysql --with-net-snmp --with-libcurl --with-libxml2
make && make install
mysql
create database zabbix default charset utf8;
quit;
mysql zabbix < database/mysql/schema.sql
mysql zabbix < database/mysql/images.sql
mysql zabbix < database/mysql/data.sql
配置zabbix
(mkdir /etc/zabbix
cp config/zabbix_server.conf /etc/zabbix/
)
vim /etc/zabbix/zabbix_server.conf
DBName=zabbix
DBUser=root
DBPassword=
DBPort=3306
/jeremy/zabbix-2.4.4/sbin/zabbix_server (默认端口10051)
(Zabbix代理安装
tar zxf zabbix-2.4.4.tar.gz
cd zabbix-2.4.4
./configure --prefix=/jeremy/zabbix-2.4.4 --enable-agent
make && make install
vim /jeremy/zabbix-2.4.4/etc/zabbix_agentd.conf
Server= IP (被动提交IT)
ServerActive= IP (主动提交IP)
Hostname= XXX
/jeremy/zabbix-2.4.4/sbin/zabbix_agentd (默认端口10050)
)
-----------------------------------------------------------------------------------------------------------------
nginx搭建
yum install gcc gcc-c++ autoconf automake zlib zlib-devel openssl openssl-devel pcre-devel
tar zxvf nginx-1.6.0.tar.gz
cd nginx-1.6.0
./configure --prefix=/jeremy/nginx-1.6.0 --with-http_ssl_module --with-http_gzip_static_module --with-http_stub_status_module
make && make install
mkdir /jeremy/monitorweb
cd /jeremy/monitorweb
mkdir logs site/zabbix
cp -rp frontends/php/* /jeremy/monitorweb/site/zabbix/
vim nginx.cfg
root /jeremy/monitorweb/site;
location / {
index index.php index.html index.htm;
}
location ~ \.php$ {
fastcgi_pass 127.0.0.1:9000;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
fastcgi_index index.php;
include fastcgi_params;
}
被监控机安装
安装
1)创建用户
groupadd zabbix
useradd -g zabbix zabbix
2)解压即可
tar zxf zabbix-2.4.4.tar.gz
3)安装服务
cd zabbix-2.4.4
./configure --prefix=/jeremy/zabbix-2.4.4 --enable-agent
make && make install
4)修改配置文件
vim /jeremy/zabbix-2.4.4/etc/zabbix_agentd.conf
Server= IP (被动提交IT)
ServerActive= IP (主动提交IP)
Hostname= XXX
5)启动
/jeremy/zabbix-2.4.4/sbin/zabbix_agentd (默认端口10050)
-------------------------------------------------------------------------------------
6)添加到系统目录
ln -s /usr/local/zabbix_agent/sbin/* /usr/local/sbin/
ln -s /usr/local/zabbix_agent/bin/* /usr/local/bin/
7)测试,下面的命令需要在server端执行,其中192.168.10.199是agent的ip
#/usr/local/zabbix/bin/zabbix_get -s192.168.10.199 -p10050 -k"system.uptime"
1031163
Zabbix Proxy安装
groupadd zabbix
useradd -g zabbix zabbix
tar zxf zabbix-2.4.4.tar.gz
cd zabbix-2.4.4
./configure --prefix=/jeremy/zabbix-2.4.4 --enable-proxy --enable-agent --with-mysql --with-net-snmp --with-libcurl --with-libxml2
make && make install
mysql
create database zabbix default charset utf8;
quit;
mysql zabbix < database/mysql/schema.sql
配置zabbix
(mkdir /etc/zabbix
cp config/zabbix_server.conf /etc/zabbix/
)
vim /etc/zabbix/zabbix_server.conf
DBName=zabbix
DBUser=root
DBPassword=
DBPort=3306
/jeremy/zabbix-2.4.4/sbin/zabbix_server (默认端口10051)