zabbix监控配置
文章目录
- zabbix监控配置
- 1.添加主机组
- 2.添加主机(linux)
- 3.添加主机(windows)
- 4.监控项配置(通过模板添加)
- 5.监控项配置(手动添加)
1.添加主机组
2.添加主机(linux)
1.关闭防火墙和selinux
[root@localhost ~]# hostnamectl set-hostname zabbix-agent
[root@localhost ~]# bash
[root@zabbix-agent ~]# systemctl disable --now firewalld
Removed "/etc/systemd/system/multi-user.target.wants/firewalld.service".
Removed "/etc/systemd/system/dbus-org.fedoraproject.FirewallD1.service".
[root@zabbix-agent ~]# vi /etc/selinux/config
[root@zabbix-agent ~]# setenforce 0
[root@zabbix-agent ~]# getenforce
Permissive2.安装依赖包
[root@zabbix-agent ~]# yum -y install vim gcc gcc-c++ make pcre-devel
Complete!3.下载zabbix软件包,与解压
[root@zabbix-agent ~]# ls
anaconda-ks.cfg zabbix-6.4.10.tar.gz
[root@zabbix-agent ~]# tar xf zabbix-6.4.10.tar.gz
[root@zabbix-agent ~]# ls
anaconda-ks.cfg zabbix-6.4.10 zabbix-6.4.10.tar.gz4.编译
[root@zabbix-agent ~]# cd zabbix-6.4.10
[root@zabbix-agent zabbix-6.4.10]# ./configure --help | grep agent--enable-agent Turn on build of Zabbix agent and client utilities--enable-agent2 Turn on build of Zabbix agent 2
[root@zabbix-agent zabbix-6.4.10]# ./configure --enable-agent
***********************************************************
* Now run 'make install' *
* *
* Thank you for using Zabbix! *
* <http://www.zabbix.com> *
***********************************************************
[root@zabbix-agent zabbix-6.4.10]# make && make install
[root@zabbix-agent zabbix-6.4.10]# echo $?
05.配置配置文件
[root@zabbix-agent ~]# cd /usr/local/etc
[root@zabbix-agent etc]# ls
zabbix_agentd.conf zabbix_agentd.conf.d
[root@zabbix-agent etc]# vim zabbix_agentd.conf
Server=192.168.116.140 //服务端的ip
ServerActive=192.168.116.140
Hostname=zabbix_agent16.创建系统用户
[root@zabbix-agent ~]# useradd -r -M -s /sbin/nologin zabbix
[root@zabbix-agent ~]# id zabbix
uid=991(zabbix) gid=991(zabbix) groups=991(zabbix)7.启动服务
[root@zabbix-agent ~]# which zabbix_agentd
/usr/local/sbin/zabbix_agentd
[root@zabbix-agent ~]# zabbix_agentd
[root@zabbix-agent ~]# ss -antl
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 4096 0.0.0.0:10050 0.0.0.0:*
LISTEN 0 128 [::]:22 [::]:*
[root@zabbix-agent ~]# pkill zabbix
[root@zabbix-agent ~]# ss -antl
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 [::]:22 [::]:* 8.设置开机自启
[root@zabbix-agent ~]# cp /usr/lib/systemd/system/sshd.service /usr/lib/systemd/system/zabbix.service
[root@zabbix-agent ~]# vim /usr/lib/systemd/system/zabbix.service
[root@zabbix-agent ~]# cat /usr/lib/systemd/system/zabbix.service
[Unit]
Description=zabbix server daemon
After=network.target [Service]
Type=forking
ExecStart=/usr/local/sbin/zabbix_agentd
ExecStop=pkill zabbix
ExecReload=/bin/kill -HUP $MAINPID[Install]
WantedBy=multi-user.target
[root@zabbix-agent ~]# systemctl daemon-reload
[root@zabbix-agent ~]# systemctl enable --now zabbix
Created symlink /etc/systemd/system/multi-user.target.wants/zabbix.service → /usr/lib/systemd/system/zabbix.service.
[root@zabbix-agent ~]# ss -antl
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 4096 0.0.0.0:10050 0.0.0.0:*
LISTEN 0 128 [::]:22 [::]:* 9.查看ip
[root@zabbix-agent ~]# ip a
1: lo: <LOOPBACK,UP,LOWER_UP> mtu 65536 qdisc noqueue state UNKNOWN group default qlen 1000link/loopback 00:00:00:00:00:00 brd 00:00:00:00:00:00inet 127.0.0.1/8 scope host lovalid_lft forever preferred_lft foreverinet6 ::1/128 scope host valid_lft forever preferred_lft forever
2: ens33: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc fq_codel state UP group default qlen 1000link/ether 00:0c:29:7b:5e:5c brd ff:ff:ff:ff:ff:ffaltname enp2s1inet 192.168.116.143/24 brd 192.168.116.255 scope global dynamic noprefixroute ens33valid_lft 1719sec preferred_lft 1719secinet6 fe80::20c:29ff:fe7b:5e5c/64 scope link noprefixroute valid_lft forever preferred_lft forever
3.添加主机(windows)
zabbix软件包要到官网上面下(zabbix.com),找到windows下载
4.监控项配置(通过模板添加)
5.监控项配置(手动添加)
[root@zabbix-agent ~]# cd /tmp
[root@zabbix-agent tmp]# ls
systemd-private-f879be71d0184a0eb724ca54dddc2609-chronyd.service-r7YIxE vmware-root_738-2999591909
systemd-private-f879be71d0184a0eb724ca54dddc2609-dbus-broker.service-oPfTel zabbix_agentd.log
systemd-private-f879be71d0184a0eb724ca54dddc2609-kdump.service-jYfArx zabbix_agentd.pid
systemd-private-f879be71d0184a0eb724ca54dddc2609-systemd-logind.service-JozYSH
[root@zabbix-agent tmp]# touch abc
[root@zabbix-agent tmp]# ls
abc systemd-private-f879be71d0184a0eb724ca54dddc2609-systemd-logind.service-JozYSH
systemd-private-f879be71d0184a0eb724ca54dddc2609-chronyd.service-r7YIxE vmware-root_738-2999591909
systemd-private-f879be71d0184a0eb724ca54dddc2609-dbus-broker.service-oPfTel zabbix_agentd.log
systemd-private-f879be71d0184a0eb724ca54dddc2609-kdump.service-jYfArx zabbix_agentd.pid