Zabbix基础

1、将zabbix server添加到zabbix web监控平台

[root@localhost ~]# hostname server
[root@localhost ~]# bash
[root@server ~]# hostname
server

[root@localhost ~]# cd /etc/zabbix/
[root@localhost zabbix]# ls
web                 zabbix_agentd.d     zabbix_server.conf.rpmsave
zabbix_agentd.conf  zabbix_server.conf

[root@server zabbix]# vim /etc/hosts
(以下是添加到配置文件)
192.168.46.129 server
192.168.46.132 agent1


[root@localhost zabbix]# vim zabbix_agentd.conf

Server=127.0.0.1(默认是zabbix的ip地址,不用改)
ServerActive=127.0.0.1(活动的服务器ip地址,默认的也不需要改)
Hostname=server(修改成自己的主机名)


[root@server zabbix]# systemctl restart zabbix-agent.service
[root@server zabbix]# systemctl enable zabbix-agent.service
Created symlink /etc/systemd/system/multi-user.target.wants/zabbix-agent.service → /usr/lib/systemd/system/zabbix-agent.service.

中文界面的显示方法

 一、zabbix没有中文选项怎么解决 
1、yum -y reinstall glibc-common 
2、yum -y install langpacks-zh_CN.noarch 
3、locale -a 查看 
4、刷新zabbix WEB就行,然后就有中文选项了。 
二、解决中文乱码问题 
1、找到windows下的简体 楷体 常规字体 
C:\Windows\Fonts 
2、将简体 楷体 常规字体文件复制出来 
3、上传到Linux系统中的/usr/share/zabbix/assets/fonts 
4、替换原先的字体文件即可 
mv simkai.ttf graphfont.ttf

首先把中文添加进来
[root@server zabbix]# yum -y reinstall glibc-common
Complete!

[root@server zabbix]# yum -y install langpacks-zh_CN.noarch
Complete!

[root@server zabbix]# locale -a
C
C.utf8
en_AG
en_AU
en_AU.utf8
en_BW
en_BW.utf8
en_CA
en_CA.utf8
en_DK
en_DK.utf8
en_GB
en_GB.iso885915
en_GB.utf8
en_HK
en_HK.utf8
en_IE
en_IE@euro
en_IE.utf8
en_IL
en_IN
en_NG
en_NZ
en_NZ.utf8
en_PH
en_PH.utf8
en_SC.utf8
en_SG
en_SG.utf8
en_US
en_US.iso885915
en_US.utf8
en_ZA
en_ZA.utf8
en_ZM
en_ZW
en_ZW.utf8
POSIX
zh_CN (简体中文)
zh_CN.gb18030
zh_CN.gbk
zh_CN.utf8
zh_HK (繁体中文)
zh_HK.utf8
zh_SG
zh_SG.gbk
zh_SG.utf8
zh_TW
zh_TW.euctw
zh_TW.utf8

 

 

2、将zabbix agent添加到zabbix web监控平台 

开启另一个虚拟机(2号虚拟机)
[root@localhost ~]# hostname agent1
[root@localhost ~]# bash
[root@agent1 ~]# hostname
agent

[root@agent1 ~]# ip a
1: lo: <LOOPBACK,UP,LOWER_UP> mtu 65536 qdisc noqueue state UNKNOWN group default qlen 1000
    link/loopback 00:00:00:00:00:00 brd 00:00:00:00:00:00
    inet 127.0.0.1/8 scope host lo
       valid_lft forever preferred_lft forever
    inet6 ::1/128 scope host
       valid_lft forever preferred_lft forever
2: ens160: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc mq state UP group default qlen 1000
    link/ether 00:0c:29:9b:04:17 brd ff:ff:ff:ff:ff:ff
    inet 192.168.46.132/24 brd 192.168.46.255 scope global dynamic noprefixroute ens160
       valid_lft 1316sec preferred_lft 1316sec
    inet6 fe80::fc2a:1900:5fbd:29eb/64 scope link noprefixroute
       valid_lft forever preferred_lft forever

[root@agent1 ~]# scp root@192.168.46.129:/etc/hosts /etc/hosts
root@192.168.46.129's password:
hosts                                         100%  202    69.5KB/s   00:00

[root@agent1 ~]# cat /etc/hosts
127.0.0.1   localhost localhost.localdomain localhost4 localhost4.localdomain4
::1         localhost localhost.localdomain localhost6 localhost6.localdomain6
192.168.46.129 server
192.168.46.132 agent1

