a2005147 发表于 2019-1-18 10:07:58

Zabbix 3.0 配置web监控

一、客户端配置
  1、安装nginx

# yum install nginx
  2、启动服务

# systemctlstart nginx
# systemctlstatus nginx
● nginx.service - The nginx HTTP and reverse proxy server
Loaded: loaded (/usr/lib/systemd/system/nginx.service; disabled; vendor preset: disabled)
Active: active (running) since 五 2018-03-16 23:23:22 CST; 11s ago
Process: 2374 ExecStart=/usr/sbin/nginx (code=exited, status=0/SUCCESS)
Process: 2371 ExecStartPre=/usr/sbin/nginx -t (code=exited, status=0/SUCCESS)
Process: 2370 ExecStartPre=/usr/bin/rm -f /run/nginx.pid (code=exited, status=0/SUCCESS)
Main PID: 2377 (nginx)
CGroup: /system.slice/nginx.service
├─2377 nginx: master process /usr/sbin/nginx
└─2378 nginx: worker process
3月 16 23:23:21 node2 systemd: Starting The nginx HTTP and reverse proxy server...
3月 16 23:23:22 node2 nginx: nginx: the configuration file /etc/nginx/nginx.conf syntax is ok
3月 16 23:23:22 node2 nginx: nginx: configuration file /etc/nginx/nginx.conf test is successful
3月 16 23:23:22 node2 systemd: Failed to read PID from file /run/nginx.pid: Invalid argument
3月 16 23:23:22 node2 systemd: Started The nginx HTTP and reverse proxy server.
  3、测试访问
http://i2.运维网.com/images/blog/201803/16/c177c5dca5fdd8522181d6077e28fc7f.png

二、配置Zabbix_Web
  web监控可以直接配置在主机上面,也可以在模板上面配置,然后添加主机时,直接链接此模板即可,此文直接在主机上面配置:

Configuration-->Host-->web--Create web scenario
http://i2.运维网.com/images/blog/201803/16/0fa46d9b738283745261f5d535736c04.png
http://i2.运维网.com/images/blog/201803/16/39b6172da17d98fdfd53b6dfb55c9514.png
http://i2.运维网.com/images/blog/201803/16/64e4d1160fff167340527fe440a159ca.png

Name:web监控的名称
New Application:指定新的Application
  点击Add添加监控的URL
http://i2.运维网.com/images/blog/201803/16/f1317de8bafb06528bd0acaeac073bf8.png
http://i2.运维网.com/images/blog/201803/16/0d0b5d0401892421b8cb7c38360d2746.png

Name:页面名称
URL:监控的URL
Required string:需要的字符串
Required status codes:需要的状态码,一般都用状态码
  最后点击Add,该页面添加成功;
http://i2.运维网.com/images/blog/201803/16/659eb182c91ad06afa187374e0b75704.png
还可以添加其他页面,这里不再添加了,添加一个页面做实验即可;
http://i2.运维网.com/images/blog/201803/16/264af70aaaebfdcebba04d431f3d7fa9.png
认证页面,我的测试页面没有认证,所以就不填了,点击Add这个web监控就添加好了;
最后到Monitoring-->Web下看下监控图形展示;
http://i2.运维网.com/images/blog/201803/16/00a56564dd49a4ca7445225d5e953bde.png
http://i2.运维网.com/images/blog/201803/16/37766589a041628ceb7647ab49d3aac8.png

三、配置触发器
  web监控添加好后,默认没有添加Triggers,这里做的不够友好,需要我们手动添加一下;

Configuration-->Host-->Triggers--Create Trigger
http://i2.运维网.com/images/blog/201803/16/b43dd7eeb23440a4cea0d66d71c0a886.png
http://i2.运维网.com/images/blog/201803/16/30c11e38dc286e97ff7406dd795586ba.png

Name:触发器名称
Expression:触发器条件表达式
Multiple PROBLEM events generation:生成多个事件
Severity:事件严重级别
Item:监控项
Function:函数条件
N:200,当状态码不等于200时,则触发报警
  最后点击Add,该Triggers即可添加成功;

四、测试
  测试很简单,随便搞点事情,让web返回状态码不等于200,直接在被监控端删除index页面,如下:

# mv index.html index.html.bak
  接着到Monitoring-->Web 页面看下状态,此时状态已经由原来的OK变为以下报错:
http://i2.运维网.com/images/blog/201803/17/e6cd638019a3ae6b2020933d516a0229.png
如果配置了报警通知,这时应该已经收到通知了,我这次开启了微信通知,收到报警如下:
http://i2.运维网.com/images/blog/201803/17/152df057864f15caf3b4e6281d60f959.jpg
  到这里,Zabbix 配置web监控就完成了~



页: [1]
查看完整版本: Zabbix 3.0 配置web监控