运维之道 | Zabbix监控网站关键词,防止恶意篡改网站信息,并触发微信告警

前言

Zabbix 监控网站关键词,防止恶意篡改网站信息,并触发微信告警

一、主机规划

服务器 IP
Zabbix-server 192.168.1.111
Zabbix-agent、Nginx 192.168.1.116

二、Zabbix-agent端安装Nginx服务

1、获取nginx源码包,并解压
[root@localhost src]# ls
nginx-1.8.0.tar.gz
[root@localhost src]# tar -xzvf nginx-1.8.0.tar.gz
2、编译安装
[root@localhost src]# cd nginx-1.8.0/
[root@localhost nginx-1.8.0]# ./configure --prefix=/usr/local/nginx
[root@localhost nginx-1.8.0]# make && make install
3、修改nginx发布页面做测试
[root@localhost ~]# vim /usr/local/nginx/html/index.html

<h1>ZABBIX-test</h1>			///添加这一句测试语句
4、重启nginx服务
[root@localhost ~]# /usr/local/nginx/sbin/nginx -t
nginx: the configuration file /usr/local/nginx/conf/nginx.conf syntax is ok
nginx: configuration file /usr/local/nginx/conf/nginx.conf test is successful
[root@localhost ~]# /usr/local/nginx/sbin/nginx -s reload
5、访问nginx界面

在这里插入图片描述

6、统计测试界面中是否存在ZABBIX-test文字,如果存在则数字大于或等于1
[root@localhost ~]# curl -s 192.168.1.116/| grep -c ZABBIX-test
1

三、配置zabbix监控关键词

1、编写监控脚本
[root@localhost ~]# vim /tmp/auto_monitor_nginx.sh

```javascript
#!/bin/bash
#by auto monitor nginx test
WEBSITE="http://192.168.1.116/"
NUM=`curl -s $WEBSITE| grep -c "ZABBIX-test"`
echo $NUM
2、授予脚本可执行权限,并测试
[root@localhost tmp]# chmod +x auto_monitor_nginx.sh 
[root@localhost tmp]# sh auto_monitor_nginx.sh 
1
3、在zabbix-agent.conf配置文件中创建key值
[root@localhost ~]# vim /etc/zabbix/zabbix_agentd.conf

UserParameter=check_nginx_word,sh /tmp/auto_monitor_nginx.sh
4、重启zabbix-agent服务
[root@localhost ~]# systemctl restart zabbix-agent
5、在zabbix-server端测试获取键值
[root@zabbix ~]# zabbix_get -s 192.168.1.116 -k check_nginx_word
1				///获取成功

四、配置zabbix-web端

1、创建主机

在这里插入图片描述
在这里插入图片描述

2、创建监控

在这里插入图片描述
在这里插入图片描述

3、创建图像

在这里插入图片描述
在这里插入图片描述

4、创建触发器

在这里插入图片描述
在这里插入图片描述
在这里插入图片描述

5、配置微信告警
运维之道 | Zabbix 使用企业微信发送邮件报警及定制邮件报警内容

PS:触发微信告警详细步骤可按此链接进行操作


五、查看检测结果及微信触发告警

1、查看检测图像

在这里插入图片描述

2、将Nginx配置文件中的"ZABBIX-test"字删除,查看触发告警
[root@localhost ~]# vim /usr/local/nginx/html/index.html

<h1>ZABBIX-test</h1>			///将此含删除
3、重启Nginx服务
[root@localhost ~]# 
[root@localhost ~]# /usr/local/nginx/sbin/nginx -t
nginx: the configuration file /usr/local/nginx/conf/nginx.conf syntax is ok
nginx: configuration file /usr/local/nginx/conf/nginx.conf test is successful
[root@localhost ~]# /usr/local/nginx/sbin/nginx -s reload

在这里插入图片描述

4、查看zabbix-web端图像

在这里插入图片描述

5、查看微信触发告警

在这里插入图片描述
在这里插入图片描述

6、将"ZABBIX-test"值写入Nginx配置文件中,再次查看告警
[root@localhost ~]# vim /usr/local/nginx/html/index.html

<h1>ZABBIX-test</h1>			///添加这一句测试语句

在这里插入图片描述
在这里插入图片描述


PS:通过此案例,可以自行按企业需求编写脚本,并在ZABBIX中创建监控项和触发器,并部署企业微信告警信息

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章