zabbix监控Linux和window
zabbix监控Linux
//使用scp将zbbbix软件从服务端传到客户端
[root@master ~]# scp -r zabbix-6.2.2.tar.gz 192.168.58.135:/opt/
//客户端进行解压
[root@slave1 opt]# tar xf zabbix-6.2.2.tar.gz -C /usr/src/
//创建系统用户zabbix
[root@slave1 ~]# useradd -r -M -s /sbin/nologin zabbix
//下载所需依赖包
[root@slave1 ~]# yum -y install wget pcre-devel libevent-devel net-snmp-devel gcc gcc-c++ make golang-bin
//编译安装
[root@slave1 ~]# cd /usr/src/zabbix-6.2.2/
[root@slave1 zabbix-6.2.2]# ./configure --enable-agent
[root@slave1 zabbix-6.2.2]# make install
//修改zabbix_agentd.conf文件配置
[root@slave1 ~]# cd /usr/local/etc/
[root@slave1 etc]# ls
zabbix_agentd.conf zabbix_agentd.conf.d
[root@slave1 etc]# vim zabbix_agentd.conf
Server=192.168.58.130 # Server指向服务端ip
ServerActive=192.168.58.130 # ServerActive指向服务端ip
Hostname=agent # 自定义名称,但是必须唯一
[root@slave1 etc]# zabbix_agentd
[root@slave1 etc]# ss -anlt
State Recv-Q Send-Q Local Address:Port Peer Address:Port Process
LISTEN 0 128 0.0.0.0:22 0.0.0.0:*
LISTEN 0 128 0.0.0.0:10050 0.0.0.0:*
LISTEN 0 128 [::]:22 [::]:*
web客服端添加服务器
zabbix监控window
下载zabbix_agentd
开始安装
添加监控主机
监控成功
手动添加监控项
创建一个用于测试的文件
[root@slave1 ~]# touch /tmp/cl
添加触发器
选择邮箱媒介
添加动作
添加qq邮箱白名单
写入数据
[root@slave1 ~]# echo 12233 >> /tmp/cl
(script方式)
[root@master ~]# hostnamectl set-hostname zabbix.alg.com
[root@master ~]# bash
[root@zabbix ~]# dnf -y install mailx postfix
//启动postfix,查看是否有25端口号
[root@zabbix ~]# systemctl enable --now postfix.service
Created symlink /etc/systemd/system/multi-user.target.wants/postfix.service → /usr/lib/systemd/system/postfix.service.
[root@zabbix ~]# ss -anlt |grep 25
LISTEN 0 100 127.0.0.1:25 0.0.0.0:*
LISTEN 0 100 [::1]:25 [::]:*
//编写脚本
#!/bin/bash
echo "$1" |mail -s "$2" $3
[root@zabbix ~]# chmod +x /usr/local/share/zabbix/alertscripts/ll.sh
qq邮箱添加白名单
发送警告信息使用默认
手动触发告警
[root@slave1 ~]# echo 12 >> /tmp/cl
收到警告