zabbix监控详解
目录
本章是基于zabbix的基础使用和监控服务zabbix部署基础之上.
本章进行的操作是zabbix监控linux,windows以及配置邮件告警
环境 | IP | 要安装的服务 |
---|---|---|
服务器 | 192.168.222.250 | lamp架构 zabbix server zabbix agent |
客户端 | 192.168.222.251 | zabbix agent |
linux进行部署agentd
zabbix客户端部署
zabbix6.2源码包
[root@localhost ~]# cd /usr/local/etc/
[root@localhost etc]# useradd -rMs /sbin/nologin zabbix
//创建zabbix用户
[root@localhost etc]# cd /usr/src/
[root@localhost src]# wget https://cdn.zabbix.com/zabbix/sources/stable/6.2/zabbix-6.2.2.tar.gz
//下载源码包
[root@localhost src]# ls
debug kernels zabbix-6.2.2.tar.gz
[root@localhost src]# tar xf zabbix-6.2.2.tar.gz //解压
[root@localhost src]# cd zabbix-6.2.2/
[root@localhost zabbix-6.2.2]# dnf -y install openssl-devel pcre-devel expat-devel gcc gcc-c++ make
//安装依赖包
[root@localhost zabbix-6.2.2]# ./configure --enable-agent
//编译
....
***********************************************************
* Now run 'make install' *
* *
* Thank you for using Zabbix! *
* <http://www.zabbix.com> *
***********************************************************
[root@localhost zabbix-6.2.2]# make install
//安装
[root@localhost zabbix-6.2.2]# cd /usr/local/etc/
[root@localhost etc]# ls
zabbix_agentd.conf zabbix_agentd.conf.d
[root@localhost etc]# vim zabbix_agentd.conf
//修改配置文件
Server=192.168.222.250 //服务端ip
ServerActive=192.168.222.250 //服务端ip
Hostname=Zabbix xbz //zabbix系统内主机名,可自定义,但要确保唯一性
[root@localhost etc]# ldconfig //刷新配置
[root@localhost etc]# zabbix_agentd //启动zabbix_agentd
[root@localhost etc]# ss -antl //查看端口
State Recv-Q Send-Q Local Address:Port Peer Address:Port Process
LISTEN 0 128 0.0.0.0:10050 0.0.0.0:*
LISTEN 0 128 0.0.0.0:22 0.0.0.0:*
LISTEN 0 128 [::]:22 [::]:*
创建监控主机
点击右上角的创建
设置好后点右下角的添加
创建主机组并加入主机
添加监控项
用模板方式添加
此处需要关闭客户端的防火墙
[root@localhost ~]# systemctl stop firewalld.service
[root@localhost ~]# vim /etc/selinux/config
[root@localhost ~]# cat /etc/selinux/config
# This file controls the state of SELinux on the system.
# SELINUX= can take one of these three values:
# enforcing - SELinux security policy is enforced.
# permissive - SELinux prints warnings instead of enforcing.
# disabled - No SELinux policy is loaded.
SELINUX= disabled
# SELINUXTYPE= can take one of these three values:
# targeted - Targeted processes are protected,
# minimum - Modification of targeted policy. Only selected processes are protected.
# mls - Multi Level Security protection.
SELINUXTYPE=targeted
[root@localhost ~]# systemctl status firewalld.service
● firewalld.service - firewalld - dynamic firewall daemon
Loaded: loaded (/usr/lib/systemd/system/firewalld.service; enabled; vendor preset: enabled)
Active: inactive (dead) since Mon 2022-09-05 22:26:01 CST; 34s ago
Docs: man:firewalld(1)
Process: 634412 ExecStart=/usr/sbin/firewalld --nofork --nopid $FIREWALLD_ARGS (code=exited,>
Main PID: 634412 (code=exited, status=0/SUCCESS)
Sep 05 21:54:24 localhost systemd[1]: Starting firewalld - dynamic firewall daemon...
Sep 05 21:54:25 localhost systemd[1]: Started firewalld - dynamic firewall daemon.
Sep 05 21:54:25 localhost firewalld[634412]: WARNING: AllowZoneDrifting is enabled. This is co>
Sep 05 22:26:01 localhost systemd[1]: Stopping firewalld - dynamic firewall daemon...
Sep 05 22:26:01 localhost systemd[1]: firewalld.service: Succeeded.
Sep 05 22:26:01 localhost systemd[1]: Stopped firewalld - dynamic firewall daemon.
此外已经在进行监控
手动添加监控项
我们可以先在被监控端创建一个测试的文件
[root@localhost ~]# touch /tmp/xbz
查看监控数据
测试:修改一下文件
[root@localhost ~]# echo "xxx" >> /tmp/xbz
刷新查看
可以看到value发生了改变
添加触发器
开始添加一个监控文件的触发器
选择错误级别添加
点击添加,然后找到刚添加的触发器,可以看到触发器已经启动
再查看监控项,已经有了触发器
进行测试
[root@localhost ~]# echo "333" >> /tmp/xbz
//修改/tmp/xbz文件
查看数据
查看主页告警信息
添加媒介(email方式)
如果想实现邮箱告警的话,需要添加媒介
这里用网易126邮箱作为演示:
设置——常规设置
BCKKTNWDZOMCXJOS
开启后会获得一个授权密码,这个授权密码要保存下来,后面会用到
这媒介想要通过哪个用户进行邮件发送,发送给谁?
添加动作