zabbix===》监控维度总结、curl模拟web页面登录、zabbix监控web场景

一、监控维度总结

  • 物理硬件监控(cpu温度、风扇转速、主板温度、电压、功率、ipmi工具监控、机房巡检)(如果是云主机由云厂商负责监控)===》ipmi 命令行
[root@db01 ~]# yum install ipmitool.x86_64 -y

[root@db01 ~]# ipmitool  -I open sensor   #取到真实物理服务器的cpu温度、风扇转速、主板温度、电压、功率
  • 操作系统监控(cpu负载、内存、磁盘容量io、网卡io、进程数、安全监控/etc/password)===》Linux模板
  • 应用软件监控(nginx、php-fpm、mysql、redis、分布式文件系统glusterFS、ceph)===》修改开源的模板
  • 业务监控(业务员状态,网页调度、pv【浏览页面】,uv【浏览终端】,IP【公网IP】监控,会员的活跃数量,每天的成单量)
  • 网络设备监控 lnmp架构
  • ELK监控日志
#1.pv、uv、ip监控
使用开源软件:piwik (之前名称)
            matomo(现在改名后)(http://matomo.org)
            Awstates
使用第三方统计:腾讯分析 (ta.qq.com)
              百度统计
              谷歌分析

在这里插入图片描述

二、使用curl模拟登陆web页面

在这里插入图片描述

1.打开普通页面(获取cookie值【以zabbix的web登录界面为例】)

GET请求:http://10.0.0.9/zabbix/index.php
在这里插入图片描述

#1.命令行模拟获取cookie值
[root@db01 ~]# curl -X GET -c cookie -b cookie http://10.0.0.9/zabbix/index.php > login.html
  % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
                                 Dload  Upload   Total   Spent    Left  Speed
100  3449  100  3449    0     0  64583      0 --:--:-- --:--:-- --:--:-- 65075
[root@db01 ~]# ll
-rw-r--r--  1 root root  213 3月  21 02:29 cookie
-rw-r--r--  1 root root 3449 3月  21 02:29 login.html


#2.把文件放到nginx的站点目录下在去浏览器请求
[root@db01 ~]# cd /code/
[root@db01 code]# mkdir test
[root@db01 code]# cd test/
[root@db01 test]# mv /root/cookie /root/login.html .
[root@db01 test]# ll
总用量 8
-rw-r--r-- 1 root root  213 3月  21 02:29 cookie
-rw-r--r-- 1 root root 3449 3月  21 02:29 login.html

使用文件网页测试是否请求成功
在这里插入图片描述

2.模拟提交post登录请求

POST请求 : http://10.0.0.9/zabbix/index.php

name=Admin&password=zabbix&autologin=1&enter=Sign+in
在这里插入图片描述

#1.命令行模拟post登录请求
[root@db01 test]# curl -X POST -L -c cookie -b cookie -d "name=Admin&password=zabbix&autologin=1&enter=Sign+in" http://10.0.0.9/zabbix/index.php > index.html
  % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
                                 Dload  Upload   Total   Spent    Left  Speed
100    52    0     0  100    52      0   1060 --:--:-- --:--:-- --:--:--  1083
  0     0    0 21569    0     0   167k      0 --:--:-- --:--:-- --:--:--  167k
[root@db01 test]# ll
总用量 32
-rw-r--r-- 1 root root   310 3月  21 02:45 cookie
-rw-r--r-- 1 root root 21569 3月  21 02:45 index.html
-rw-r--r-- 1 root root  3449 3月  21 02:29 login.html

使用文件网页测试是否请求成功
在这里插入图片描述

3.验证是否登录成功

GET请求:http://10.0.0.9/zabbix/hosts.php?ddreset=1
在这里插入图片描述

#1.命令行模拟登录host页面
[root@db01 test]# curl -X GET -L -c cookie -b cookie  "http://10.0.0.9/zabbix/hosts.php?ddreset=1" > host.html
  % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
                                 Dload  Upload   Total   Spent    Left  Speed
100 22128    0 22128    0     0   198k      0 --:--:-- --:--:-- --:--:--  200k
[root@db01 test]# ll
总用量 56
-rw-r--r-- 1 root root   310 3月  21 02:53 cookie
-rw-r--r-- 1 root root 22128 3月  21 02:53 host.html
-rw-r--r-- 1 root root 21569 3月  21 02:52 index.html
-rw-r--r-- 1 root root  3449 3月  21 02:29 login.html

在这里插入图片描述

三、zabbix创建web场景监控

1.给zabbix-server端创建web监测

在这里插入图片描述

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

在这里插入图片描述
在这里插入图片描述
监控成功界面:
在这里插入图片描述
在这里插入图片描述

2.给web_monitor应用集的监控项配置触发器

在这里插入图片描述
触发器(1):主机页面状态码异常
在这里插入图片描述

3.检查配置的触发器是否成功

#1.找到浏览器默认请求的hosts.html文件,修改权限为400
[root@web03 ~]# cd /usr/share/zabbix/
[root@web03 zabbix]# ll hosts.php 
-rw-r--r-- 1 root root 43403 2月  22 16:57 hosts.php
[root@web03 zabbix]# chmod 400 hosts.php 
[root@web03 zabbix]# ll hosts.php 
-r-------- 1 root root 43403 2月  22 16:57 hosts.php

再去监测页面观察报警
在这里插入图片描述
报警恢复

#把权限修改为644
[root@web03 zabbix]# chmod 644 hosts.php 

在这里插入图片描述
触发器(2):主机页面响应慢
在这里插入图片描述
在这里插入图片描述
模拟故障:给登录网址加压(ctrl+c停掉加压即可恢复正常)

[root@web03 zabbix]# ab -n 100000 -c 20 http://10.0.0.9/zabbix/index.php
This is ApacheBench, Version 2.3 <$Revision: 1430300 $>
Copyright 1996 Adam Twiss, Zeus Technology Ltd, http://www.zeustech.net/
Licensed to The Apache Software Foundation, http://www.apache.org/

Benchmarking 10.0.0.9 (be patient)

再去观察报警即可
在这里插入图片描述
在这里插入图片描述

猜你喜欢

转载自blog.csdn.net/weixin_52492280/article/details/115033097
今日推荐