zabbix

安装文档https://www.cnblogs.com/yaoyaojcy/p/9884130.html
yum -y update
vi /etc/selinux/config
firewall-cmd --state
yum install -y httpd mariadb-server mariadb php php-mysql php-gd libjpeg* php-ldap php-odbc php-pear php-xml php-xmlrpc php-mhash
rpm -qa httpd php mariadb
显示3个:httpd/mariadb/php
vi /etc/httpd/conf/httpd.conf
ServerName www.zabbixfast.com
DirectoryIndex index.html index.php
vi /etc/php.ini
date.timezone = PRC
systemctl start httpd
systemctl enable httpd
systemctl start mariadb
systemctl enable mariadb
ss -anplt | grep httpd
ss -naplt | grep mysqld
vi /var/www/html/index.php
<?php
phpinfo()
?>

curl http://127.0.0.1 -I
数据库root密码是11112222
CREATE DATABASE zabbix character set utf8 collate utf8_bin;
GRANT all ON zabbix.* TO 'zabbix'@'%' IDENTIFIED BY 'tyadmin123';
GRANT all ON zabbix.* TO 'zabbix'@'localhost' IDENTIFIED BY 'tyadmin123';
测试:在web直接输入IP地址
1
vi /var/www/html/index.php #修改测试页内容,测试zabbix用户是否能够登陆数据库,这个环节很重要
<?php
$link=mysql_connect('172.18.20.224','zabbix','ykadmin123');
if($link) echo "<h1>Success!!</h1>"; #显示Success表示连接数据库成功
else echo "Fail!!";
mysql_close();
?>
yum -y install net-snmp net-snmp-devel curl curl-devel libxml2 libxml2-devel libevent-devel.x86_64 javacc.noarch javacc-javadoc.noarch javacc-maven-plugin.noarch javacc*
yum install php-bcmath php-mbstring -y
rpm -ivh http://repo.zabbix.com/zabbix/4.0/rhel/7/x86_64/zabbix-release-4.0-1.el7.noarch.rpm (这一步报错了没有成功,不知道有没有影响)
yum install zabbix-server-mysql zabbix-web-mysql -y (这一步先安装了deltarpm以后,又反复执行多次才安装下来,不知道是不是有毒)
zcat /usr/share/doc/zabbix-server-mysql-4.0.22/create.sql.gz|mysql -uzabbix -p -h 39.99.203.152 zabbix (这个包每次安装位置会不一样,需要用find找一下)
vi /etc/httpd/conf.d/zabbix.conf
将# php_value date.timezone Europe/Riga 变更成php_value date.timezone Asia/Shanghai
systemctl enable zabbix-server # #启动并加入开机自启动zabbix-server
systemctl start zabbix-server

zabbix的启动文件位置
/usr/bin/zabbix
在conf文件中没有配置DB的密码,手动配置
/etc/zabbix/zabbix_server.conf
http://39.99.203.152/zabbix/ 浏览器输入这个地址(之前配置的zabbixfast是什么我没搞懂)
重启zabbix server:systemctl restart zabbix-server
重启数据库systemctl stop/start mariadb
# DBHost=localhost 我试着把这个#取消试试

Admin zabbix

客户端安装:
1、通过root用户登陆服务器,确保SELinux和防火墙处于关闭状态(不用管iptables)
rpm -Uvh https://repo.zabbix.com/zabbix/4.0/rhel/7/x86_64/zabbix-release-4.0-2.el7.noarch.rpm
yum clean all
yum -y install zabbix-agent
vi /etc/zabbix/zabbix_agentd.conf

sed -i 's/Server=127.0.0.1/Server=39.99.203.152/g' /etc/zabbix/zabbix_agentd.conf
sed -i 's/ServerActive=127.0.0.1/ServerActive=39.99.203.152/g' /etc/zabbix/zabbix_agentd.conf
sed -i 's/Hostname=Zabbix server/Hostname=host-106-13-230-61/g' /etc/zabbix/zabbix_agentd.conf
sed -i '/# HostMetadataItem=/a HostMetadataItem=system.uname' /etc/zabbix/zabbix_agentd.conf(以后的配置都会用到的)
sed -i '/# EnableRemoteCommands=0/a EnableRemoteCommands=1' /etc/zabbix/zabbix_agentd.conf(以后的配置都会用到的,比如执行脚本的时候)
sed -i '/# AllowRoot=0/a AllowRoot=1' /etc/zabbix/zabbix_agentd.conf(以后的配置都会用到的)

|^$" /etc/zabbix/zabbix_agentd.conf #查看刚刚修改的内容
service zabbix-agent start(启动zabbix-agent)
chkconfig zabbix-agent on(设置开机自启动)

sed -i 's/FpingLocation=/usr/sbin/fping/FpingLocation=/usr/local/fping/sbin/fping/g' /etc/zabbix/zabbix_agentd.conf
sed -i '/# FpingLocation=/usr/sbin/fping/a FpingLocation=/usr/local/fping/sbin/fping' /etc/zabbix/zabbix_agentd.conf

邮箱告警
yum -y install mailx
set smtp=smtp.qq.com #邮箱的smtp服务器地址,一般在邮箱的设置中寻找
set from=568353087@qq.com #设置发件人邮箱
set smtp-auth-user=568353087 #邮箱登录账号,即发件人邮箱
set smtp-auth-password=a11112222 #邮箱密码或者授权码
set smtp-auth=login

vi /etc/mail.rc

echo "HEllo_test_test1" | mailx -v -s "zabbix_test_mail" 393556204@qq.com

zabbix_get -s 106. -k "system.run[sudo systemctl stop httpd]

 

依赖关系

 

 

 

 一般情况下不需要去碰这个东西

 

posted @ 2020-07-30 10:26  568353087  阅读(169)  评论(0编辑  收藏  举报