zabbix4.0理论+操作——02(zabbix部署+邮件报警)

网友投稿 490 2022-11-10

zabbix4.0理论+操作——02(zabbix部署+邮件报警)

zabbix理论+操作——02(zabbix部署+邮件报警)

实验环境

监控端:192.168.136.168被监控端:192.168.136.185

安装LAMP

yum install -y \ \ mariadb-server mariadb \ php \ php-mysql \ php-gd \ libjpeg* \ php-ldap \ php-odbc \ php-pear \ php-xml \ php-xmlrpc \ php-mhash

vim /etc/httpd/conf/httpd.conf ServerName benet.com DirectoryIndex index.html index.php vi /etc/php.ini date.timezone = PRC //设置中国时区 systemctl stop firewalld.service setenforce 0 systemctl start httpd.service systemctl start mariadb.service netstat -ntap | egrep '(80|3306)' mysql_secure_installation vi /var/www/html/index.php

mysql -u root -p #为zabbix设置一个数据库,并且要设置一个用户去管理它 CREATE DATABASE zabbix character set utf8 collate utf8_bin; GRANT all privileges ON *.* TO 'zabbix'@'%' IDENTIFIED BY 'admin123'; flush privileges; #写一个测试首页 [root@localhost ~]# cd /var/www/html/ [root@localhost html]# vim index.php #验证zabbix能否连接数据库

---------解决本地无法登录问题(可忽略)---------------

[root@localhost html]# mysql -u root -p Enter password: Welcome to the MariaDB monitor. Commands end with ; or \g. Your MariaDB connection id is 9 Server version: 5.5.64-MariaDB MariaDB Server Copyright (c) 2000, 2018, Oracle, MariaDB Corporation Ab and others. Type 'help;' or '\h' for help. Type '\c' to clear the current input statement. MariaDB [(none)]> select user,host from mysql.user; //有空用户名称占用导致本地无法登录远程可登录 +--------+-----------------------+ | user | host | +--------+-----------------------+ | zabbix | % | | root | 127.0.0.1 | | root | ::1 | | | localhost | | root | localhost | | | localhost.localdomain | +--------+-----------------------+ 6 rows in set (0.01 sec) drop user ''@localhost; drop user ''@cacti; flush privileges;

----------------以下开始部署zabbix Server-------

yum install php-bcmath php-mbstring -y rpm -ivh //会自动生成yum源文件,保证系统可以上网 yum install zabbix-server-mysql zabbix-web-mysql -y zcat /usr/share/doc/zabbix-server-mysql-4.0.0/create.sql.gz | mysql -uzabbix -p zabbix //生成数据库文件,注意密码不要输成root的 grep -n '^'[a-Z] /etc/zabbix/zabbix_server.conf 38:LogFile=/var/log/zabbix/zabbix_server.log 49:LogFileSize=0 72:PidFile=/var/run/zabbix/zabbix_server.pid 82:SocketDir=/var/run/zabbix 101:DBName=zabbix 117:DBUser=zabbix 125:DBPassword=admin123 //修改本行 347:SNMPTrapperFile=/var/log/snmptrap/snmptrap.log 465:Timeout=4 507:AlertScriptsPath=/usr/lib/zabbix/alertscripts 517:ExternalScripts=/usr/lib/zabbix/externalscripts 553:LogSlowQueries=3000 vim /etc///修改时区 php_value date.timezone Asia/Shanghai vim /usr/share/zabbix/include/defines.inc.php //修正图表中文乱码 :%s /graphfont/kaiti/g //从微软系统下复制相应的字体文件到 /usr/share/zabbix/fonts 目录中注意字体名称要对应配置文件,且注意大小写 cp STKAITI.TTF /usr/share/zabbix/fonts/ systemctl enable zabbix-server systemctl start zabbix-server netstat -anpt | grep zabbix //监听在10051端口上 systemctl restart -ivh http://repo.zabbix.com/zabbix/3.5/rhel/7/x86_64/zabbix-release-3.5-1.el7.noarch.rpm yum install -y zabbix-agent grep -n '^'[a-Z] /etc/zabbix/zabbix_agentd.conf 13:PidFile=/var/run/zabbix/zabbix_agentd.pid 32:LogFile=/var/log/zabbix/zabbix_agentd.log 43:LogFileSize=0 98:Server=192.168.175.155 139:ServerActive=192.168.175.155 150:Hostname=test 268:Include=/etc/zabbix/zabbix_agentd.d/*.conf service firewalld stop setenforce 0 systemctl enable zabbix-agent.service systemctl restart zabbix-agent.service netstat -anpt | grep zabbix //监听在10050端口 ---------------增加被控主机--在WEB平台上做----- 配置-主机-创建主机: 主机页面根据需求配置 模板页需要链接模板,根据需要链接相应的模板 0K

--------配置邮件报警功能---服务器上配置--------- yum install mailx vi /etc/mail.rc //注意网易邮箱需要开启客户端授权码进行第三方登录 ----文件末尾新增--- set from=1960277503@qq.com set smtp=smtp.qq.com set smtp-auth-user=1960277503@qq.com set smtp-auth-password=邮箱密码 set smtp-auth=login echo "hello world" | mail -s "testmail" 1960277503@qq.com //测试发信正常 cd /usr/lib/zabbix/alertscripts vi mailx.sh //编写发邮件脚本 #!/bin/bash #send mail messages=`echo $3 | tr '\r\n' '\n'` subject=`echo $2 | tr '\r\n' '\n'` echo "${messages}" | mail -s "${subject}" $1 >>/tmp/mailx.log 2>&1 ------ touch /tmp/mailx.log chown -R zabbix.zabbix /tmp/mailx.log chmod +x /usr/lib/zabbix/alertscripts/mailx.sh chown -R zabbix.zabbix /usr/lib/zabbix/ ./mailx.sh 13951868284@139.com "主题" "内容" //测试发邮件脚本是否可以正常工作

-----在服务器WEB上配置----

版权声明:本文内容由网络用户投稿,版权归原作者所有,本站不拥有其著作权,亦不承担相应法律责任。如果您发现本站中有涉嫌抄袭或描述失实的内容,请联系我们jiasou666@gmail.com 处理,核实后本网站将在24小时内删除侵权内容。

上一篇:赛灵思参加百度云智峰会,展示四大加速方案
下一篇:基于FPGA的边缘设备开发深度神经网络检测程序
相关文章

 发表评论

暂时没有评论,来抢沙发吧~