文章目录
- 1. 将 zabbix server 添加到 zabbix web 监控平台
- 2. 将 zabbix agent 添加到 zabbix web 监控平台
- 3. 为 zabbix agent 创建自定义模板 Template
- 4. 基于 Template 模板创建自定义监控项
- 5. 自定义键值 logusers(该键值要求:监控有多少个用户连接 agent 端),应用集为 ssh
- 6. 创建 Template 模板的图形,将以上 5 个监控项制作成图形
- 7. 创建聚合图形,将监控项 cpu 1 分钟平均负载和有多少个用户连接 agent 端图形制作成聚合图形
- 8. 收藏该聚合图形,让其在仪表板中显示
- 9. 创建触发器,设置超过 7 个用户连接 agent 端,发出告警信息
服务器 IP:192.168.91.128
客户端 IP:192.168.91.131
1. 将 zabbix server 添加到 zabbix web 监控平台
[root@localhost ~]# hostnamectl set-hostname server
[root@localhost ~]# bash
[root@server ~]# cd /etc/zabbix/
[root@server zabbix]# ls
web zabbix_agentd.conf zabbix_agentd.d zabbix_server.conf
[root@server zabbix]# vim zabbix_agentd.conf
Server=127.0.0.1
ServerActive=127.0.0.1
Hostname=server //改为本机的hostname
[root@server zabbix]# vim /etc/hosts
192.168.91.128 server //添加此行
192.168.91.131 agnet //添加此行
[root@server zabbix]# systemctl restart zabbix-agent
[root@server zabbix]# systemctl enable zabbix-agent
2. 将 zabbix agent 添加到 zabbix web 监控平台
[root@localhost ~]# hostnamectl set-hostname agent
[root@localhost ~]# bash
[root@agent ~]# scp root@192.168.91.128:/etc/hosts /etc/hosts
The authenticity of host '192.168.91.128 (192.168.91.128)' can't be established.
ECDSA key fingerprint is SHA256:HzP5/q4QBCkMtXqvHhPqy72ytttOZ6AX9vvL7hzidU8.
Are you sure you want to continue connecting (yes/no/[fingerprint])? yes
Warning: Permanently added '192.168.91.128' (ECDSA) to the list of known hosts.
root@192.168.91.128's password:
hosts 100% 201 114.7KB/s 00:00
[root@agent ~]# scp root@192.168.91.128:/etc/yum.repos.d/zabbix.repo /etc/yum.repos.d/zabbix.repo
root@192.168.91.128's password:
zabbix.repo 100% 386 31.3KB/s 00:00
[root@agent ~]# systemctl stop firewalld
[root@agent ~]# systemctl disable firewalld
[root@agent ~]# vim /etc/selinux/config
SELINUX=disabled //disabled模式
[root@agent ~]# dnf -y install zabbix-agent
[root@agent ~]# vim /etc/zabbix/zabbix_agentd.conf
Server=192.168.91.128
ServerActive=192.168.91.128
Hostname=agent
[root@agent ~]# systemctl restart zabbix-agent
[root@agent ~]# systemctl enable zabbix-agent
3. 为 zabbix agent 创建自定义模板 Template
4. 基于 Template 模板创建自定义监控项
监控 cpu 1 分钟平均负载,应用集为 cpu
要求监控 cpu 5 分钟平均负载,应用集为 cpu
要求监控 cpu 15 分钟平均负载,应用集为 cpu
要求监控 agent 的 ssh 服务的 22 端口,应用集为 ssh
5. 自定义键值 logusers(该键值要求:监控有多少个用户连接 agent 端),应用集为 ssh
[root@agent ~]# vim /etc/zabbix/zabbix_agentd.conf
UserParameter=logusers,who | wc -l //取消注释,并填入内容
[root@agent ~]# systemctl restart zabbix-agent
[root@server ~]# yum -y install zabbix-get
[root@server ~]# zabbix_get -s 192.168.91.131 -k logusers //服务器端,测试键值
6. 创建 Template 模板的图形,将以上 5 个监控项制作成图形
7. 创建聚合图形,将监控项 cpu 1 分钟平均负载和有多少个用户连接 agent 端图形制作成聚合图形
8. 收藏该聚合图形,让其在仪表板中显示
9. 创建触发器,设置超过 7 个用户连接 agent 端,发出告警信息