Windows主机监控

NAT网段下不能建立

查看真机IP,真机和NAT网段的虚拟机可以互通

zabbix 不同网段监控 网卡 zabbix监控windows跨网段_网络

但服务器用NAT模式下,和真机都不能建立监控关系。

桥接网络

服务器虚拟机采用桥接网络

zabbix 不同网段监控 网卡 zabbix监控windows跨网段_zabbix_02

服务器能PING通我的真机192.168.1.109和另一台同局域网的电脑192.168.1.105

zabbix 不同网段监控 网卡 zabbix监控windows跨网段_服务器_03

Agent2官网下载

真机为WIN10专业版,去官网下载Windows版agent2
https://www.zabbix.com/cn/download?zabbix=6.0&os_distribution=centos&os_version=7&components=proxy&db=mysql&ws=

zabbix 不同网段监控 网卡 zabbix监控windows跨网段_linux_04


zabbix 不同网段监控 网卡 zabbix监控windows跨网段_服务器_05

暂时不知道怎么卸载,如果后面要卸载的话再运行这个安装程序卸载它就行了

zabbix 不同网段监控 网卡 zabbix监控windows跨网段_网络_06


zabbix 不同网段监控 网卡 zabbix监控windows跨网段_网络_07

查看任务管理器确认agent客户端已经运行

zabbix 不同网段监控 网卡 zabbix监控windows跨网段_zabbix 不同网段监控 网卡_08

添加Windows监控主机

创建主机选择模板

zabbix 不同网段监控 网卡 zabbix监控windows跨网段_服务器_09


zabbix 不同网段监控 网卡 zabbix监控windows跨网段_服务器_10


zabbix 不同网段监控 网卡 zabbix监控windows跨网段_zabbix 不同网段监控 网卡_11

Windows添加监控完成

zabbix 不同网段监控 网卡 zabbix监控windows跨网段_服务器_12

LINUX主机监控,官网Agent2安装方式

确认Sever和Client互通

查看服务器上Zabbix的版本是6.0.12

zabbix server -v

桥接IP为192.168.0.105

zabbix 不同网段监控 网卡 zabbix监控windows跨网段_zabbix_13

另一台LINUX虚拟机为CentOS 7.9版本,同样设置为桥接网络,IP目前为192.168.0.104

zabbix 不同网段监控 网卡 zabbix监控windows跨网段_服务器_14

和Zabbix服务器是连通的,查看系统版本是3.10

cat /proc/version

zabbix 不同网段监控 网卡 zabbix监控windows跨网段_zabbix 不同网段监控 网卡_15

CentOS 7(被监控端)系统优化

关掉防火墙和Selinux后重启
 sudo setenforce 0
 sudo sed -i “s/SELINUX=enforcing/SELINUX=disabled/g” /etc/selinux/config
 sudo systemctl stop firewalld.service
 sudo systemctl disable firewalld.service
更换清华源
 cd /etc/yum.repos.d/
 mv CentOS-Base.repo CentOS-Base.repo.bak 将原先的源备份
 vim CentOS-Base.repo 新写一个源

vim cd /etc/yum.repos.d/CentOS-Base.repo
将下面的内容全部复制进这个文件即可
大家也可以去尝试其他的换源操作,只要正确换源了能用yum就行


#CentOS-Base.repo
#The mirror system uses the connecting IP address of the client and the
 #update status of each mirror to pick mirrors that are updated to and
 #geographically close to the client. You should use this for CentOS updates
 #unless you are manually picking other mirrors.#If the mirrorlist= does not work for you, as a fall back you can try the
 #remarked out baseurl= line instead.
[base]
 name=CentOS-releasever/os/KaTeX parse error: Expected 'EOF', got '#' at position 11: basearch/ #̲mirrorlist=http…releasever&arch=$basearch&repo=os
 gpgcheck=1
 gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-7#released updates
 [updates]
 name=CentOS-releasever/updates/KaTeX parse error: Expected 'EOF', got '#' at position 11: basearch/ #̲mirrorlist=http…releasever&arch=$basearch&repo=updates
 gpgcheck=1
 gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-7#additional packages that may be useful
 [extras]
 name=CentOS-releasever/extras/KaTeX parse error: Expected 'EOF', got '#' at position 11: basearch/ #̲mirrorlist=http…releasever&arch=$basearch&repo=extras
 gpgcheck=1
 gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-7#additional packages that extend functionality of existing packages
 [centosplus]
 name=CentOS-releasever/centosplus/KaTeX parse error: Expected 'EOF', got '#' at position 11: basearch/ #̲mirrorlist=http…releasever&arch=$basearch&repo=centosplus
 gpgcheck=1
 enabled=0
 gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-7

yum makecache
yum update

如果提示yum被锁住了,删除这个pid文件即可
rm -rf /var/run/yum.pid

可以按照这位博主的方式去清华源安装agent2
在镜像网站直接下载对应zabiix版本的agent客户端(例如我的就是zabbix6.0.12)

官网Agent2安装

zabbix 不同网段监控 网卡 zabbix监控windows跨网段_zabbix 不同网段监控 网卡_16

安装Zabbix源

#rpm -Uvh https://repo.zabbix.com/zabbix/6.0/rhel/7/x86_64/zabbix-release-6.0-4.el7.noarch.rpm
 yum clean all
 如果有进程pid需要等待
 rm -f /var/run/yum.pid
 安装agent2
 #yum install zabbix-agent2 zabbix-agent2-plugin-*
 更改配置文件
 vi /etc/zabbix/zabbix_agent2.conf

zabbix 不同网段监控 网卡 zabbix监控windows跨网段_网络_17


zabbix 不同网段监控 网卡 zabbix监控windows跨网段_服务器_18


zabbix 不同网段监控 网卡 zabbix监控windows跨网段_linux_19

grep -v “^#” /etc/zabbix/zabbix_agent2.conf

zabbix 不同网段监控 网卡 zabbix监控windows跨网段_zabbix 不同网段监控 网卡_20

启动服务

#systemctl restart zabbix-agent2
 #systemctl enable zabbix-agent2

zabbix 不同网段监控 网卡 zabbix监控windows跨网段_zabbix_21

添加主机

zabbix 不同网段监控 网卡 zabbix监控windows跨网段_zabbix_22


zabbix 不同网段监控 网卡 zabbix监控windows跨网段_zabbix_23

SNMP 协议方式监控LINUX主机

客户端(192.168.0.104)

yum -y install net-snmp net-snmp-utils
 rpm -ql net-snmp
 vim /etc/snmp/snmpd.conf

在第55行设置OID范围为最大view systemview included .1

zabbix 不同网段监控 网卡 zabbix监控windows跨网段_linux_24

systemctl restart snmpd.service #启动SNMP服务
systemctl enable snmpd.service #开机启动SNMP服务

服务器端(192.168.0.105)

yum -y install net-snmp net-snmp-utils
 systemctl restart snmpd.service #启动SNMP服务
 systemctl enable snmpd.service #开机启动SNMP服务

测试snmp命令:

snmpwalk -v 2c -c public 192.168.0.104 .1.3.6.1.4.1.2021.11.10.0

创建主机

zabbix 不同网段监控 网卡 zabbix监控windows跨网段_zabbix 不同网段监控 网卡_25


zabbix 不同网段监控 网卡 zabbix监控windows跨网段_zabbix_26

需要更改一些SNMP口令,在配置文件中如果改了community值,在这里也要对应更改

zabbix 不同网段监控 网卡 zabbix监控windows跨网段_服务器_27