提示:文章写完后,目录可以自动生成,如何生成可参考右边的帮助文档
一、实验准备
192.168.156.148 zabbix-server
192.168.156.151 zabbix-angent
zabbix-server端:
rpm -Uvh https://repo.zabbix.com/zabbix/5.0/rhel/7/x86_64/zabbix-release-5.0-1.el7.noarch.rpm
yum install zabbix-server-mysql zabbix-agent
yum install centos-release-scl
vim /etc/yum.repos.d/zabbix.repo
####改这里
[zabbix-frontend]
...
enabled=1
...
yum install zabbix-web-mysql-scl zabbix-apache-conf-scl
yum -y install mariadb mariadb-server
systemctl start mariadb.service
##进入MYSQL
mysql
mysql> create database zabbix character set utf8 collate utf8_bin;
mysql> create user "zabbix"@"localhost" identified by '123456';
mysql> grant all privileges on zabbix.* to "zabbix"@"localhost";
mysql> exit;
zcat /usr/share/doc/zabbix-server-mysql*/create.sql.gz | mysql -uzabbix -p zabbix
yum install zabbix-get
vim /etc/zabbix/zabbix_server.conf
##修改密码
DBPassword=123456
##揭开注释
DBHost=localhost
vim /etc/opt/rh/rh-php72/php-fpm.d/zabbix.conf
php_value[date.timezone] = Asia/Shanghai
systemctl restart zabbix-server zabbix-agent httpd rh-php72-php-fpm
systemctl enable zabbix-server zabbix-agent httpd rh-php72-php-fpm
rpm -Uvh https://repo.zabbix.com/zabbix/5.0/rhel/7/x86_64/zabbix-release-5.0-1.el7.noarch.rpm
yum install zabbix-agent
vim /etc/zabbix/zabbix_agentd.conf
##117行
Server=192.168.156.148
##163行
ServerActive=192.168.156.148
##174行
Hostname=192.168.156.151
systemctl start zabbix-agent
systemctl enable zabbix-agent
二、安装
访问192.168.156.148/zabbix
三、添加监控对象
同理添加192.168.156.151
四、添加自定义监控项
在192.168.15.6151上添加自定义的监控项:监控当前登录用户的个数
vim /etc/zabbix/zabbix_agentd.d/user-login.conf
########定义键
########格式:UserParameter=key,shell命令(脚本也可)
UserParameter=user_login,who|wc -l
vim /etc/zabbix/zabbix_agentd.conf
###解开注释,启用
UnsafeUserParameters=1
systemctl restart zabbix-agent
yum -y install zabbix-get
在zabbix-server 上验证,数据采集没有问题了就可以添加监控项了
在web端添加自定义监控项
验证,使用ssh登录192.168.156.151,让登录用户大于3
五、监控mariadb
1、添加模版查看要求
在192.168.156.151上先
查看说明
Requirements for template