zabbix web100 web200 web101 web102
监控软件:zabbix.tar.gz
traceroute www.baidu.com 系统自带的监控命令
1 监控
安装LNMP环境
Zabbix监控管理控制台需要通过Web页面展示出来,并且还需要使用MySQL来存储数据,因此需要先为Zabbix准备基础LNMP环境
[root@zabbix ~]# yum -y install gcc pcre-devel openssl-devel zlib-devel
[root@zabbix ~]# cd zabbix/
[root@zabbix zabbix]# tar -xf nginx-1.12.2.tar.gz
[root@zabbix zabbix]# cd nginx-1.12.2/
[root@zabbix nginx-1.12.2]# ./configure --with-http_ssl_module
[root@zabbix nginx-1.12.2]# make && make install
[root@zabbix ~]# yum -y install php php-mysql mariadb mariadb-devel mariadb-server
[root@zabbix ~]# yum -y install php-fpm-5.4.16-42.el7.x86_64.rpm
[root@zabbix ~]# yum -y install php-ldap.x86_64
[root@zabbix ~]# vim /usr/local/nginx/conf/nginx.conf
http { 17行
fastcgi_buffers 8 16k;
缓存php生成的页面内容,8个16k
fastcgi_buffer_size 32k;
缓存php生产的头部信息
fastcgi_connect_timeout 300;
连接PHP的超时时间
fastcgi_send_timeout 300;
发送请求的超时时间
fastcgi_read_timeout 300;
读取请求的超时时间
......................................................
location ~ .php$ { 65行
root html;
fastcgi_pass 127.0.0.1:9000;
fastcgi_index index.php;
fastcgi_param SCRIPT_FILENAME /scripts$fastcgi_script_name;
include fastcgi.conf;
}
***启动服务***
[root@zabbix ~]# systemctl start mariadb
[root@zabbix ~]# systemctl enable mariadb
[root@zabbix ~]# ss -ntulp | grep :3306
[root@zabbix ~]# systemctl start php-fpm
[root@zabbix ~]# systemctl enable php-fpm
[root@zabbix ~]# ss -ntulp | grep :9000
[root@zabbix ~]# ln -s /usr/local/nginx/sbin/nginx /sbin/nginx
[root@zabbix ~]# nginx
[root@zabbix ~]# ss -ntulp | grep :80
***测试页面***
[root@zabbix ~]# vim /usr/local/nginx/html/test.php
<?php
$i=33;
echo $i;
?>
[root@zabbix ~]# curl http://localhost/test.php
33
[root@zabbix ~]# tar -xf zabbix-3.4.4.tar.gz
[root@zabbix ~]# cd zabbix-3.4.4/
[root@zabbix zabbix-3.4.4]# yum -y install net-snmp-devel curl-devel
[root@zabbix zabbix-3.4.4]# yum -y install libevent-devel-2.0.21-4.el7.x86_64.rpm
[root@zabbix zabbix-3.4.4]# ./configure --enable-server --enable-proxy --enable-agent --with-mysql=/usr/bin/mysql_config --with-net-snmp --with-libcurl
Now run 'make install' *
*
Thank you for using Zabbix! *
<http://www.zabbix.com> *
[root@zabbix zabbix-3.4.4]# make && make install
***配制文件***
[root@zabbix zabbix-3.4.4]# ls /usr/local/etc/
zabbix_agentd.conf zabbix_proxy.conf zabbix_server.conf
zabbix_agentd.conf.d zabbix_proxy.conf.d zabbix_server.conf.d
***命令***
[root@zabbix zabbix-3.4.4]# ls /usr/local/bin/
zabbix_get zabbix_sender
***库文件***
[root@zabbix zabbix-3.4.4]# ls /usr/local/sbin/
zabbix_agentd zabbix_proxy zabbix_server
***初始化Zabbix***
创建数据库与数据库账户
[root@zabbix zabbix-3.4.4]# mysql
MariaDB [(none)]> create database zabbix character set utf8;
MariaDB [(none)]> grant all on zabbix.* to zabbix@'localhost' identified by 'zabbix';
MariaDB [(none)]> use zabbix;
MariaDB [zabbix]> show tables;
Empty set (0.00 sec)
[root@zabbix zabbix-3.4.4]# cd database/
[root@zabbix database]# cd mysql/
[root@zabbix mysql]# ls
data.sql images.sql schema.sql
[root@zabbix mysql]# mysql -uzabbix -pzabbix zabbix < schema.sql
[root@zabbix mysql]# mysql -uzabbix -pzabbix zabbix < images.sql
[root@zabbix mysql]# mysql -uzabbix -pzabbix zabbix < data.sql
[root@zabbix mysql]# mysql -uzabbix -pzabbix zabbix
MariaDB [zabbix]> show tables;
[root@zabbix mysql]# cd ../..
[root@zabbix zabbix-3.4.4]# ls frontends/
php
[root@zabbix zabbix-3.4.4]# cp -r frontends/php/ /usr/local/nginx/html/zabbix
[root@zabbix zabbix-3.4.4]# chmod -R 777 //usr/local/nginx/html/zabbix/
[root@zabbix zabbix-3.4.4]# cp -r frontends/php/ /usr/local/nginx/html/zabbix
[root@zabbix zabbix-3.4.4]# chmod -R 777 //usr/local/nginx/html/zabbix/
[root@zabbix zabbix-3.4.4]# rm -rf /usr/local/nginx/html/zabbix/^C
[root@zabbix zabbix-3.4.4]# cp -r frontends/php/* /usr/local/nginx/html/
[root@zabbix zabbix-3.4.4]# chmod -R 777 /usr/local/nginx/html/
[root@zabbix zabbix-3.4.4]# vim ~/.mysql_history
create database zabbix character set utf8;
grant all on zabbix.* to zabbix@'localhost' identified by 'zabbix';
修改Zabbix_server配置文件,设置数据库相关参数,启动Zabbix_server服务
Zabbix端口
[root@zabbix zabbix-3.4.4]# ss -utnlp | grep :10051
Zabbix监控配置文件
[root@zabbix ~]# vim /usr/local/etc/zabbix_server.conf
Zabbix代理配置文件
[root@zabbix ~]# vim /usr/local/etc/zabbix_proxy.conf
主配置文件
[root@zabbix ~]# vim /usr/local/etc/zabbix_agentd.conf
[root@zabbix zabbix-3.4.4]# echo $PATH
/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/root/bin
改监控配置文件
[root@zabbix ~]# vim /usr/local/etc/zabbix_server.conf
[root@zabbix zabbix-3.4.4]# ls /usr/local/sbin/
zabbix_agentd zabbix_proxy zabbix_server
启动zabbix服务
LogFile=/tmp/zabbix_server.log
日制文件 38行
DBHost=localhost
数据库主机,默认该行被注释 85行
DBName=zabbix
设置数据库名称 95行
DBUser=zabbix
设置数据库账户 111行
DBPassword=zabbix
设置数据库密码,默认该行被注释 119行
[root@zabbix zabbix-3.4.4]# which zabbix_server
[root@zabbix zabbix-3.4.4]# zabbix_server
zabbix_server [22186]: user zabbix does not exist
zabbix_server [22186]: cannot run as root!
[root@zabbix zabbix-3.4.4]# grep zabbix /etc/passwd
zabbix:x:1001:1001::/home/zabbix:/bin/bash
[root@zabbix zabbix-3.4.4]# zabbix_server
[root@zabbix zabbix-3.4.4]# ss -utnlp | grep :10051
[root@zabbix zabbix-3.4.4]# netstat -utnlp | grep :10051
[root@zabbix zabbix-3.4.4]# vim /usr/local/etc/zabbix_agentd.conf
LogFile=/tmp/zabbix_agentd.log
设置日志文件 25行
Server=127.0.0.1, 192.168.2.5
允许哪些主机监控本机 93行
ServerActive=127.0.0.1:10051
指定默认ip和端口 134行
Hostname=Zabbix server
设置本机主机名 145行
UnsafeUserParameters=1
是否允许自定义key 280行
***启动zabbix服务***
[root@zabbix zabbix-3.4.4]# zabbix_agentd
[root@zabbix zabbix-3.4.4]# zabbix_server
[root@zabbix zabbix-3.4.4]# killall -9 zabbix_server
[root@zabbix zabbix-3.4.4]# netstat -utnlp | grep :10050
[root@zabbix zabbix-3.4.4]# firefox http://192.168.2.5/index.php
第一次访问,初始化PHP页面会检查计算机环境是否满足要求,如果不满足会给出修改建议
默认会提示PHP的配置不满足环境要求,需要修改PHP配置文件
根据错误提示,修改PHP配置文件,满足Zabbix_server的Web环境要求
php-bcmath和php-mbstring都在lnmp_soft目录下有提供软件包
[root@zabbix ~]# yum -y install php-gd php-xml
[root@zabbix ~]# yum -y install php-bcmath-5.4.16-42.el7.x86_64.rpm
[root@zabbix ~]# yum -y install php-mbstring-5.4.16-42.el7.x86_64.rpm
[root@zabbix ~]# yum -y install php-ldap
[root@zabbix ~]# vim /etc/php.ini
post_max_size = 16M
POST数据最大容量 672行
max_execution_time = 300
最大执行时间,秒 384行
max_input_time = 300
服务器接收数据的时间限制 394行
date.timezone = Asia/Shanghai
设置时区 878行
memory_limit = 128M
内存容量限制 405行
[root@zabbix ~]# systemctl restart php-fpm
[root@zabbix ~]# cat /usr/local/nginx/html/conf/zabbix.conf.php
<?php
// Zabbix GUI configuration file.
global $DB;
$DB['TYPE'] = 'MYSQL';
$DB['SERVER'] = 'localhost';
$DB['PORT'] = '0';
$DB['DATABASE'] = 'zabbix';
$DB['USER'] = 'zabbix';
$DB['PASSWORD'] = 'zabbix';
// Schema name. Used for IBM DB2 and PostgreSQL.
$DB['SCHEMA'] = '';
$ZBX_SERVER = 'localhost';
$ZBX_SERVER_PORT = '10051';
$ZBX_SERVER_NAME = 'my';
$IMAGE_FORMAT_DEFAULT = IMAGE_FORMAT_PNG;
***报错日志***
[root@zabbix ~]# tail -f /usr/local/nginx/logs/error.log
监控服基本使用
1 修改管理员
2 修改语言
3 查看监控模板 配置-->模板
4 查看已经监控的主机 配置-->主机 -->启用
[root@zabbix ~]# netstat -utnlp | grep :10050
5 查看监控信息 监测中--->最新数据--->主机--> zabbix-server
***配置Zabbix监控服务***
[root@web100 ~]# yum -y install httpd
[root@web100 ~]# echo web100 > /var/www/html/test.html
[root@web100 ~]# systemctl restart httpd
[root@web100 ~]# systemctl enable httpd
[root@web100 ~]# curl http://localhost/test.html
web100
[root@web100 ~]# useradd -s /sbin/nologin zabbix
[root@web100 ~]# yum -y install gcc pcre-devel
[root@web100 ~]# tar -xf zabbix-3.4.4.tar.gz
[root@web100 zabbix-3.4.4]# ./configure --enable-agent
[root@web100 zabbix-3.4.4]# make install
查看命令
[root@web100 ~]# ls /usr/local/bin
zabbix_get zabbix_sender
查看服务启动命令
[root@web100 ~]# ls /usr/local/sbin/
zabbix_agentd
查看配置文件
[root@web100 ~]# ls /usr/local/etc/
zabbix_agentd.conf zabbix_agentd.conf.d
主配置文件
[root@web100 ~]# vim /usr/local/etc/zabbix_agentd.conf
LogFile=/tmp/zabbix_agentd.log
设置日志文件 30行
Server=127.0.0.1,192.168.2.5
允许哪些主机监控本机 93行
ServerActive=192.168.2.5:10051
指定默认ip和端口 134行
Hostname=web100
设置本机主机名 145行
UnsafeUserParameters=1
是否允许自定义key 280行
启动服务
[root@web100 ~]# zabbix_agentd
[root@web100 ~]# netstat -utnlp | grep :10050
***浏览http:/ip:/index.php
1 管理登陆管理页面***
![在这里插入图片描述](https://img-blog.csdnimg.cn/20190609202911639.jpg?x-oss-process=image/watermark,type_ZmFuZ3poZW5naGVpdGk,shadow_10,text_aHR0cHM6Ly9ibG9nLmNzZG4ubmV0L3FxXzQzMzk1NDI4,size_16,color_FFFFFF,t_70)
![在这里插入图片描述](https://img-blog.csdnimg.cn/20190609202922734.jpg?x-oss-process=image/watermark,type_ZmFuZ3poZW5naGVpdGk,shadow_10,text_aHR0cHM6Ly9ibG9nLmNzZG4ubmV0L3FxXzQzMzk1NDI4,size_16,color_FFFFFF,t_70)
![在这里插入图片描述](https://img-blog.csdnimg.cn/20190609202955564.jpg?x-oss-process=image/watermark,type_ZmFuZ3poZW5naGVpdGk,shadow_10,text_aHR0cHM6Ly9ibG9nLmNzZG4ubmV0L3FxXzQzMzk1NDI4,size_16,color_FFFFFF,t_70)
![在这里插入图片描述](https://img-blog.csdnimg.cn/20190609203011195.jpg?x-oss-process=image/watermark,type_ZmFuZ3poZW5naGVpdGk,shadow_10,text_aHR0cHM6Ly9ibG9nLmNzZG4ubmV0L3FxXzQzMzk1NDI4,size_16,color_FFFFFF,t_70)
![在这里插入图片描述](https://img-blog.csdnimg.cn/20190609203023570.jpg?x-oss-process=image/watermark,type_ZmFuZ3poZW5naGVpdGk,shadow_10,text_aHR0cHM6Ly9ibG9nLmNzZG4ubmV0L3FxXzQzMzk1NDI4,size_16,color_FFFFFF,t_70)
![在这里插入图片描述](https://img-blog.csdnimg.cn/20190609203248246.jpg?x-oss-process=image/watermark,type_ZmFuZ3poZW5naGVpdGk,shadow_10,text_aHR0cHM6Ly9ibG9nLmNzZG4ubmV0L3FxXzQzMzk1NDI4,size_16,color_FFFFFF,t_70)
***2 添加监控主机 配置-->主机-->创建主机-->主机-->模版***
![在这里插入图片描述](https://img-blog.csdnimg.cn/201906092043454.jpg?x-oss-process=image/watermark,type_ZmFuZ3poZW5naGVpdGk,shadow_10,text_aHR0cHM6Ly9ibG9nLmNzZG4ubmV0L3FxXzQzMzk1NDI4,size_16,color_FFFFFF,t_70)
***3 选择监控模板 Template App HTTP Service Template OS Linux***
![在这里插入图片描述](https://img-blog.csdnimg.cn/20190609204912933.jpg?x-oss-process=image/watermark,type_ZmFuZ3poZW5naGVpdGk,shadow_10,text_aHR0cHM6Ly9ibG9nLmNzZG4ubmV0L3FxXzQzMzk1NDI4,size_16,color_FFFFFF,t_70)
***不要点添加直接点模板***
![在这里插入图片描述](https://img-blog.csdnimg.cn/2019060920550019.jpg?x-oss-process=image/watermark,type_ZmFuZ3poZW5naGVpdGk,shadow_10,text_aHR0cHM6Ly9ibG9nLmNzZG4ubmV0L3FxXzQzMzk1NDI4,size_16,color_FFFFFF,t_70)
![在这里插入图片描述](https://img-blog.csdnimg.cn/20190609205638993.jpg?x-oss-process=image/watermark,type_ZmFuZ3poZW5naGVpdGk,shadow_10,text_aHR0cHM6Ly9ibG9nLmNzZG4ubmV0L3FxXzQzMzk1NDI4,size_16,color_FFFFFF,t_70)
![在这里插入图片描述](https://img-blog.csdnimg.cn/20190609220950461.jpg?x-oss-process=image/watermark,type_ZmFuZ3poZW5naGVpdGk,shadow_10,text_aHR0cHM6Ly9ibG9nLmNzZG4ubmV0L3FxXzQzMzk1NDI4,size_16,color_FFFFFF,t_70)
***4 查看监控数据 监测中-->最新数据-->HTTP service***
![在这里插入图片描述](https://img-blog.csdnimg.cn/20190609222618828.jpg?x-oss-process=image/watermark,type_ZmFuZ3poZW5naGVpdGk,shadow_10,text_aHR0cHM6Ly9ibG9nLmNzZG4ubmV0L3FxXzQzMzk1NDI4,size_16,color_FFFFFF,t_70)
![在这里插入图片描述](https://img-blog.csdnimg.cn/20190610100427832.jpg?x-oss-process=image/watermark,type_ZmFuZ3poZW5naGVpdGk,shadow_10,text_aHR0cHM6Ly9ibG9nLmNzZG4ubmV0L3FxXzQzMzk1NDI4,size_16,color_FFFFFF,t_70)
[root@web100 ~]# systemctl stop httpd
[root@web100 ~]# ss -utnlp | grep :80 没有了
***配置-->模板***
![在这里插入图片描述](https://img-blog.csdnimg.cn/20190610101502193.jpg?x-oss-process=image/watermark,type_ZmFuZ3poZW5naGVpdGk,shadow_10,text_aHR0cHM6Ly9ibG9nLmNzZG4ubmV0L3FxXzQzMzk1NDI4,size_16,color_FFFFFF,t_70)
***自定义监控(在被监控的主机上定义命令 给监控服务器使用)***
***配置在被监控的主机 192.168.2.100***
定义命令
[root@web100 ~]# sed -n '280p' /usr/local/etc/zabbix_agentd.conf
UnsafeUserParameters=1
[root@web100 ~]# grep -n "Include" /usr/local/etc/zabbix_agentd.conf
255:### Option: Include
261:# Include=
263:# Include=/usr/local/etc/zabbix_agentd.userparams.conf
264:# Include=/usr/local/etc/zabbix_agentd.conf.d/
265:# Include=/usr/local/etc/zabbix_agentd.conf.d/*.conf
[root@web100 ~]# sed -i '265s/^#//' /usr/local/etc/zabbix_agentd.conf
[root@web100 ~]# grep -n "Include" /usr/local/etc/zabbix_agentd.conf
255:### Option: Include
261:# Include=
263:# Include=/usr/local/etc/zabbix_agentd.userparams.conf
264:# Include=/usr/local/etc/zabbix_agentd.conf.d/
265: Include=/usr/local/etc/zabbix_agentd.conf.d/*.conf
或者
[root@web100 ~]# vim /usr/local/etc/zabbix_agentd.conf
Include=/usr/local/etc/zabbix_agentd.conf.d/*.conf 265行
UnsafeUserParameters=1 280行
[root@web100 ~]# wc -l /etc/passwd | awk '{print $1}'
42
[root@web100 ~]# vim /usr/local/etc/zabbix_agentd.conf.d/get_sum_users.conf
UserParameter=getusers,wc -l /etc/passwd | awk '{print $1}'
[root@web100 ~]# netstat -utnlp | grep zabbix
tcp 0 0 0.0.0.0:10050 0.0.0.0:* LISTEN 1362/zabbix_agentd
[root@web100 ~]# killall -9 zabbix_agentd
[root@web100 ~]# zabbix_agentd
[root@web100 ~]# ps -C zabbix_agentd
PID TTY TIME CMD
8829 ? 00:00:00 zabbix_agentd
8830 ? 00:00:00 zabbix_agentd
8831 ? 00:00:00 zabbix_agentd
8832 ? 00:00:00 zabbix_agentd
8833 ? 00:00:00 zabbix_agentd
8834 ? 00:00:00 zabbix_agentd
[root@web100 ~]# netstat -utnlp | grep :10050
tcp 0 0 0.0.0.0:10050 0.0.0.0:* LISTEN 8829/zabbix_agentd
验证定义结果
[root@web100 ~]# zabbix_get -s 127.0.0.1 -p 10050 -k getusers
42
命令行测试定义结果
[root@zabbix ~]# zabbix_get -s 192.168.2.100 -p 10050 -k getusers
42
***创建新监控模板***
![在这里插入图片描述](https://img-blog.csdnimg.cn/20190610142149649.jpg?x-oss-process=image/watermark,type_ZmFuZ3poZW5naGVpdGk,shadow_10,text_aHR0cHM6Ly9ibG9nLmNzZG4ubmV0L3FxXzQzMzk1NDI4,size_16,color_FFFFFF,t_70)
![在这里插入图片描述](https://img-blog.csdnimg.cn/20190610142411502.jpg?x-oss-process=image/watermark,type_ZmFuZ3poZW5naGVpdGk,shadow_10,text_aHR0cHM6Ly9ibG9nLmNzZG4ubmV0L3FxXzQzMzk1NDI4,size_16,color_FFFFFF,t_70)
![在这里插入图片描述](https://img-blog.csdnimg.cn/20190610142649911.jpg?x-oss-process=image/watermark,type_ZmFuZ3poZW5naGVpdGk,shadow_10,text_aHR0cHM6Ly9ibG9nLmNzZG4ubmV0L3FxXzQzMzk1NDI4,size_16,color_FFFFFF,t_70)
***创建应用集***
![在这里插入图片描述](https://img-blog.csdnimg.cn/20190610142910332.jpg?x-oss-process=image/watermark,type_ZmFuZ3poZW5naGVpdGk,shadow_10,text_aHR0cHM6Ly9ibG9nLmNzZG4ubmV0L3FxXzQzMzk1NDI4,size_16,color_FFFFFF,t_70)
![在这里插入图片描述](https://img-blog.csdnimg.cn/20190610143031940.jpg)
![在这里插入图片描述](https://img-blog.csdnimg.cn/2019061014322563.jpg?x-oss-process=image/watermark,type_ZmFuZ3poZW5naGVpdGk,shadow_10,text_aHR0cHM6Ly9ibG9nLmNzZG4ubmV0L3FxXzQzMzk1NDI4,size_16,color_FFFFFF,t_70)
***创建监控项(与监控命令绑定)***
![在这里插入图片描述](https://img-blog.csdnimg.cn/20190610143539354.jpg?x-oss-process=image/watermark,type_ZmFuZ3poZW5naGVpdGk,shadow_10,text_aHR0cHM6Ly9ibG9nLmNzZG4ubmV0L3FxXzQzMzk1NDI4,size_16,color_FFFFFF,t_70)
![在这里插入图片描述](https://img-blog.csdnimg.cn/20190610144621489.jpg?x-oss-process=image/watermark,type_ZmFuZ3poZW5naGVpdGk,shadow_10,text_aHR0cHM6Ly9ibG9nLmNzZG4ubmV0L3FxXzQzMzk1NDI4,size_16,color_FFFFFF,t_70)
![在这里插入图片描述](https://img-blog.csdnimg.cn/20190610145237985.jpg?x-oss-process=image/watermark,type_ZmFuZ3poZW5naGVpdGk,shadow_10,text_aHR0cHM6Ly9ibG9nLmNzZG4ubmV0L3FxXzQzMzk1NDI4,size_16,color_FFFFFF,t_70)
***直接点添加***
![在这里插入图片描述](https://img-blog.csdnimg.cn/20190610145425907.jpg?x-oss-process=image/watermark,type_ZmFuZ3poZW5naGVpdGk,shadow_10,text_aHR0cHM6Ly9ibG9nLmNzZG4ubmV0L3FxXzQzMzk1NDI4,size_16,color_FFFFFF,t_70)
![在这里插入图片描述](https://img-blog.csdnimg.cn/20190610145748945.jpg?x-oss-process=image/watermark,type_ZmFuZ3poZW5naGVpdGk,shadow_10,text_aHR0cHM6Ly9ibG9nLmNzZG4ubmV0L3FxXzQzMzk1NDI4,size_16,color_FFFFFF,t_70)
***监控主机100 调用新监控模板***
![在这里插入图片描述](https://img-blog.csdnimg.cn/20190610150152284.jpg?x-oss-process=image/watermark,type_ZmFuZ3poZW5naGVpdGk,shadow_10,text_aHR0cHM6Ly9ibG9nLmNzZG4ubmV0L3FxXzQzMzk1NDI4,size_16,color_FFFFFF,t_70)
![在这里插入图片描述](https://img-blog.csdnimg.cn/20190610150420621.jpg?x-oss-process=image/watermark,type_ZmFuZ3poZW5naGVpdGk,shadow_10,text_aHR0cHM6Ly9ibG9nLmNzZG4ubmV0L3FxXzQzMzk1NDI4,size_16,color_FFFFFF,t_70)
![在这里插入图片描述](https://img-blog.csdnimg.cn/20190610150605837.jpg)
***查看监控信息***
![在这里插入图片描述](https://img-blog.csdnimg.cn/20190610152332569.jpg?x-oss-process=image/watermark,type_ZmFuZ3poZW5naGVpdGk,shadow_10,text_aHR0cHM6Ly9ibG9nLmNzZG4ubmV0L3FxXzQzMzk1NDI4,size_16,color_FFFFFF,t_70)
![在这里插入图片描述](https://img-blog.csdnimg.cn/20190610152618200.jpg?x-oss-process=image/watermark,type_ZmFuZ3poZW5naGVpdGk,shadow_10,text_aHR0cHM6Ly9ibG9nLmNzZG4ubmV0L3FxXzQzMzk1NDI4,size_16,color_FFFFFF,t_70)
[root@web100 ~]# useradd ooxx
[root@web100 ~]# useradd uuoo
[root@zabbix ~]# zabbix_get -s 192.168.2.100 -p 10050 -k getusers
44
![在这里插入图片描述](https://img-blog.csdnimg.cn/20190610153049909.jpg?x-oss-process=image/watermark,type_ZmFuZ3poZW5naGVpdGk,shadow_10,text_aHR0cHM6Ly9ibG9nLmNzZG4ubmV0L3FxXzQzMzk1NDI4,size_16,color_FFFFFF,t_70)
***验证***
[root@zabbix ~]# netstat -utnlp | grep :80
[root@zabbix ~]# netstat -utnlp | grep :3306
[root@zabbix ~]# netstat -utnlp | grep :9000
[root@zabbix ~]# netstat -utnlp | grep :10051
***Zabbix报警机制***
触发器(tigger)
表达式-如内存不足300M,用户超过30个等
当触发条件发生后,会导致一个触发事件
触发事件会执行某个动作
动作
触发器的条件被触发后的行为
可以是发送邮件,也可以是重启某个服务等
![在这里插入图片描述](https://img-blog.csdnimg.cn/20190610162358399.jpg?x-oss-process=image/watermark,type_ZmFuZ3poZW5naGVpdGk,shadow_10,text_aHR0cHM6Ly9ibG9nLmNzZG4ubmV0L3FxXzQzMzk1NDI4,size_16,color_FFFFFF,t_70)
![在这里插入图片描述](https://img-blog.csdnimg.cn/20190610163224288.jpg?x-oss-process=image/watermark,type_ZmFuZ3poZW5naGVpdGk,shadow_10,text_aHR0cHM6Ly9ibG9nLmNzZG4ubmV0L3FxXzQzMzk1NDI4,size_16,color_FFFFFF,t_70)
![在这里插入图片描述](https://img-blog.csdnimg.cn/20190610163438170.jpg?x-oss-process=image/watermark,type_ZmFuZ3poZW5naGVpdGk,shadow_10,text_aHR0cHM6Ly9ibG9nLmNzZG4ubmV0L3FxXzQzMzk1NDI4,size_16,color_FFFFFF,t_70)
![在这里插入图片描述](https://img-blog.csdnimg.cn/20190610163657155.jpg?x-oss-process=image/watermark,type_ZmFuZ3poZW5naGVpdGk,shadow_10,text_aHR0cHM6Ly9ibG9nLmNzZG4ubmV0L3FxXzQzMzk1NDI4,size_16,color_FFFFFF,t_70)
![在这里插入图片描述](https://img-blog.csdnimg.cn/20190610163907729.jpg?x-oss-process=image/watermark,type_ZmFuZ3poZW5naGVpdGk,shadow_10,text_aHR0cHM6Ly9ibG9nLmNzZG4ubmV0L3FxXzQzMzk1NDI4,size_16,color_FFFFFF,t_70)
![在这里插入图片描述](https://img-blog.csdnimg.cn/20190610164357844.jpg?x-oss-process=image/watermark,type_ZmFuZ3poZW5naGVpdGk,shadow_10,text_aHR0cHM6Ly9ibG9nLmNzZG4ubmV0L3FxXzQzMzk1NDI4,size_16,color_FFFFFF,t_70)
![在这里插入图片描述](https://img-blog.csdnimg.cn/20190610164655926.jpg?x-oss-process=image/watermark,type_ZmFuZ3poZW5naGVpdGk,shadow_10,text_aHR0cHM6Ly9ibG9nLmNzZG4ubmV0L3FxXzQzMzk1NDI4,size_16,color_FFFFFF,t_70)
***创建触发器***
![在这里插入图片描述](https://img-blog.csdnimg.cn/20190610203923771.jpg?x-oss-process=image/watermark,type_ZmFuZ3poZW5naGVpdGk,shadow_10,text_aHR0cHM6Ly9ibG9nLmNzZG4ubmV0L3FxXzQzMzk1NDI4,size_16,color_FFFFFF,t_70)
![在这里插入图片描述](https://img-blog.csdnimg.cn/20190610204126981.jpg?x-oss-process=image/watermark,type_ZmFuZ3poZW5naGVpdGk,shadow_10,text_aHR0cHM6Ly9ibG9nLmNzZG4ubmV0L3FxXzQzMzk1NDI4,size_16,color_FFFFFF,t_70)
![在这里插入图片描述](https://img-blog.csdnimg.cn/20190610205206254.jpg?x-oss-process=image/watermark,type_ZmFuZ3poZW5naGVpdGk,shadow_10,text_aHR0cHM6Ly9ibG9nLmNzZG4ubmV0L3FxXzQzMzk1NDI4,size_16,color_FFFFFF,t_70)
[root@zabbix ~]# zabbix_get -s 192.168.2.100 -p 10050 -k getusers
44
![在这里插入图片描述](https://img-blog.csdnimg.cn/20190610204836680.jpg?x-oss-process=image/watermark,type_ZmFuZ3poZW5naGVpdGk,shadow_10,text_aHR0cHM6Ly9ibG9nLmNzZG4ubmV0L3FxXzQzMzk1NDI4,size_16,color_FFFFFF,t_70)
![在这里插入图片描述](https://img-blog.csdnimg.cn/20190610205509751.jpg?x-oss-process=image/watermark,type_ZmFuZ3poZW5naGVpdGk,shadow_10,text_aHR0cHM6Ly9ibG9nLmNzZG4ubmV0L3FxXzQzMzk1NDI4,size_16,color_FFFFFF,t_70)
***创建动作***
![在这里插入图片描述](https://img-blog.csdnimg.cn/20190610210420499.jpg?x-oss-process=image/watermark,type_ZmFuZ3poZW5naGVpdGk,shadow_10,text_aHR0cHM6Ly9ibG9nLmNzZG4ubmV0L3FxXzQzMzk1NDI4,size_16,color_FFFFFF,t_70)
[root@web100 ~]# useradd qq
![在这里插入图片描述](https://img-blog.csdnimg.cn/2019061021155920.jpg?x-oss-process=image/watermark,type_ZmFuZ3poZW5naGVpdGk,shadow_10,text_aHR0cHM6Ly9ibG9nLmNzZG4ubmV0L3FxXzQzMzk1NDI4,size_16,color_FFFFFF,t_70)
![在这里插入图片描述](https://img-blog.csdnimg.cn/20190610211839477.jpg?x-oss-process=image/watermark,type_ZmFuZ3poZW5naGVpdGk,shadow_10,text_aHR0cHM6Ly9ibG9nLmNzZG4ubmV0L3FxXzQzMzk1NDI4,size_16,color_FFFFFF,t_70)
![在这里插入图片描述](https://img-blog.csdnimg.cn/20190610212215132.jpg?x-oss-process=image/watermark,type_ZmFuZ3poZW5naGVpdGk,shadow_10,text_aHR0cHM6Ly9ibG9nLmNzZG4ubmV0L3FxXzQzMzk1NDI4,size_16,color_FFFFFF,t_70)
![在这里插入图片描述](https://img-blog.csdnimg.cn/20190610212350121.jpg?x-oss-process=image/watermark,type_ZmFuZ3poZW5naGVpdGk,shadow_10,text_aHR0cHM6Ly9ibG9nLmNzZG4ubmV0L3FxXzQzMzk1NDI4,size_16,color_FFFFFF,t_70)
[root@web100 ~]# userdel qq
![在这里插入图片描述](https://img-blog.csdnimg.cn/20190610212642520.jpg?x-oss-process=image/watermark,type_ZmFuZ3poZW5naGVpdGk,shadow_10,text_aHR0cHM6Ly9ibG9nLmNzZG4ubmV0L3FxXzQzMzk1NDI4,size_16,color_FFFFFF,t_70)
![在这里插入图片描述](https://img-blog.csdnimg.cn/20190610212910144.jpg?x-oss-process=image/watermark,type_ZmFuZ3poZW5naGVpdGk,shadow_10,text_aHR0cHM6Ly9ibG9nLmNzZG4ubmV0L3FxXzQzMzk1NDI4,size_16,color_FFFFFF,t_70)
***监控报警***
![在这里插入图片描述](https://img-blog.csdnimg.cn/20190610213542465.jpg?x-oss-process=image/watermark,type_ZmFuZ3poZW5naGVpdGk,shadow_10,text_aHR0cHM6Ly9ibG9nLmNzZG4ubmV0L3FxXzQzMzk1NDI4,size_16,color_FFFFFF,t_70)
***设置邮件***
![在这里插入图片描述](https://img-blog.csdnimg.cn/20190610214001375.jpg?x-oss-process=image/watermark,type_ZmFuZ3poZW5naGVpdGk,shadow_10,text_aHR0cHM6Ly9ibG9nLmNzZG4ubmV0L3FxXzQzMzk1NDI4,size_16,color_FFFFFF,t_70)
![在这里插入图片描述](https://img-blog.csdnimg.cn/20190610214134965.jpg?x-oss-process=image/watermark,type_ZmFuZ3poZW5naGVpdGk,shadow_10,text_aHR0cHM6Ly9ibG9nLmNzZG4ubmV0L3FxXzQzMzk1NDI4,size_16,color_FFFFFF,t_70)
[root@zabbix ~]# netstat -utnlp | grep :25
tcp 0 0 127.0.0.1:25 0.0.0.0:* LISTEN 1117/master
tcp6 0 0 ::1:25 :::* LISTEN 1117/master
[root@zabbix ~]# rpm -q postfix
postfix-2.10.1-6.el7.x86_64
[root@zabbix ~]# systemctl status postfix.service
[root@zabbix ~]# grep zabbix /etc/passwd
zabbix:x:1001:1001::/home/zabbix:/bin/bash
[root@zabbix ~]# mail -s "teduli" zabbix < /etc/passwd
[root@zabbix ~]# su - zabbix
[zabbix@zabbix ~]$ mail
Heirloom Mail version 12.5 7/5/10. Type ? for help.
"/var/spool/mail/zabbix": 1 message 1 new
N 1 root Mon Jun 10 21:56 60/2796 "teduli"
&
![在这里插入图片描述](https://img-blog.csdnimg.cn/20190610220555243.jpg?x-oss-process=image/watermark,type_ZmFuZ3poZW5naGVpdGk,shadow_10,text_aHR0cHM6Ly9ibG9nLmNzZG4ubmV0L3FxXzQzMzk1NDI4,size_16,color_FFFFFF,t_70)
[root@zabbix ~]# vim /etc/hosts
127.0.0.1 zabbix localhost localhost.localdomain localhost4 localhost4.localdomain4
::1 localhost localhost.localdomain localhost6 localhost6.localdomain6
***为账户添加Hedia***
![在这里插入图片描述](https://img-blog.csdnimg.cn/20190610221215849.jpg?x-oss-process=image/watermark,type_ZmFuZ3poZW5naGVpdGk,shadow_10,text_aHR0cHM6Ly9ibG9nLmNzZG4ubmV0L3FxXzQzMzk1NDI4,size_16,color_FFFFFF,t_70)
![在这里插入图片描述](https://img-blog.csdnimg.cn/20190610221621663.jpg?x-oss-process=image/watermark,type_ZmFuZ3poZW5naGVpdGk,shadow_10,text_aHR0cHM6Ly9ibG9nLmNzZG4ubmV0L3FxXzQzMzk1NDI4,size_16,color_FFFFFF,t_70)
![在这里插入图片描述](https://img-blog.csdnimg.cn/20190610221701673.jpg?x-oss-process=image/watermark,type_ZmFuZ3poZW5naGVpdGk,shadow_10,text_aHR0cHM6Ly9ibG9nLmNzZG4ubmV0L3FxXzQzMzk1NDI4,size_16,color_FFFFFF,t_70)
![在这里插入图片描述](https://img-blog.csdnimg.cn/20190610221757303.jpg?x-oss-process=image/watermark,type_ZmFuZ3poZW5naGVpdGk,shadow_10,text_aHR0cHM6Ly9ibG9nLmNzZG4ubmV0L3FxXzQzMzk1NDI4,size_16,color_FFFFFF,t_70)
![在这里插入图片描述](https://img-blog.csdnimg.cn/20190610222000488.jpg?x-oss-process=image/watermark,type_ZmFuZ3poZW5naGVpdGk,shadow_10,text_aHR0cHM6Ly9ibG9nLmNzZG4ubmV0L3FxXzQzMzk1NDI4,size_16,color_FFFFFF,t_70)
***创建动作***
![在这里插入图片描述](https://img-blog.csdnimg.cn/20190610222158955.jpg?x-oss-process=image/watermark,type_ZmFuZ3poZW5naGVpdGk,shadow_10,text_aHR0cHM6Ly9ibG9nLmNzZG4ubmV0L3FxXzQzMzk1NDI4,size_16,color_FFFFFF,t_70)
![在这里插入图片描述](https://img-blog.csdnimg.cn/2019061022331968.jpg?x-oss-process=image/watermark,type_ZmFuZ3poZW5naGVpdGk,shadow_10,text_aHR0cHM6Ly9ibG9nLmNzZG4ubmV0L3FxXzQzMzk1NDI4,size_16,color_FFFFFF,t_70)
![在这里插入图片描述](https://img-blog.csdnimg.cn/20190610223722995.jpg?x-oss-process=image/watermark,type_ZmFuZ3poZW5naGVpdGk,shadow_10,text_aHR0cHM6Ly9ibG9nLmNzZG4ubmV0L3FxXzQzMzk1NDI4,size_16,color_FFFFFF,t_70)
![在这里插入图片描述](https://img-blog.csdnimg.cn/20190610223839316.jpg?x-oss-process=image/watermark,type_ZmFuZ3poZW5naGVpdGk,shadow_10,text_aHR0cHM6Ly9ibG9nLmNzZG4ubmV0L3FxXzQzMzk1NDI4,size_16,color_FFFFFF,t_70)
![在这里插入图片描述](https://img-blog.csdnimg.cn/20190610224005253.jpg?x-oss-process=image/watermark,type_ZmFuZ3poZW5naGVpdGk,shadow_10,text_aHR0cHM6Ly9ibG9nLmNzZG4ubmV0L3FxXzQzMzk1NDI4,size_16,color_FFFFFF,t_70)
***效果测试(在被监控主机100创建账户)***
![在这里插入图片描述](https://img-blog.csdnimg.cn/20190611102438969.jpg?x-oss-process=image/watermark,type_ZmFuZ3poZW5naGVpdGk,shadow_10,text_aHR0cHM6Ly9ibG9nLmNzZG4ubmV0L3FxXzQzMzk1NDI4,size_16,color_FFFFFF,t_70)
[root@zabbix ~]# useradd yy
![在这里插入图片描述](https://img-blog.csdnimg.cn/20190611102932293.jpg?x-oss-process=image/watermark,type_ZmFuZ3poZW5naGVpdGk,shadow_10,text_aHR0cHM6Ly9ibG9nLmNzZG4ubmV0L3FxXzQzMzk1NDI4,size_16,color_FFFFFF,t_70)
![在这里插入图片描述](https://img-blog.csdnimg.cn/20190611103105573.jpg?x-oss-process=image/watermark,type_ZmFuZ3poZW5naGVpdGk,shadow_10,text_aHR0cHM6Ly9ibG9nLmNzZG4ubmV0L3FxXzQzMzk1NDI4,size_16,color_FFFFFF,t_70)
![在这里插入图片描述](https://img-blog.csdnimg.cn/20190611103230939.jpg?x-oss-process=image/watermark,type_ZmFuZ3poZW5naGVpdGk,shadow_10,text_aHR0cHM6Ly9ibG9nLmNzZG4ubmV0L3FxXzQzMzk1NDI4,size_16,color_FFFFFF,t_70)
[root@zabbix ~]# su - zabbix
[zabbix@zabbix ~]$ mail
Heirloom Mail version 12.5 7/5/10. Type ? for help.
"/var/spool/mail/zabbix": 2 messages 1 new 2 unread
U 1 root Mon Jun 10 21:56 61/2806 "teduli"
N 2 zabbix@localhost.loc Tue Jun 11 10:28 20/810 "big44"
& 2
Message 2:
From zabbix@localhost.localdomain Tue Jun 11 10:28:04 2019
Return-Path: zabbix@localhost.localdomain
X-Original-To: zabbix@localhost
Delivered-To: zabbix@localhost.localdomain
From: zabbix@localhost.localdomain
To: zabbix@localhost.localdomain
Date: Tue, 11 Jun 2019 10:28:04 +0800
Subject: big44
Content-Type: text/plain; charset="UTF-8"
Status: R
Problem started at 10:28:01 on 2019.06.11
Problem name: web100_users
Host: web100
Severity: Disaster
Original problem ID: 167
***自动发现***
自动发现(Discovery)
当Zabbix需要监控的设备越来越多,手动添加监控设备越来越有挑战,这时,可以考虑使用自动发现功能
需要批量一次性添加一组监控主机,也可以使用自动发现功能
自动发现可以实现:
自动发现、添加主机,自动添加主机到组
自动连接模板到主机,自动创建监控项目与图形等
自动发现(Discovery)流程
创建自动发现规则
创建Action动作,说明发现主机后自动执行什么动作
通过动作,执行添加主机,链接模板到主机等操作
![在这里插入图片描述](https://upload-images.jianshu.io/upload_images/17661211-16f832ebcf7dc422?imageMogr2/auto-orient/strip%7CimageView2/2/w/1240)
![在这里插入图片描述](https://upload-images.jianshu.io/upload_images/17661211-fabfa8526f4aca37?imageMogr2/auto-orient/strip%7CimageView2/2/w/1240)
![在这里插入图片描述](https://upload-images.jianshu.io/upload_images/17661211-51072ba3ca279529?imageMogr2/auto-orient/strip%7CimageView2/2/w/1240)
![在这里插入图片描述](https://upload-images.jianshu.io/upload_images/17661211-623fdedcaad7a530?imageMogr2/auto-orient/strip%7CimageView2/2/w/1240)
![在这里插入图片描述](https://upload-images.jianshu.io/upload_images/17661211-be4bcb5ce9a1e94b?imageMogr2/auto-orient/strip%7CimageView2/2/w/1240)
![在这里插入图片描述](https://upload-images.jianshu.io/upload_images/17661211-b6bc7414f2c681e1?imageMogr2/auto-orient/strip%7CimageView2/2/w/1240)
![在这里插入图片描述](https://upload-images.jianshu.io/upload_images/17661211-01c8e60ad9a6ab39?imageMogr2/auto-orient/strip%7CimageView2/2/w/1240)
![在这里插入图片描述](https://upload-images.jianshu.io/upload_images/17661211-524820968cd2128d?imageMogr2/auto-orient/strip%7CimageView2/2/w/1240)
![在这里插入图片描述](https://upload-images.jianshu.io/upload_images/17661211-60a5c0ef621ed735?imageMogr2/auto-orient/strip%7CimageView2/2/w/1240)
***查看***
![在这里插入图片描述](https://upload-images.jianshu.io/upload_images/17661211-3fed2c4915a64415?imageMogr2/auto-orient/strip%7CimageView2/2/w/1240)