Zabbix-2.4-安装-3
![](https://images2015.cnblogs.com/blog/1076878/201703/1076878-20170313233405151-102911409.png)
下面就是自动注册
在operations这里找到Add host
![](https://images2015.cnblogs.com/blog/1076878/201703/1076878-20170313233733354-477754406.png)
![](https://images2015.cnblogs.com/blog/1076878/201703/1076878-20170313234114182-924785052.png)
![](https://images2015.cnblogs.com/blog/1076878/201703/1076878-20170313234156901-1972268864.png)
![](https://images2015.cnblogs.com/blog/1076878/201703/1076878-20170313234500979-1250002320.png)
![](https://images2015.cnblogs.com/blog/1076878/201703/1076878-20170313234518354-149196855.png)
创建1个2行2列的screen。
![](https://images2015.cnblogs.com/blog/1076878/201703/1076878-20170313234548620-1402975843.png)
![](https://images2015.cnblogs.com/blog/1076878/201703/1076878-20170313234612916-908568000.png)
![](https://images2015.cnblogs.com/blog/1076878/201703/1076878-20170313234629823-1982179987.png)
![](https://images2015.cnblogs.com/blog/1076878/201703/1076878-20170313234744823-1084936407.png)
![](https://images2015.cnblogs.com/blog/1076878/201703/1076878-20170313234920682-1550799385.png)
![](https://images2015.cnblogs.com/blog/1076878/201703/1076878-20170313235127557-426152645.png)
加入进来了
![](https://images2015.cnblogs.com/blog/1076878/201703/1076878-20170313235149416-11043117.png)
从Monitor--Screens里也可以加
![](https://images2015.cnblogs.com/blog/1076878/201703/1076878-20170313235251010-763047123.png)
zabbix监控主动模式
默认情况下zabbix是运行在被动模式,这个主动和被动是针对zabbix-agent来说的
agent默认监听一个端口,10050,server会定期主动过来要数据。server端主动的发命令,告诉agent。取哪些数据
如果1万台机器,zabbix同时要发10000个请求到agent,问他们数据。这么弄肯定有问题
zabbix agent也支持主动模式,主动给服务器发消息,这时候用于分布式比较好了
![](https://images2015.cnblogs.com/blog/1076878/201703/1076878-20170314210837073-987765081.png)
![](https://images2015.cnblogs.com/blog/1076878/201703/1076878-20170314210857916-750758156.png)
![](https://images2015.cnblogs.com/blog/1076878/201703/1076878-20170315130622479-159635241.png)
全部克隆
![](https://images2015.cnblogs.com/blog/1076878/201703/1076878-20170315130652901-1931371948.png)
![](https://images2015.cnblogs.com/blog/1076878/201703/1076878-20170315131409526-414468219.png)
![](https://images2015.cnblogs.com/blog/1076878/201703/1076878-20170315131438713-513830849.png)
![](https://images2015.cnblogs.com/blog/1076878/201703/1076878-20170315131517448-963793298.png)
点击进去
![](https://images2015.cnblogs.com/blog/1076878/201703/1076878-20170315131541557-1366369956.png)
点击Full clone
![](https://images2015.cnblogs.com/blog/1076878/201703/1076878-20170315131559979-1811446189.png)
把克隆出来的改成如下名字,多了个Active用来区分,然后点击Add
![](https://images2015.cnblogs.com/blog/1076878/201703/1076878-20170315133515791-1173997437.png)
![](https://images2015.cnblogs.com/blog/1076878/201703/1076878-20170315134125963-1978705555.png)
改成如下
以上更改仅仅是添加了新的模板,items这里并没改掉
![](https://images2015.cnblogs.com/blog/1076878/201703/1076878-20170315134509073-1116778966.png)
批量修改
![](https://images2015.cnblogs.com/blog/1076878/201703/1076878-20170315130449745-615121014.png)
下面这里改成Active的
右边的items这里都变成了Active的。上面没变的是link的另一个模板的,因此link的模板也要改
![](https://images2015.cnblogs.com/blog/1076878/201703/1076878-20170315134605729-235104261.png)
![](https://images2015.cnblogs.com/blog/1076878/201703/1076878-20170315134705198-1047914006.png)
也改成active的
![](https://images2015.cnblogs.com/blog/1076878/201703/1076878-20170315134926401-1603471541.png)
![](https://images2015.cnblogs.com/blog/1076878/201703/1076878-20170315135044073-1803039660.png)
删除之前的node2主机,改成主动模式添加
![](https://images2015.cnblogs.com/blog/1076878/201703/1076878-20170315145406760-855485242.png)
下面是设置为0才表示agent开启主动监控模式
把ServerActive改成Zabbix Server的地址,把Hostname改成自己的主机名
![](https://images2015.cnblogs.com/blog/1076878/201703/1076878-20170315145620729-875555381.png)
[root@linux-node2 ~]# grep '^[a-Z]' /etc/zabbix/zabbix_agentd.conf PidFile=/var/run/zabbix/zabbix_agentd.pid LogFile=/var/log/zabbix/zabbix_agentd.log LogFileSize=0 StartAgents=0 ServerActive=10.0.1.161 Hostname=linux-node2.example.com Include=/etc/zabbix/zabbix_agentd.d/ UserParameter=login-user,uptime | awk -F ' ' '{print $4}' [root@linux-node2 ~]#
重启agent服务
[root@linux-node2 ~]# /etc/init.d/zabbix-agent restart Shutting down Zabbix agent: [ OK ] Starting Zabbix agent: [ OK ] [root@linux-node2 ~]#
看到不再监听端口了
[root@linux-node2 ~]# netstat -lntp 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 2075/sshd tcp 0 0 :::22 :::* LISTEN 2075/sshd [root@linux-node2 ~]# ps -ef | grep zabbix zabbix 76194 1 0 19:38 ? 00:00:00 zabbix_agentd -c /etc/zabbix/zabbix_agentd.conf zabbix 76195 76194 0 19:38 ? 00:00:00 zabbix_agentd: collector [idle 1 sec] zabbix 76197 76194 0 19:38 ? 00:00:00 zabbix_agentd: active checks #1 [idle 1 sec] root 76211 75384 0 19:42 pts/0 00:00:00 grep --colour=auto zabbix [root@linux-node2 ~]#
网页里添加主机
![](https://images2015.cnblogs.com/blog/1076878/201703/1076878-20170315194511870-1625467158.png)
![](https://images2015.cnblogs.com/blog/1076878/201703/1076878-20170315194706479-377368754.png)
![](https://images2015.cnblogs.com/blog/1076878/201703/1076878-20170315194819088-1446924269.png)
![](https://images2015.cnblogs.com/blog/1076878/201703/1076878-20170315194753901-1370764967.png)
mkdir /tools -p cd /tools/ wget http://repo.zabbix.com/zabbix/2.4/rhel/6/x86_64/zabbix-release-2.4-1.el6.noarch.rpm rpm -ivh zabbix-release-2.4-1.el6.noarch.rpm
yum install -y zabbix-proxy zabbix-proxy-mysql mysql-server
[root@linux-proxy tools]# yum install -y zabbix-proxy zabbix-proxy-mysql mysql-server Loaded plugins: fastestmirror, refresh-packagekit, security Setting up Install Process Loading mirror speeds from cached hostfile * base: mirrors.cn99.com * extras: mirrors.cn99.com * updates: mirrors.cn99.com Package zabbix-proxy-2.4.8-1.el6.x86_64 already installed and latest version Package zabbix-proxy-mysql-2.4.8-1.el6.x86_64 already installed and latest version Package mysql-server-5.1.73-8.el6_8.x86_64 already installed and latest version Nothing to do [root@linux-proxy tools]#
启动刚装的mysql,并设置密码
[root@linux-proxy tools]# /etc/init.d/mysqld start Initializing MySQL database: WARNING: The host 'linux-proxy.example.com' could not be looked up with resolveip. This probably means that your libc libraries are not 100 % compatible with this binary MySQL version. The MySQL daemon, mysqld, should work normally with the exception that host name resolving will not work. This means that you should use IP addresses instead of hostnames when specifying MySQL privileges ! Installing MySQL system tables... OK Filling help tables... OK To start mysqld at boot time you have to copy support-files/mysql.server to the right place for your system PLEASE REMEMBER TO SET A PASSWORD FOR THE MySQL root USER ! To do so, start the server, then issue the following commands: /usr/bin/mysqladmin -u root password 'new-password' /usr/bin/mysqladmin -u root -h linux-proxy.example.com password 'new-password' Alternatively you can run: /usr/bin/mysql_secure_installation which will also give you the option of removing the test databases and anonymous user created by default. This is strongly recommended for production servers. See the manual for more instructions. You can start the MySQL daemon with: cd /usr ; /usr/bin/mysqld_safe & You can test the MySQL daemon with mysql-test-run.pl cd /usr/mysql-test ; perl mysql-test-run.pl Please report any problems with the /usr/bin/mysqlbug script! [ OK ] Starting mysqld: [ OK ] [root@linux-proxy tools]# /usr/bin/mysqladmin -uroot password 'zabbix' [root@linux-proxy tools]# mysql -uroot -pzabbix Welcome to the MySQL monitor. Commands end with ; or \g. Your MySQL connection id is 3 Server version: 5.1.73 Source distribution Copyright (c) 2000, 2013, Oracle and/or its affiliates. All rights reserved. Oracle is a registered trademark of Oracle Corporation and/or its affiliates. Other names may be trademarks of their respective owners. Type 'help;' or '\h' for help. Type '\c' to clear the current input statement. mysql> show databases; +--------------------+ | Database | +--------------------+ | information_schema | | mysql | | test | +--------------------+ 3 rows in set (0.00 sec) mysql>
创建zabbix_proxy库,并授权zabbix用户,导入数据
[root@linux-proxy tools]# rpm -ql zabbix-proxy-mysql /usr/sbin/zabbix_proxy_mysql /usr/share/doc/zabbix-proxy-mysql-2.4.8 /usr/share/doc/zabbix-proxy-mysql-2.4.8/create /usr/share/doc/zabbix-proxy-mysql-2.4.8/create/schema.sql [root@linux-proxy tools]# /usr/bin/mysqladmin -uroot password 'zabbix' /usr/bin/mysqladmin: connect to server at 'localhost' failed error: 'Access denied for user 'root'@'localhost' (using password: NO)' [root@linux-proxy tools]# mysql -uroot -pzabbix Welcome to the MySQL monitor. Commands end with ; or \g. Your MySQL connection id is 5 Server version: 5.1.73 Source distribution Copyright (c) 2000, 2013, Oracle and/or its affiliates. All rights reserved. Oracle is a registered trademark of Oracle Corporation and/or its affiliates. Other names may be trademarks of their respective owners. Type 'help;' or '\h' for help. Type '\c' to clear the current input statement. mysql> create database zabbix_proxy character set utf8; Query OK, 1 row affected (0.00 sec) mysql> grant all on zabbix_proxy.* to zabbix@localhost identified by 'zabbix'; Query OK, 0 rows affected (0.00 sec) mysql> use zabbix_proxy; Database changed mysql> source /usr/share/doc/zabbix-proxy-mysql-2.4.8/create/schema.sql Query OK, 0 rows affected (0.01 sec) Query OK, 0 rows affected (0.02 sec) Records: 0 Duplicates: 0 Warnings: 0
[root@linux-proxy tools]# vim /etc/zabbix/zabbix_proxy.conf
看到如下注释,proxy也可以运行在Active和Passtive模式下,工作中主要还是运行在Active模式下
![](https://images2015.cnblogs.com/blog/1076878/201703/1076878-20170315222832776-1780901130.png)
![](https://images2015.cnblogs.com/blog/1076878/201703/1076878-20170315223150776-85409832.png)
DBHost和DBName都没变,不用修改
![](https://images2015.cnblogs.com/blog/1076878/201703/1076878-20170315223345338-878394599.png)
![](https://images2015.cnblogs.com/blog/1076878/201703/1076878-20170315223513573-2057909418.png)
检查配置
[root@linux-proxy tools]# vim /etc/zabbix/zabbix_proxy.conf [root@linux-proxy tools]# grep '^[a-Z]' /etc/zabbix/zabbix_proxy.conf ProxyMode=0 Server=10.0.1.161 Hostname=node3-proxy LogFile=/var/log/zabbix/zabbix_proxy.log LogFileSize=0 PidFile=/var/run/zabbix/zabbix_proxy.pid DBName=zabbix_proxy DBUser=zabbix DBPassword=zabbix DBSocket=/var/lib/mysql/mysql.sock ExternalScripts=/usr/lib/zabbix/externalscripts [root@linux-proxy tools]#
[root@linux-proxy tools]# /etc/init.d/zabbix-proxy start Starting Zabbix proxy: [ OK ] [root@linux-proxy tools]# netstat -lntp 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 2076/sshd tcp 0 0 0.0.0.0:10051 0.0.0.0:* LISTEN 13310/zabbix_proxy tcp 0 0 0.0.0.0:3306 0.0.0.0:* LISTEN 13219/mysqld tcp 0 0 :::22 :::* LISTEN 2076/sshd tcp 0 0 :::10051 :::* LISTEN 13310/zabbix_proxy [root@linux-proxy tools]#
![](https://images2015.cnblogs.com/blog/1076878/201703/1076878-20170315224008323-1415170280.png)
![](https://images2015.cnblogs.com/blog/1076878/201703/1076878-20170315224113635-383993138.png)
![](https://images2015.cnblogs.com/blog/1076878/201703/1076878-20170315224214448-1229938454.png)
![](https://images2015.cnblogs.com/blog/1076878/201703/1076878-20170315224557104-620250304.png)
下面这里要选择proxy
![](https://images2015.cnblogs.com/blog/1076878/201703/1076878-20170315224634370-2084341155.png)
![](https://images2015.cnblogs.com/blog/1076878/201703/1076878-20170315224743198-472344358.png)
![](https://images2015.cnblogs.com/blog/1076878/201703/1076878-20170315224837698-1057567368.png)
还需要把node2的指向改成proxy
[root@linux-node2 ~]# vim /etc/zabbix/zabbix_agentd.conf
下面改成proxy地址,因为它要把数据发给proxy
重启agent
[root@linux-node2 ~]# /etc/init.d/zabbix-agent restart Shutting down Zabbix agent: [ OK ] Starting Zabbix agent: [ OK ] [root@linux-node2 ~]#
[root@linux-proxy tools]# tail -f /var/log/zabbix/zabbix_proxy.log 13537:20170315:225713.912 proxy #17 started [http poller #1] 13542:20170315:225713.918 proxy #22 started [history syncer #4] 13531:20170315:225713.918 proxy #11 started [trapper #2] 13543:20170315:225713.918 proxy #23 started [self-monitoring #1] 13532:20170315:225713.918 proxy #12 started [trapper #3] 13528:20170315:225713.919 proxy #8 started [poller #5] 13533:20170315:225713.922 proxy #13 started [trapper #4] 13538:20170315:225713.941 proxy #18 started [discoverer #1] 13520:20170315:225813.966 sending heartbeat message to server failed: error:"negative response: "failed"", info:"proxy "linux-proxy.example.com" not found" 13534:20170315:225858.853 cannot send list of active checks to [10.0.1.162]: host [linux-node2.example.com] not found
[root@linux-proxy tools]# tail -f /var/log/zabbix/zabbix_proxy.log 13638:20170315:230149.414 proxy #17 started [http poller #1] 13642:20170315:230149.415 proxy #21 started [history syncer #3] 13634:20170315:230149.415 proxy #13 started [trapper #4] 13637:20170315:230149.420 proxy #16 started [housekeeper #1] 13641:20170315:230149.420 proxy #20 started [history syncer #2] 13633:20170315:230149.424 proxy #12 started [trapper #3] 13643:20170315:230149.426 proxy #22 started [history syncer #4] 13635:20170315:230149.431 proxy #14 started [trapper #5] 13639:20170315:230149.448 proxy #18 started [discoverer #1] 13620:20170315:230149.453 received configuration data from server, datalen 7423
![](https://images2015.cnblogs.com/blog/1076878/201703/1076878-20170315230816557-737045369.png)
![](https://images2015.cnblogs.com/blog/1076878/201703/1076878-20170315230910791-636626789.png)
Zabbox自动化监控---自动注册
自动化监控分为:
agent自动注册
server端自动发现
通过zabbix api方式插入数据(比如从cmdb读取资产里的主机,然后通过Zabbix的api插入Zabbix数据库)
![](https://images2015.cnblogs.com/blog/1076878/201703/1076878-20170316203101588-264582980.png)
![](https://images2015.cnblogs.com/blog/1076878/201703/1076878-20170316203117026-991052582.png)
![](https://images2015.cnblogs.com/blog/1076878/201703/1076878-20170316203218198-1434171183.png)
![](https://images2015.cnblogs.com/blog/1076878/201703/1076878-20170316203242526-759067210.png)
[root@linux-node1 ~]# zabbix_get -s 10.0.1.161 -k system.uname Linux linux-node1.example.com 2.6.32-504.el6.x86_64 #1 SMP Wed Oct 15 04:27:16 UTC 2014 x86_64
[root@linux-node2 ~]# /etc/init.d/zabbix-agent restart Shutting down Zabbix agent: [ OK ] Starting Zabbix agent: [ OK ] [root@linux-node2 ~]#
![](https://images2015.cnblogs.com/blog/1076878/201703/1076878-20170316203402682-429676673.png)
![](https://images2015.cnblogs.com/blog/1076878/201703/1076878-20170316203451323-133510329.png)
[root@linux-node1 ~]# zabbix_get -s 10.0.1.161 -k system.uname Linux linux-node1.example.com 2.6.32-504.el6.x86_64 #1 SMP Wed Oct 15 04:27:16 UTC 2014 x86_64
这两个条件
注意你的条件是a and b,operation 表示你想让它干什么。添加这台主机,然后添加主机组,再link一个模板
![](https://images2015.cnblogs.com/blog/1076878/201703/1076878-20170316203612416-681257510.png)
![](https://images2015.cnblogs.com/blog/1076878/201703/1076878-20170316203624620-2021218103.png)
![](https://images2015.cnblogs.com/blog/1076878/201703/1076878-20170316203640541-1961394815.png)
![](https://images2015.cnblogs.com/blog/1076878/201703/1076878-20170316203657823-1179380470.png)
![](https://images2015.cnblogs.com/blog/1076878/201703/1076878-20170316203747495-1912984023.png)
![](https://images2015.cnblogs.com/blog/1076878/201703/1076878-20170316203811198-187720488.png)
![](https://images2015.cnblogs.com/blog/1076878/201703/1076878-20170316203838682-650622519.png)
![](https://images2015.cnblogs.com/blog/1076878/201703/1076878-20170316203858198-850220638.png)
![](https://images2015.cnblogs.com/blog/1076878/201703/1076878-20170316203926463-122073929.png)
[root@linux-node2 ~]# grep '^[a-Z]' /etc/zabbix/zabbix_agentd.conf PidFile=/var/run/zabbix/zabbix_agentd.pid LogFile=/var/log/zabbix/zabbix_agentd.log LogFileSize=0 Server=10.0.1.161 StartAgents=3 ServerActive=127.0.0.1 Hostname=linux-node2.example.com HostMetadataItem=system.uname Include=/etc/zabbix/zabbix_agentd.d/ UserParameter=login-user,uptime | awk -F ' ' '{print $4}' [root@linux-node2 ~]#
[root@linux-node2 ~]# /etc/init.d/zabbix-agent restart Shutting down Zabbix agent: [ OK ] Starting Zabbix agent: [ OK ] [root@linux-node2 ~]#
![](https://images2015.cnblogs.com/blog/1076878/201703/1076878-20170316204018838-1022849473.png)
![](https://images2015.cnblogs.com/blog/1076878/201703/1076878-20170316204032776-640685428.png)
![](https://images2015.cnblogs.com/blog/1076878/201703/1076878-20170316204048870-1058479531.png)
![](https://images2015.cnblogs.com/blog/1076878/201703/1076878-20170316204056510-891096760.png)
![](https://images2015.cnblogs.com/blog/1076878/201703/1076878-20170316204109948-30212365.png)
![](https://images2015.cnblogs.com/blog/1076878/201703/1076878-20170316204116854-1706476825.png)
![](https://images2015.cnblogs.com/blog/1076878/201703/1076878-20170316204132901-881484571.png)
![](https://images2015.cnblogs.com/blog/1076878/201703/1076878-20170316204147276-360603516.png)
![](https://images2015.cnblogs.com/blog/1076878/201703/1076878-20170316204201323-640172477.png)
![](https://images2015.cnblogs.com/blog/1076878/201703/1076878-20170316204214682-821169666.png)
![](https://images2015.cnblogs.com/blog/1076878/201703/1076878-20170316204228729-3744792.png)