Zabbix Server 和 Zabbix Agent 的详细安装过程(附带监控主机和监控参数的详细设置)
1、拓扑1.1 Zabbix 3.X 介绍
2、Zabbix Mysql 部署(本次实验 Zabbix Server 和 Mariadb 部署在同一主机)2.1 安装 Mariadb-server2.2 修改 Mariadb-server 的配置文件2.3 启动 Mariadb-server ,并设置为开机启动2.4 设置 Zabbix Server 使用的数据库(创建相应数据库并进行登陆授权)
3、Zabbix Server 部署(本次实验 Zabbix Server 和 Mariadb 部署在同一主机)3.1 确认安装 Zabbix 的版本(本次安装 3.4 的版本)3.1.1 [Zabbix 各个主要版本的链接](http://repo.zabbix.com/zabbix/)3.1.2 [Zabbix Documentation 3.4 手册链接,支持中文](https://www.zabbix.com/documentation/3.4/manual)
3.2 下载并安装 zabbix-release ,确定 Zabbix 版本(后续安装 Zabbix 其它程序时,不需指明详细版本号)3.3 安装 Zabbix Server 相关程序3.4 zabbix-server-mysql 程序环境介绍3.5 导入 zabbix-server-mysql 数据库结构,生成相应数据库环境3.6 Zabbix Server 的相关配置文件修改注意:Zabbix Server 的相关配置文件的相关注意事项(Socket 路径)
3.7 启动 Zabbix Server
4、Zabbix Web GUI 部署(本次实验与 Zabbix Server 和 mysql 部署在同一主机上)4.1 安装 php 相关软件4.2 安装 Zabbix Web GUI 相应软件4.3 查看并修改 Zabbix Web 的相关配置文件(安装完后,会在 httpd 的conf.d 目录下生成相应的 conf 文件)4.4 启动 httpd 进程
5、Zabbix Web 界面启动5.1 首次启动时,按照 Web 引导顺序进行设置5.2 按照 5.1 进行设置完毕后,Zabbix Server主机相应目录会生成相应的配置文件,相关配置也可以进行修改5.3 Zabbix Web 进行登陆
6、Zabbix Agent 部署6.1 下载并安装 zabbix-release ,确定 Zabbix 版本(后续安装 Zabbix 其它程序时,不需指明详细版本号)6.2 安装 Zabbix Agent 相应程序6.3 Zabbix Agent 程序文件6.4 Zabbix Agent 配置文件修改6.5 Zabbix Agent 服务启动
7、Zabbix Hosts 监控主机和监控项添加7.1 添加 Hosts7.2 添加监控项目7.2.1 Zabbix 内建 Item Key(Web GUI,可以查看 1 和 0 的具体含义,每个Key 后面都有详细的说明)7.2.2 Zabbix 内建 Item Key(Zabbix Server Get 查看)
7.3 监控数据查看7.4 监控数据查看(Zabbix_agent 命令采集数据)7.4.1 帮助查看7.4.2 命令使用
1、拓扑
1.1 Zabbix 3.X 介绍
# Server ## zabbix
-server
-mysql , zabbix
-get
# Web
GUI ## zabbix
-web , zabbix
-web
-mysql
# Agent ## zabbix
-agent , zabbix
-sender
# Proxy ## zabbix
-proxy
2、Zabbix Mysql 部署(本次实验 Zabbix Server 和 Mariadb 部署在同一主机)
2.1 安装 Mariadb-server
[root@Tang
-2 ~]# yum install mariadb
-server
-y
Updated
:
mariadb
-server
.x86_64
1:5.5.64-1.el7
Dependency Updated
:
mariadb
.x86_64
1:5.5.64-1.el7 mariadb
-devel
.x86_64
1:5.5.64-1.el7 mariadb
-libs
.x86_64
1:5.5.64-1.el7
Complete
!
2.2 修改 Mariadb-server 的配置文件
[root@Tang
-2 ~]# vim
/etc
/my
.cnf
skip_name_resolve
= ON
innodb_file_per_table
= ON
2.3 启动 Mariadb-server ,并设置为开机启动
[root@Tang
-2 ~]# systemctl start mariadb
.service
[root@Tang
-2 ~]# systemctl enable mariadb
.service
Created symlink
from /etc
/systemd
/system
/multi
-user
.target
.wants
/mariadb
.service to
/usr
/lib
/systemd
/system
/mariadb
.service
.
[root@Tang
-2 ~]# ss
-tnl
State Recv
-Q Send
-Q Local Address
:Port Peer Address
:Port
LISTEN 0 50 *:3306 *:*
LISTEN 0 128 *:111 *:*
LISTEN 0 128 *:22 *:*
LISTEN 0 100 127.0.0.1:25 *:*
LISTEN 0 128 :::111 :::*
LISTEN 0 128 :::22 :::*
2.4 设置 Zabbix Server 使用的数据库(创建相应数据库并进行登陆授权)
[root@Tang
-2 ~]# mysql
Welcome to the MariaDB monitor
. Commands end
with ; or \g
.
Your MariaDB connection id is
2
Server version
: 5.5.64-MariaDB MariaDB Server
Copyright (c
) 2000, 2018, Oracle
, MariaDB Corporation Ab and others
.
Type
'help;' or
'\h' for help
. Type
'\c' to clear the current input statement
.
MariaDB
[(none
)]> CREATE DATABASE zabbix
CHARSET 'utf8';
Query
OK, 1 row
affected (0.00 sec
)
MariaDB
[(none
)]> GRANT ALL ON zabbix
.* TO 'zbxuser'@
'172.16.141.%' IDENTIFIED BY 'zbxpass';
Query
OK, 0 rows
affected (0.00 sec
)
MariaDB
[(none
)]> GRANT ALL ON zabbix
.* TO 'zbxuser'@
'127.0.0.1' IDENTIFIED BY 'zbxpass';
Query
OK, 0 rows
affected (0.00 sec
)
MariaDB
[(none
)]> FLUSH PRIVILEGES;
Query
OK, 0 rows
affected (0.00 sec
)
MariaDB
[(none
)]> EXIT
Bye
3、Zabbix Server 部署(本次实验 Zabbix Server 和 Mariadb 部署在同一主机)
3.1 确认安装 Zabbix 的版本(本次安装 3.4 的版本)
3.1.1 Zabbix 各个主要版本的链接
3.1.2 Zabbix Documentation 3.4 手册链接,支持中文
3.2 下载并安装 zabbix-release ,确定 Zabbix 版本(后续安装 Zabbix 其它程序时,不需指明详细版本号)
[root@Tang
-2 ~]# rpm
-ivh http
://repo
.zabbix
.com
/zabbix
/3.4/rhel
/7/x86_64
/zabbix
-release
-3.4-2.el7
.noarch
.rpm
Retrieving http
://repo
.zabbix
.com
/zabbix
/3.4/rhel
/7/x86_64
/zabbix
-release
-3.4-2.el7
.noarch
.rpm
warning
: /var/tmp
/rpm
-tmp
.dwDcQV
: Header
V4 RSA/SHA512 Signature
, key
ID a14fe591
: NOKEY
Preparing
... #################################
[100%]
Updating
/ installing
...
1:zabbix
-release
-3.4-2.el7 #################################
[100%]
3.3 安装 Zabbix Server 相关程序
[root@Tang
-2 ~]# yum install
-y zabbix
-server
-mysql zabbix
-get
Installed
:
zabbix
-get.x86_64
0:3.4.15-1.el7 zabbix
-server
-mysql
.x86_64
0:3.4.15-1.el7
Dependency Installed
:
OpenIPMI
.x86_64
0:2.0.27-1.el7 OpenIPMI
-libs
.x86_64
0:2.0.27-1.el7 OpenIPMI
-modalias
.x86_64
0:2.0.27-1.el7
fping
.x86_64
0:3.10-4.el7 gnutls
.x86_64
0:3.3.29-9.el7_6 iksemel
.x86_64
0:1.4-2.el7
.centos
libevent
.x86_64
0:2.0.21-4.el7 libtool
-ltdl
.x86_64
0:2.4.2-22.el7_3 net
-snmp
-libs
.x86_64
1:5.7.2-43.el7
nettle
.x86_64
0:2.7.1-8.el7 trousers
.x86_64
0:0.3.14-2.el7 unixODBC
.x86_64
0:2.3.1-14.el7
Complete
!
3.4 zabbix-server-mysql 程序环境介绍
[root@Tang
-2 ~]# rpm
-ql zabbix
-server
-mysql
/etc
/logrotate
.d
/zabbix
-server
/etc
/zabbix
/zabbix_server
.conf # 配置文件
/usr
/lib
/systemd
/system
/zabbix
-server
.service # 程序文件
/usr
/lib
/tmpfiles
.d
/zabbix
-server
.conf
/usr
/lib
/zabbix
/alertscripts
/usr
/lib
/zabbix
/externalscripts
/usr
/sbin
/zabbix_server_mysql
/usr
/share
/doc
/zabbix
-server
-mysql
-3.4.15
/usr
/share
/doc
/zabbix
-server
-mysql
-3.4.15/AUTHORS
/usr
/share
/doc
/zabbix
-server
-mysql
-3.4.15/COPYING
/usr
/share
/doc
/zabbix
-server
-mysql
-3.4.15/ChangeLog
/usr
/share
/doc
/zabbix
-server
-mysql
-3.4.15/NEWS
/usr
/share
/doc
/zabbix
-server
-mysql
-3.4.15/README
/usr
/share
/doc
/zabbix
-server
-mysql
-3.4.15/create
.sql
.gz # 数据库结构
/usr
/share
/man
/man8
/zabbix_server
.8.gz
/var/log
/zabbix
/var/run
/zabbix
3.5 导入 zabbix-server-mysql 数据库结构,生成相应数据库环境
[root@Tang
-2 ~]# cp
/usr
/share
/doc
/zabbix
-server
-mysql
-3.4.15/create
.sql
.gz
./ # 把 Zabbix
-server
-mysql 的数据库压缩包 cp 到本地
[root@Tang
-2 ~]# ll
total
1248
-rw
-------. 1 root root
1607 Oct
16 13:38 anaconda
-ks
.cfg
-rw
-r
--r
--. 1 root root
1267039 Oct
28 17:28 create
.sql
.gz
-rw
-r
--r
--. 1 root root
35 Oct
17 12:15 test
.txt
[root@Tang
-2 ~]# gzip
-d create
.sql
.gz # 进行解压并删除原压缩包
[root@Tang
-2 ~]# ll
total
4884
-rw
-------. 1 root root
1607 Oct
16 13:38 anaconda
-ks
.cfg
-rw
-r
--r
--. 1 root root
4990625 Oct
28 17:28 create
.sql
-rw
-r
--r
--. 1 root root
35 Oct
17 12:15 test
.txt
[root@Tang
-2 ~]# mysql
-uzbxuser
-h127
.0.0.1 -pzbxpass zabbix
<./create
.sql # 进行数据库导入
[root@Tang
-2 ~]# mysql
-uzbxuser
-h127
.0.0.1 -pzbxpass # 登陆数据库,进行数据查看
Welcome to the MariaDB monitor
. Commands end
with ; or \g
.
Your MariaDB connection id is
5
Server version
: 5.5.64-MariaDB MariaDB Server
Copyright (c
) 2000, 2018, Oracle
, MariaDB Corporation Ab and others
.
Type
'help;' or
'\h' for help
. Type
'\c' to clear the current input statement
.
MariaDB
[(none
)]> use zabbix
; # 使用 zabbix 数据库
Reading table information
for completion
of table and column names
You can turn off
this feature to
get a quicker startup
with -A
Database changed
MariaDB
[zabbix
]> SHOW TABLES; # 查看载入的表
+----------------------------+
| Tables_in_zabbix
|
+----------------------------+
| acknowledges
|
| actions
|
| alerts
|
... 140 rows
...
| widget
|
| widget_field
|
+----------------------------+
140 rows
in set (0.00 sec
)
MariaDB
[zabbix
]> exit
3.6 Zabbix Server 的相关配置文件修改
[root@Tang
-2 ~]# cd
/etc
/zabbix
/
[root@Tang
-2 zabbix
]# cp zabbix_server
.conf
{,.bak
}
[root@Tang
-2 zabbix
]# ll
total
32
-rw
-r
-----. 1 root zabbix
15527 Nov
12 2018 zabbix_server
.conf
-rw
-r
-----. 1 root root
15527 Oct
28 17:34 zabbix_server
.conf
.bak
[root@Tang
-2 zabbix
]# grep
"^#####" zabbix_server
.conf
############
GENERAL PARAMETERS #################
############
ADVANCED PARAMETERS ################
#######
LOADABLE MODULES #######
#######
TLS-RELATED PARAMETERS #######
[root@Tang
-2 zabbix
]# vim zabbix_server
.conf
[root@Tang
-2 zabbix
]# grep
"^DB" zabbix_server
.conf
DBHost
=172.16.141.253 # 指定数据库的
IP 地址,用于登陆数据库
DBName
=zabbix # 指定数据库的数据库名称
DBUser
=zbxuser # 指定数据库的用户名
DBPassword
=zbxpass # 指定数据库的密码
[root@Tang
-2 zabbix
]# grep
"^Lis" zabbix_server
.conf
ListenPort
=10051 # Zabbix 监听的端口,默认是
10051
注意:Zabbix Server 的相关配置文件的相关注意事项(Socket 路径)
### 如果 DBHost 使用的是
127.0.0.1 的时候,这里需要进行修改,与 mariadb 配置文件中的 socket 路径一致 ###
### 因为配置问本地环回地址的话,需要使用 Socket 进行通信,所以路径要与 Mysql 配置文件中的路径相一致 ###
[root@Tang
-2 zabbix
]# grep
"^# DBSocket" zabbix_server
.conf
# DBSocket
=/tmp
/mysql
.sock
[root@Tang
-2 zabbix
]# cat
/etc
/my
.cnf
| grep socket
socket
=/var/lib
/mysql
/mysql
.sock
3.7 启动 Zabbix Server
[root@Tang
-2 zabbix
]# systemctl start zabbix
-server
.service
[root@Tang
-2 zabbix
]# systemctl status zabbix
-server
.service
4、Zabbix Web GUI 部署(本次实验与 Zabbix Server 和 mysql 部署在同一主机上)
4.1 安装 php 相关软件
[root@Tang
-2 zabbix
]# yum install httpd php php
-mysql php
-mbstring php
-gd php
-bcmath php
-ldap php
-xml
-y
4.2 安装 Zabbix Web GUI 相应软件
[root@Tang
-2 zabbix
]# yum install zabbix
-web zabbix
-web
-mysql
=====================================================================================================================================
Package Arch Version Repository Size
=====================================================================================================================================
Installing
:
zabbix
-web noarch
3.4.15-1.el7 zabbix
2.6 M
zabbix
-web
-mysql noarch
3.4.15-1.el7 zabbix
7.2 k
Transaction Summary
=====================================================================================================================================
Install
2 Packages
Total download size
: 2.6 M
Installed size
: 15 M
Is
this ok
[y
/d
/N]: y
Downloading packages
:
(1/2): zabbix
-web
-mysql
-3.4.15-1.el7
.noarch
.rpm
| 7.2 kB
00:00:00
(2/2): zabbix
-web
-3.4.15-1.el7
.noarch
.rpm
| 2.6 MB 00:00:23
-------------------------------------------------------------------------------------------------------------------------------------
Total
117 kB
/s
| 2.6 MB 00:00:23
Running transaction check
Running transaction test
Transaction test succeeded
Running transaction
Installing
: zabbix
-web
-mysql
-3.4.15-1.el7
.noarch
1/2
Installing
: zabbix
-web
-3.4.15-1.el7
.noarch
2/2
Verifying
: zabbix
-web
-3.4.15-1.el7
.noarch
1/2
Verifying
: zabbix
-web
-mysql
-3.4.15-1.el7
.noarch
2/2
Installed
:
zabbix
-web
.noarch
0:3.4.15-1.el7 zabbix
-web
-mysql
.noarch
0:3.4.15-1.el7
Complete
!
4.3 查看并修改 Zabbix Web 的相关配置文件(安装完后,会在 httpd 的conf.d 目录下生成相应的 conf 文件)
[root@Tang
-2 zabbix
]# rpm
-ql zabbix
-web
| grep conf$
/etc
/httpd
/conf
.d
/zabbix
.conf
/usr
/share
/zabbix
/conf
[root@Tang
-2 zabbix
]# cd
/etc
/httpd
/conf
.d
/
[root@Tang
-2 conf
.d
]# ll
total
28
-rw
-r
--r
--. 1 root root
2926 Aug
8 19:41 autoindex
.conf
-rw
-r
--r
--. 1 root root
13 Oct
17 13:26 mylisten
.conf
-rw
-r
--r
--. 1 root root
691 Oct
31 2018 php
.conf
-rw
-r
--r
--. 1 root root
366 Aug
8 19:42 README
-rw
-r
--r
--. 1 root root
1252 Aug
6 21:44 userdir
.conf
-rw
-r
--r
--. 1 root root
824 Aug
6 21:44 welcome
.conf
-rw
-r
--r
--. 1 root root
870 Jul
30 2018 zabbix
.conf
[root@Tang
-2 conf
.d
]# vim zabbix
.conf
php_value date
.timezone Asia
/Shanghai # 配置 php 时区参数
4.4 启动 httpd 进程
[root@Tang
-2 conf
.d
]# systemctl start httpd
.service
[root@Tang
-2 conf
.d
]# ss
-tnl
State Recv
-Q Send
-Q Local Address
:Port Peer Address
:Port
LISTEN 0 50 *:3306 *:*
LISTEN 0 128 *:22 *:*
LISTEN 0 100 127.0.0.1:25 *:*
LISTEN 0 128 *:10051 *:*
LISTEN 0 128 :::10090 :::*
LISTEN 0 128 :::80 :::*
LISTEN 0 128 :::22 :::*
LISTEN 0 100 ::1:25 :::*
LISTEN 0 128 :::10051 :::*
5、Zabbix Web 界面启动
5.1 首次启动时,按照 Web 引导顺序进行设置
web 地址是:http://Zabbix-Server-IP/zabbix 。
5.2 按照 5.1 进行设置完毕后,Zabbix Server主机相应目录会生成相应的配置文件,相关配置也可以进行修改
[root@Tang
-2 conf
.d
]# cat
/etc
/zabbix
/web
/zabbix
.conf
.php
<?php
global $
DB;
$
DB['TYPE'] = 'MYSQL';
$
DB['SERVER'] = '172.16.141.253';
$
DB['PORT'] = '0';
$
DB['DATABASE'] = 'zabbix';
$
DB['USER'] = 'zbxuser';
$
DB['PASSWORD'] = 'zbxpass';
$
DB['SCHEMA'] = '';
$
ZBX_SERVER = 'localhost';
$
ZBX_SERVER_PORT = '10051';
$
ZBX_SERVER_NAME = '';
$
IMAGE_FORMAT_DEFAULT = IMAGE_FORMAT_PNG;
5.3 Zabbix Web 进行登陆
6、Zabbix Agent 部署
6.1 下载并安装 zabbix-release ,确定 Zabbix 版本(后续安装 Zabbix 其它程序时,不需指明详细版本号)
[root@Tang
-1 ~]# rpm
-ivh http
://repo
.zabbix
.com
/zabbix
/3.4/rhel
/7/x86_64
/zabbix
-release
-3.4-2.el7
.noarch
.rpm
Retrieving http
://repo
.zabbix
.com
/zabbix
/3.4/rhel
/7/x86_64
/zabbix
-release
-3.4-2.el7
.noarch
.rpm
warning
: /var/tmp
/rpm
-tmp
.dwDcQV
: Header
V4 RSA/SHA512 Signature
, key
ID a14fe591
: NOKEY
Preparing
... #################################
[100%]
Updating
/ installing
...
1:zabbix
-release
-3.4-2.el7 #################################
[100%]
6.2 安装 Zabbix Agent 相应程序
[root@Tang
-1 ~]# yum install zabbix
-agent zabbix
-sender
-y
Dependencies Resolved
=====================================================================================================================================
Package Arch Version Repository Size
=====================================================================================================================================
Installing
:
zabbix
-agent x86_64
3.4.15-1.el7 zabbix
369 k
zabbix
-sender x86_64
3.4.15-1.el7 zabbix
270 k
Transaction Summary
=====================================================================================================================================
Install
2 Packages
Installed
:
zabbix
-agent
.x86_64
0:3.4.15-1.el7 zabbix
-sender
.x86_64
0:3.4.15-1.el7
Complete
!
6.3 Zabbix Agent 程序文件
[root@Tang
-1 ~]# rpm
-ql zabbix
-agent
/etc
/logrotate
.d
/zabbix
-agent
/etc
/zabbix
/zabbix_agentd
.conf # 配置文件
/etc
/zabbix
/zabbix_agentd
.d
/etc
/zabbix
/zabbix_agentd
.d
/userparameter_mysql
.conf
/usr
/lib
/systemd
/system
/zabbix
-agent
.service # 程序文件
/usr
/lib
/tmpfiles
.d
/zabbix
-agent
.conf
/usr
/sbin
/zabbix_agentd
/usr
/share
/doc
/zabbix
-agent
-3.4.15
/usr
/share
/doc
/zabbix
-agent
-3.4.15/AUTHORS
/usr
/share
/doc
/zabbix
-agent
-3.4.15/COPYING
/usr
/share
/doc
/zabbix
-agent
-3.4.15/ChangeLog
/usr
/share
/doc
/zabbix
-agent
-3.4.15/NEWS
/usr
/share
/doc
/zabbix
-agent
-3.4.15/README
/usr
/share
/man
/man8
/zabbix_agentd
.8.gz
/var/log
/zabbix
/var/run
/zabbix
[root@Tang
-1 ~]# cd
/etc
/zabbix
/
[root@Tang
-1 zabbix
]# grep
"^#####" zabbix_agentd
.conf
############
GENERAL PARAMETERS #################
##### Passive checks related # 被动监控相关配置
##### Active checks related # 主动监控相关配置
############
ADVANCED PARAMETERS #################
#######
USER-DEFINED MONITORED PARAMETERS ####### # 用户自定义的监控参数
#######
LOADABLE MODULES #######
#######
TLS-RELATED PARAMETERS #######
6.4 Zabbix Agent 配置文件修改
[root@Tang
-1 zabbix
]# ll
total
12
-rw
-r
--r
--. 1 root root
10632 Nov
12 2018 zabbix_agentd
.conf
drwxr
-xr
-x
. 2 root root
38 Oct
28 18:26 zabbix_agentd
.d
[root@Tang
-1 zabbix
]# cp zabbix_agentd
.conf
{,.bak
}
[root@Tang
-1 zabbix
]# ll
total
24
-rw
-r
--r
--. 1 root root
10632 Nov
12 2018 zabbix_agentd
.conf
-rw
-r
--r
--. 1 root root
10632 Oct
28 18:35 zabbix_agentd
.conf
.bak
drwxr
-xr
-x
. 2 root root
38 Oct
28 18:26 zabbix_agentd
.d
[root@Tang
-1 zabbix
]# cim zabbix_agentd
.conf
-bash
: cim
: command not found
[root@Tang
-1 zabbix
]# vim zabbix_agentd
.conf
[root@Tang
-1 zabbix
]# vim
~/.vimrc
[root@Tang
-1 zabbix
]# vim zabbix_agentd
.conf
##### Passive checks related
Server
=172.16.141.253 # 允许 zabbix server 进行数据采集,多台主机的话使用
, 分隔
ListenPort
=10050 # 监听端口
ListenIP
=0.0.0.0 # 监听地址,有多个地址时,可以指定监听地址
StartAgents
=3
##### Active checks related
ServerActive
=172.16.141.253
Hostname
=Tang
-1
6.5 Zabbix Agent 服务启动
[root@Tang
-1 zabbix
]# systemctl start zabbix
-agent
.service
[root@Tang
-1 zabbix
]# ss
-tnl
State Recv
-Q Send
-Q Local Address
:Port Peer Address
:Port
LISTEN 0 128 *:22 *:*
LISTEN 0 100 127.0.0.1:25 *:*
LISTEN 0 128 *:10050 *:*
LISTEN 0 128 :::22 :::*
LISTEN 0 100 ::1:25 :::*
LISTEN 0 128 :::10050 :::*
[root@Tang
-1 zabbix
]# systemctl enable zabbix
-agent
.service
Created symlink
from /etc
/systemd
/system
/multi
-user
.target
.wants
/zabbix
-agent
.service to
/usr
/lib
/systemd
/system
/zabbix
-agent
.service
.
[root@Tang
-1 zabbix
]# systemctl status zabbix
-agent
.service
● zabbix
-agent
.service
- Zabbix Agent
Loaded
: loaded (/usr
/lib
/systemd
/system
/zabbix
-agent
.service
; enabled
; vendor preset
: disabled
)
Active
: active (running
) since Mon
2019-10-28 18:37:13 CST; 25s ago
Main
PID: 14057 (zabbix_agentd
)
CGroup
: /system
.slice
/zabbix
-agent
.service
├─
14057 /usr
/sbin
/zabbix_agentd
-c
/etc
/zabbix
/zabbix_agentd
.conf
├─
14058 /usr
/sbin
/zabbix_agentd
: collector
[idle
1 sec
]
├─
14059 /usr
/sbin
/zabbix_agentd
: listener #
1 [waiting
for connection
]
├─
14060 /usr
/sbin
/zabbix_agentd
: listener #
2 [waiting
for connection
]
├─
14061 /usr
/sbin
/zabbix_agentd
: listener #
3 [waiting
for connection
]
└─
14062 /usr
/sbin
/zabbix_agentd
: active checks #
1 [idle
1 sec
]
Oct
28 18:37:13 Tang
-1 systemd
[1]: Starting Zabbix Agent
...
Oct
28 18:37:13 Tang
-1 systemd
[1]: Started Zabbix Agent
.
7、Zabbix Hosts 监控主机和监控项添加
7.1 添加 Hosts
7.2 添加监控项目
7.2.1 Zabbix 内建 Item Key(Web GUI,可以查看 1 和 0 的具体含义,每个Key 后面都有详细的说明)
7.2.2 Zabbix 内建 Item Key(Zabbix Server Get 查看)
[root@Tang
-2 ~]# zabbix_get
-s
172.16.141.209 -p
10050 -k
"net.if.collisions[enp1s0]"
0
[root@Tang
-2 ~]# zabbix_get
-s
172.16.141.209 -p
10050 -k
"net.if.out[enp1s0]"
50868584
[root@Tang
-2 ~]# zabbix_get
-s
172.16.141.209 -p
10050 -k
"net.if.in[enp1s0]"
126869198
[root@Tang
-2 ~]# zabbix_get
-s
172.16.141.209 -p
10050 -k
"agent.ping"
1
[root@Tang
-2 ~]# zabbix_get
-s
172.16.141.209 -p
10050 -k
"agent.ping"
1
[root@Tang
-2 ~]# zabbix_get
-s
172.16.141.209 -p
10050 -k
"agent.version"
3.4.15
[root@Tang
-2 ~]# zabbix_get
-s
172.16.141.209 -p
10050 -k
"agent.hostname"
Tang
-1
[root@Tang
-2 ~]# zabbix_get
-s
172.16.141.209 -p
10050 -k
"kernel.maxproc"
32768
[root@Tang
-2 ~]# zabbix_get
-s
172.16.141.209 -p
10050 -k
"kernel.maxfiles"
370250
[root@Tang
-2 ~]# zabbix_get
-s
172.16.141.209 -p
10050 -k
"net.dns"
1
[root@Tang
-2 ~]# zabbix_get
-s
172.16.141.209 -p
10050 -k
"net.tcp.listen[80]"
1
[root@Tang
-2 ~]# zabbix_get
-s
172.16.141.209 -p
10050 -k
"net.tcp.listen[443]"
0
[root@Tang
-2 ~]# zabbix_get
-s
172.16.141.209 -p
10050 -k
"net.if.in[enp1s0]"
169263716
[root@Tang
-2 ~]# zabbix_get
-s
172.16.141.209 -p
10050 -k
"net.if.in[enp1s0,packets]"
1874947
[root@Tang
-2 ~]# zabbix_get
-s
172.16.141.209 -p
10050 -k
"net.if.out[enp1s0,packets]"
1164000
[root@Tang
-2 ~]# zabbix_get
-s
172.16.141.209 -p
10050 -k
"net.if.in[enp1s0,bytes]"
169307905
[root@Tang
-2 ~]# zabbix_get
-s
172.16.141.209 -p
10050 -k
"net.if.out[enp1s0,bytes]"
83948810
[root@Tang
-1 ~]# ifconfig enp1s0
enp1s0
: flags
=4163<UP,BROADCAST,RUNNING,MULTICAST> mtu
1500
inet
172.16.141.209 netmask
255.255.255.0 broadcast
172.16.141.255
inet6 fe80
::6aed
:a4ff
:fe21
:d8d4 prefixlen
64 scopeid
0x20<link
>
ether
68:ed
:a4
:21:d8
:d4 txqueuelen
1000 (Ethernet
)
RX packets
1876303 bytes
169370666 (161.5 MiB
)
RX errors
0 dropped
134987 overruns
0 frame
0
TX packets
1164791 bytes
83995384 (80.1 MiB
)
TX errors
0 dropped
0 overruns
0 carrier
0 collisions
0
device memory
0xd0b00000-d0b1ffff
7.3 监控数据查看
7.4 监控数据查看(Zabbix_agent 命令采集数据)
7.4.1 帮助查看
[root@Tang
-2 ~]# zabbix_get
-h
usage
:
zabbix_get
-s host
-name
-or
-IP [-p port
-number
] [-I IP-address
] -k item
-key
zabbix_get
-s host
-name
-or
-IP [-p port
-number
] [-I IP-address
]
--tls
-connect cert
--tls
-ca
-file
CA-file
[--tls
-crl
-file
CRL-file
] [--tls
-agent
-cert
-issuer cert
-issuer
]
[--tls
-agent
-cert
-subject cert
-subject
]
--tls
-cert
-file cert
-file
--tls
-key
-file key
-file
-k item
-key
zabbix_get
-s host
-name
-or
-IP [-p port
-number
] [-I IP-address
]
--tls
-connect psk
--tls
-psk
-identity
PSK-identity
--tls
-psk
-file
PSK-file
-k item
-key
zabbix_get
-h
zabbix_get
-V
Example(s
):
zabbix_get
-s
127.0.0.1 -p
10050 -k
"system.cpu.load[all,avg1]"
zabbix_get
-s
127.0.0.1 -p
10050 -k
"system.cpu.load[all,avg1]" \
--tls
-connect cert
--tls
-ca
-file
/home
/zabbix
/zabbix_ca_file \
--tls
-agent
-cert
-issuer \
"CN=Signing CA,OU=IT operations,O=Example Corp,DC=example,DC=com" \
--tls
-agent
-cert
-subject \
"CN=server1,OU=IT operations,O=Example Corp,DC=example,DC=com" \
--tls
-cert
-file
/home
/zabbix
/zabbix_get
.crt \
--tls
-key
-file
/home
/zabbix
/zabbix_get
.key
zabbix_get
-s
127.0.0.1 -p
10050 -k
"system.cpu.load[all,avg1]" \
--tls
-connect psk
--tls
-psk
-identity
"PSK ID Zabbix agentd" \
--tls
-psk
-file
/home
/zabbix
/zabbix_agentd
.psk
Report bugs to
: <https
://support
.zabbix
.com
>
Zabbix home page
: <http
://www
.zabbix
.com
>
Documentation
: <https
://www
.zabbix
.com
/documentation
>
7.4.2 命令使用
[root@Tang
-2 ~]# zabbix_get
-s
172.16.141.209 -p
10050 -k
"system.cpu.switches"
4723022
[root@Tang
-2 ~]# zabbix_get
-s
172.16.141.209 -p
10050 -k
"system.cpu.switches"
4723252