zabbix 添加被监视web服务器
查看系统版本:
cat /etc/redhat-release
uname -a centos8安装zabbix-agent:
rpm -Uvh https://repo.zabbix.com/zabbix/5.0/rhel/8/x86_64/zabbix-release-5.0-1.el8.noarch.rpm
dnf install zabbix-agent
systemctl restart zabbix-agent
systemctl enable zabbix-agentcentos7安装zabbix-agent:
rpm -Uvh https://repo.zabbix.com/zabbix/5.0/rhel/7/x86_64/zabbix-release-5.0-1.el7.noarch.rpm
yum clean all
yum install -y zabbix-agent
systemctl restart zabbix-agent
systemctl enable zabbix-agentcentos6安装zabbix-agent:
rpm -Uvh https://repo.zabbix.com/zabbix/5.0/rhel/6/x86_64/zabbix-release-5.0-1.el6.noarch.rpm
yum clean all
yum install -y zabbix-agent
service zabbix-agent restart
chkconfig --level 35 zabbix-agent on如果使用yum出现repomd.xml 404, 可以先备份一下yum的源配置文件,再恢复成centos官网yum源
cd /etc/yum.repos.d/
mv CentOS-Base.repo CentOS-Base.repo.`date +%Y%m%d%H%I%S`
curl https://www.getpagespeed.com/files/centos6-eol.repo --output /etc/yum.repos.d/CentOS-Base.repo
mv epel.repo epel.repo.`date +%Y%m%d%H%I%S`
curl https://www.getpagespeed.com/files/centos6-epel-eol.repo --output /etc/yum.repos.d/epel.repo
yum makecache
修改zabbix-agent配置文件:
vim /etc/zabbix/zabbix_agentd.conf
LogFileSize=50
Server=172.19.0.16
ListenIP=172.19.0.9 #客户端IP
ServerActive=172.19.0.16:10051
Hostname=semBT面板安全设置里面,开放端口:10050 zabbix-agent
BT服务器,需要将mysqladmin命令添加到全局
ln -s /www/server/mysql/bin/mysqladmin /usr/bin/添加数据库监控账号及授权:
mysql -uroot -p
CREATE USER 'zabbix'@'localhost' IDENTIFIED BY '<password>';
GRANT USAGE,REPLICATION CLIENT,PROCESS,SHOW DATABASES,SHOW VIEW ON *.* TO 'zabbix'@'localhost';
flush privileges;===mysql config:
mkdir /var/lib/zabbix
vim /var/lib/zabbix/.my.cnf
[client]
user=zabbix
password=saYdX5G2FJs2iEMZ
socket=/tmp/mysql.sock修改数据库配置的访问权限(新版mysql要求,不然进不了数据库):
chmod 644 /var/lib/zabbix/.my.cnf
===test数据库配置是否可用,能成功进入即可:
mysql --defaults-file=/var/lib/zabbix/.my.cnf
添加mysql模板(参考配置)到配置目录:
下载地址:
https://git.zabbix.com/projects/ZBX/repos/zabbix/browse/templates/db/mysql_agent/template_db_mysql.conf
放到这个路径:
vim /etc/zabbix/zabbix_agentd.d/template_db_mysql.conf
template_db_mysql.conf参考内容:
#template_db_mysql.conf created by Zabbix for "Template DB MySQL" and Zabbix 4.2
#For OS Linux: You need create .my.cnf in zabbix-agent home directory (/var/lib/zabbix by default)
#For OS Windows: You need add PATH to mysql and mysqladmin and create my.cnf in %WINDIR%\my.cnf,C:\my.cnf,BASEDIR\my.cnf https://dev.mysql.com/doc/refman/5.7/en/option-files.html
#The file must have three strings:
#[client]
#user='zbx_monitor'
#password='<password>'
#
UserParameter=mysql.ping[*], mysqladmin -h"$1" -P"$2" ping
UserParameter=mysql.get_status_variables[*], mysql -h"$1" -P"$2" -sNX -e "show global status"
UserParameter=mysql.version[*], mysqladmin -s -h"$1" -P"$2" version
UserParameter=mysql.db.discovery[*], mysql -h"$1" -P"$2" -sN -e "show databases"
UserParameter=mysql.dbsize[*], mysql -h"$1" -P"$2" -sN -e "SELECT COALESCE(SUM(DATA_LENGTH + INDEX_LENGTH),0) FROM INFORMATION_SCHEMA.TABLES WHERE TABLE_SCHEMA='$3'"
UserParameter=mysql.replication.discovery[*], mysql -h"$1" -P"$2" -sNX -e "show slave status"
UserParameter=mysql.slave_status[*], mysql -h"$1" -P"$2" -sNX -e "show slave status"nginx php-fpm监控:
vhost/phpfpm_status.conf (修改 phpfpm_56_status、fastcgi_pass 127.0.0.1:9000)
server {
listen 80;
server_name 127.0.0.1;
allow 127.0.0.1;
location /nginx_status {
stub_status on;
access_log off;
}
location /phpfpm_56_status {
fastcgi_pass unix:/tmp/php-cgi.sock;
include fastcgi_params;
fastcgi_param SCRIPT_FILENAME $fastcgi_script_name;
}
}php-fpm配置:
pm.status_path = /phpfpm_54_status版权属于:Joyber
本文链接:https://blog.qqvbc.com/default/401.html
转载时须注明出处及本声明