[root@agent1 ~]# systemctl stop firewalld
[root@agent1 ~]# systemctl disable firewalld
Removed /etc/systemd/system/multi-user.target.wants/firewalld.service.
Removed /etc/systemd/system/dbus-org.fedoraproject.FirewallD1.service.
[root@agent1 ~]# vim /etc/selinux/config
SELINUX=disabled

配置zabbix源
[root@agent1 ~]# vim /etc/yum.repos.d/zabbix.repo

[aliyun]
name=aliyun
baseurl=https://mirrors.aliyun.com/zabbix/zabbix/4.4/rhel/8/x86_64/
enable=1
gpgcheck=0
[qinghua]
name=Zabbix Official Repository - $basearch
#baseurl=http://repo.zabbix.com/zabbix/3.4/rhel/7/$basearch/
baseurl=https://mirrors.tuna.tsinghua.edu.cn/zabbix/zabbix/4.4/rhel/8/$basearch/
enabled=1
gpgcheck=0
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-ZABBIX-A14FE591

[root@agent1 ~]# yum -y install zabbix-agent
Complete!

[root@agent1 ~]# vim /etc/zabbix/zabbix_agentd.conf
Server=192.168.46.129(修改为服务器的ip)
ServerActive=192.168.46.129(修改为服务器的ip)
Hostname=agent1 (修改为自己的主机名agent1)

[root@agent1 ~]# systemctl restart zabbix-agent.service
[root@agent1 ~]# systemctl enable zabbix-agent.service
Created symlink /etc/systemd/system/multi-user.target.wants/zabbix-agent.service → /usr/lib/systemd/system/zabbix-agent.service.

 

 

 

 

简体中文乱码的解决办法 

 

[root@server zabbix]# cd /usr/share/zabbix/assets/fonts/
[root@server fonts]# ls
graphfont.ttf

[root@server fonts]# pwd
/usr/share/zabbix/assets/fonts

 

下载一个软件包,作用是可以直接把windows文件托到虚拟机里,用于xshell7
[root@server fonts]# yum -y install lrzsz
Complete!

字体放进来之后ls查看
[root@server fonts]# ls
graphfont.ttf  simkai.ttf

用mv直接覆盖之前的graphfont.ttf字体,然后就可以使用了
[root@server fonts]# mv simkai.ttf graphfont.ttf
mv: overwrite 'graphfont.ttf'? y
[root@server fonts]# ls
graphfont.ttf

 

3、为zabbix agent创建自定义模板 Template XXX 

 

 

 

 

 

4、基于Template XXX模板创建自定义监控项

(1)要求监控cpu1分钟平均负载 应用集为cpu

 

 

 

 

 

 

 

 (2)要求监控cpu5分钟平均负载 应用集为cpu

 

 

 (3)要求监控cpu15分钟平均负载 应用集为cpu

 

(4)要求监控agent的ssh服务的22端口 应用集为ssh 

 

129连接到132
[root@server fonts]# ssh root@192.168.46.132
The authenticity of host '192.168.46.132 (192.168.46.132)' can't be established.
ECDSA key fingerprint is SHA256:+4iyMTYXF8AyQPWhUo/Ob877C3DTTXpBnVG7wMUkMUE.
Are you sure you want to continue connecting (yes/no/[fingerprint])? y
Please type 'yes', 'no' or the fingerprint: yes
Warning: Permanently added '192.168.46.132' (ECDSA) to the list of known hosts.
root@192.168.46.132's password:
Last login: Sun Sep  4 10:21:32 2022 from 192.168.46.1

 

 

此时从129断开132查看
[root@agent1 ~]# exit
logout
Connection to 192.168.46.132 closed.

然后132停止服务
[root@agent1 ~]# systemctl stop sshd

 

132把服务重新启动
[root@agent1 ~]# systemctl restart sshd

 5、自定义键值logusers,该键值要求监控有多少个用户连接agent端 应用集为ssh

[root@agent1 ~]# who
root     tty1         2022-09-04 10:21
root     pts/0        2022-09-04 10:21 (192.168.46.1)
[root@agent1 ~]# who|wc -l
2

[root@agent1 ~]# vim /etc/zabbix/zabbix_agentd.conf
(去掉井号 去掉注释) UserParameter=loginusers,who | wc -l

[root@agent1 ~]# systemctl restart zabbix-agent.service

 

6、创建Template xxx模板的图形,将以上5个监控项制作成图形

 

 

 

 

 

 

 

7、创建聚合图形,将监控项cpu1分钟平均负载和有多少个用户连接agent端图形制作成聚合图形 

 

 

 

 

 

 

 8、收藏该聚合图形,让其在仪表板中显示

 

 

 

 9、创建触发器,设置超过7个用户连接agent端,发出告警信息。

 

 

 

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值