运维监控自动化监控Zabbix

zabbix proxy 安装

2018-12-05  本文已影响1人  baiyongjie

安装jdk

tar zxvf jdk-8u45-linux-x64.tar.gz 
mv jdk1.8.0_45/ /usr/local/

vim  /etc/profile
export JAVA_HOME=/usr/local/jdk1.8.0_45
export JRE_HOME=${JAVA_HOME}/jre
export CLASSPATH=.:${JAVA_HOME}/lib:${JRE_HOME}/lib
export PATH=${JAVA_HOME}/bin:$PATH

source /etc/profile

java -version
java version "1.8.0_45"
Java(TM) SE Runtime Environment (build 1.8.0_45-b14)
Java HotSpot(TM) 64-Bit Server VM (build 25.45-b02, mixed mode)

安装zabbix及依赖

groupadd zabbix
useradd  zabbix -g zabbix -s /sbin/nologin 
yum -y install gcc net-snmp-devel  libssh2-devel mysql-devel libxml2-devel  curl-devel 
wget https://nchc.dl.sourceforge.net/project/zabbix/ZABBIX%20Latest%20Stable/3.2.6/zabbix-3.2.6.tar.gz
tar zxf zabbix-3.2.6.tar.gz 
cd zabbix-3.2.6
./configure --prefix=/usr/local/zabbix --enable-proxy  --enable-agent --enable-java --with-net-snmp --with-mysql --with-ssh2  --with-libxml2 --with-libcurl
make -j`lscpu | grep ^CPU\(s\):|awk '{print $2}'`
make install

创建数据库

mysql -uroot -p
create database if not exists zabbix_proxy default character set utf8 collate utf8_general_ci;
grant all privileges on zabbix_proxy.* to zabbix@localhost identified by 'zabbix';
flush privileges;
use zabbix_proxy;
source /usr/local/src/zabbix-3.2.6/database/mysql/schema.sql 

安装fping

wget http://www.fping.org/dist/fping-4.0.tar.gz
tar -zxvf fping-4.0.tar.gz
cd fping-4.0
./configure --prefix=/usr/local/fping
make && make install

ln -s /usr/local/fping/sbin/fping  /usr/sbin/
chmod u+s /usr/local/fping/sbin/fping

配置agent(22.107)

vim /usr/local/zabbix/etc/zabbix_agentd.conf
PidFile=/usr/local/zabbix/zabbix_agentd.pid
LogFile=/var/log/zabbix/zabbix_agentd.log
Server=172.22.22.108
ServerActive=172.22.22.108
Hostname=SN-172.22.22.107
Include=/usr/local/zabbix/etc/zabbix_agentd.conf.d/*.conf

配置proxy

proxy配置文件

cat /usr/local/zabbix/etc/zabbix_proxy.conf

ProxyMode=0
Server=192.168.1.28
Hostname=Zabbix_proxy_IDC
LogFile=/tmp/zabbix_proxy.log
LogFileSize=1024
DebugLevel=3
PidFile=/tmp/zabbix_proxy.pid
DBHost=127.0.0.1
DBName=zabbix_proxy
DBUser=zabbix
DBPassword=zabbix
DBSocket=/var/lib/mysql/mysql.sock
ProxyOfflineBuffer=168
ConfigFrequency=10
DataSenderFrequency=30
StartPollers=30
StartPollersUnreachable=1
StartTrappers=4
StartPingers=1
StartDiscoverers=4
StartHTTPPollers=4
HousekeepingFrequency=1
CacheSize=64M
StartDBSyncers=4
HistoryCacheSize=16M
Timeout=10
TrapperTimeout=30
ExternalScripts=/usr/lib/zabbix/externalscripts
FpingLocation=/usr/local/fping/sbin/fping
JavaGateway=172.22.22.108
JavaGatewayPort=10052
StartJavaPollers=5

启动zabbix_proxy和java以及agent

/usr/local/zabbix/sbin/zabbix_proxy
/usr/local/zabbix/sbin/zabbix_java/startup.sh 
/usr/local/zabbix/sbin/zabbix_agentd

# netstat -nplt
Active Internet connections (only servers)
Proto Recv-Q Send-Q Local Address           Foreign Address         State       PID/Program name    
tcp        0      0 0.0.0.0:22              0.0.0.0:*               LISTEN      1048/sshd           
tcp        0      0 0.0.0.0:10050           0.0.0.0:*               LISTEN      367/zabbix_agentd   
tcp        0      0 0.0.0.0:10051           0.0.0.0:*               LISTEN      300/zabbix_proxy: t 
tcp6       0      0 :::22                   :::*                    LISTEN      1048/sshd           
tcp6       0      0 :::10052                :::*                    LISTEN      348/java            
tcp6       0      0 :::3306                 :::*                    LISTEN      9568/mysqld  

Server端添加proxy

image (3).png

Server端新建群组

image (4).png

Server端添加主机,选择Proxy

image (5).png

zabbix_get测试(22.108)

/usr/local/zabbix/bin/zabbix_get  -s 172.22.22.107 -k system.uptime
31355024

[root@localhost ~]# /usr/local/zabbix/bin/zabbix_get  -s 172.22.22.107 -k agent.ping
1
上一篇下一篇

猜你喜欢

热点阅读