zabbix===》使用模板监控nginx、php-fpm、redis「建议收藏」

zabbix===》使用模板监控nginx、php-fpm、redis「建议收藏」一、使用模板监控nginx1.下载nginx(要监控的主机也就是客户端)#1.有CentOS-Base.repo和epel.repo这两个源就可以直接yum下载nginx[root@db01~]#cd/etc/yum.repos.d/[root@db01yum.repos.d]#ll总用量16-rw-r–r–.1rootroot252311月1803:23CentOS-Base.repo-rw-r–r–.1rootroot66411月1803

大家好,又见面了,我是你们的朋友全栈君。

一、使用模板监控nginx

1.下载nginx(要监控的主机也就是客户端)

#1.有CentOS-Base.repo和epel.repo这两个源就可以直接yum下载nginx
[root@db01 ~]# cd /etc/yum.repos.d/
[root@db01 yum.repos.d]# ll
总用量 16
-rw-r--r--. 1 root root 2523 11月 18 03:23 CentOS-Base.repo
-rw-r--r--. 1 root root  664 11月 18 03:23 epel.repo

#2.下载nginx
[root@db01 ~]# yum install nginx -y

2.前提条件(server端)

#1.开启监控取值页面 (MySQL默认自动开启===》mysql -uroot -p1 -e 'show status;'===》有值就是已经开启)
[root@db01 ~]# vim /etc/nginx/nginx.conf
    server { 
   
        listen       80 default_server;
        listen       [::]:80 default_server;
        server_name  _;
        root         /usr/share/nginx/html;

        # Load configuration files for the default server block.
        include /etc/nginx/default.d/*.conf;

        location / { 
   
        }
        location /nginx_status { 
        #在默认的location下添加一个location
            stub_status;
        }
  ........

#2.启动并设置开机自启
[root@db01 ~]# systemctl start nginx.service 
[root@db01 ~]# systemctl enable nginx.service 

#3.在浏览器测试如下图

#4.在命令行测试
[root@db01 ~]# curl http://10.0.0.51/nginx_status
Active connections: 1 
server accepts handled requests
 3 3 3 
Reading: 0 Writing: 1 Waiting: 0 

在这里插入图片描述

3.导入模板

在这里插入图片描述

4.给触发器指定动作

在这里插入图片描述

5.导入配置文件与脚本(客户端)

#1.导入配置文件
[root@db01 ~]# cd /etc/zabbix/zabbix_agentd.d/
[root@db01 zabbix_agentd.d]# rz #导入nginx_status.conf
[root@db01 zabbix_agentd.d]# ll
-rw-r--r-- 1 root root   88 12月  4 10:05 nginx_status.conf
[root@db01 ~]# vim /etc/zabbix/zabbix_agentd.d/nginx_status.conf 
UserParameter=nginx_status[*],/bin/bash /server/scripts/nginx_monitor.sh $1

#注:要指定执行脚本的解释器,脚本路径要与实际相符

#2.创建放脚本的目录
[root@db01 ~]# mkide -p /server/scripts/
[root@db01 ~]# cd /server/scripts/
[root@db01 scripts]# rz #上传nginx_monitor.sh
[root@db01 scripts]# ll
-rw-r--r-- 1 root root 1512 12月  4 10:27 nginx_monitor.sh

6.命令行测试(服务端)

#1.nginx服务开启时
[root@web03 ~]# zabbix_get -s 10.0.0.51 -p 10050 -k nginx_status["check",http://10.0.0.51/nginx_status]
1


#2.nginx服务关闭后
[root@web03 ~]# zabbix_get -s 10.0.0.51 -p 10050 -k nginx_status["check",http://10.0.0.51/nginx_status]
0

7.测试zabbix报警

#1.客户端关闭nginx服务
[root@db01 ~]# systemctl stop nginx.service

#2.接收报警信息

在这里插入图片描述

二、使用模板监控php服务

1.下载php服务

[root@db01 ~]# yum install php-fpm -y

2.修改php配置文件(开启监控取值页面)

[root@db01 ~]# vim /etc/php-fpm.d/www.conf 
pm.status_path = /php_status   #修改这一行内容并去掉注释

3.修改nginx的配置文件

#1.修改配置文件
[root@db01 ~]# vim /etc/nginx/nginx.conf
      location / { 
   
        }
        location /nginx_status { 
   
           stub_status;
        }
        location /php_status { 
       #添加新的一组location
            fastcgi_pass 127.0.0.1:9000;
            fastcgi_index index.php;
            fastcgi_param SCRIPT_FILENAME  $document_root$fastcgi_script_name;
            include       fastcgi_params;
        }
.....

#2.检查nginx配置文件语法
[root@db01 ~]# nginx -t
nginx: the configuration file /etc/nginx/nginx.conf syntax is ok
nginx: configuration file /etc/nginx/nginx.conf test is successful

4.启动nginx和php服务

[root@db01 ~]# systemctl restart nginx.service 
[root@db01 ~]# systemctl restart php-fpm.service 

5.浏览器上监测修改是否成功在这里插入图片描述

6.导入模板

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

7.导入脚本和配置文件(客户端)

#1.导入配置文件
[root@db01 ~]# cd /etc/zabbix/zabbix_agentd.d/
[root@db01 zabbix_agentd.d]# rz #导入fpm.conf
[root@db01 zabbix_agentd.d]# ll
总用量 16
-rw-r--r-- 1 root root   68 3月  19 22:32 fpm.conf
[root@db01 ~]# vim /etc/zabbix/zabbix_agentd.d/fpm.conf
UserParameter=php-fpm[*],/bin/bash /server/scripts/fpm.sh "$1" "$2"
#注:要指定执行脚本的解释器,脚本路径要与实际相符

#2.创建放脚本的目录
[root@db01 ~]# mkide -p /server/scripts/
[root@db01 ~]# cd /server/scripts/
[root@db01 scripts]# rz #上传fpm.sh
[root@db01 scripts]# ll
总用量 4
-rw-r--r-- 1 root root 1559 12月  4 13:00 fpm.sh

8.命令行测试(服务端)

#1.php服务开启时
[root@web03 ~]# zabbix_get -s 10.0.0.51 -p 10050 -k php-fpm["active processes",http://10.0.0.51/php_status]
1

#2.php服务关闭后
[root@web03 ~]# zabbix_get -s 10.0.0.51 -p 10050 -k php-fpm["active processes",http://10.0.0.51/php_status]
-0.94

9.测试zabbix报警

#1.客户端关闭nginx服务
[root@db01 ~]# systemctl stop php-fpm.service

#2.接收报警信息

三、搭建discuz论坛使用redis加速(未完待续)

discuz论坛需要lnmp环境

1.修改nginx配置文件

[root@db01 ~]# vim /etc/nginx/nginx.conf
    server { 
   
        listen       80 default_server;
        listen       [::]:80 default_server;
        server_name  _;
        root         /code;    #改路径
        index index.php index.html index.htm;  #如果没有则添加
        # Load configuration files for the default server block.
        include /etc/nginx/default.d/*.conf;

        location / { 
   
        }
        location /nginx_status { 
   
            stub_status;
        }
        location /php_status { 
   
            fastcgi_pass 127.0.0.1:9000;
            fastcgi_index index.php;
            fastcgi_param SCRIPT_FILENAME  $document_root$fastcgi_script_name;
            include       fastcgi_params;
        }

        location ~ \.php$ { 
        #添加一组新的location内容
            fastcgi_pass 127.0.0.1:9000;
            fastcgi_index index.php;
            fastcgi_param SCRIPT_FILENAME  $document_root$fastcgi_script_name;
            include       fastcgi_params;
        }
        error_page 404 /404.html;
        location = /404.html { 
   
        }
 ........

#2.重启nginx服务
[root@db01 ~]# systemctl restart nginx.service 

#3.准备项目文件
[root@db01 ~]# mkdir /code
[root@db01 ~]# cd /code/
[root@db01 code]# rz -E #上传word press包
[root@db01 code]# tar xvf wordpress.tar.gz #解压
[root@db01 code]# chown -R nginx.nginx . #修改权限
版权声明:本文内容由互联网用户自发贡献,该文观点仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请联系我们举报,一经查实,本站将立刻删除。

发布者:全栈程序员-站长,转载请注明出处:https://javaforall.net/135340.html原文链接:https://javaforall.net

(0)
全栈程序员-站长的头像全栈程序员-站长


相关推荐

  • CSS-精灵图片的使用(从一张图片中截图指定位置图标)

    CSS-精灵图片的使用(从一张图片中截图指定位置图标)目录一、名词解释二、使用难点三、使用步骤四、程序源码一、名词解释  在网页中,我们可以看到有很多的小图标,比如微博上的登录位置有很多这样的小图标。因为浏览器显示网页的所有内容都需要从我们自己的服务器进行下载,如果将这些图标分别存在服务器上,那么当需要显示的时候将会发出很多次请求–>响应–>下载,这样一来将会消耗大量的时间来下载这些小图标  所…

    2022年5月5日
    40
  • uniapp 复制粘贴_小程序封装键盘输入框

    uniapp 复制粘贴_小程序封装键盘输入框本篇没啥营养,就是告诉不熟悉uniapp的开发者怎么完成长按复制,懂得朋友别浪费时间1.给text组件设置对应平台的对应属性,在安卓手机上的效果2.直接设置剪切板的内容uni.setClipboardData(OBJECT)<textstyle=”@longpress=’copyText’>长按触发longpress事件</text>//对应事件copyText(){ uni.setClipboardData({ dat…

    2022年9月1日
    0
  • 五万字总结,深度学习基础。「建议收藏」

    五万字总结,深度学习基础。「建议收藏」文章目录1基本概念1.1神经网络组成?1.2神经网络有哪些常用模型结构?1.3如何选择深度学习开发平台?1.4为什么深层神经网络难以训练?1.5深度学习和机器学习的异同?2网络操作与计算2.1前向传播与反向传播?2.2如何计算神经网络的输出?2.3如何计算卷积神经网络输出值?2.4如何计算Pooling层输出值输出值?2.5实例理解反向传播2.6神经网络更“深”有什么意义?3超参数3.1什么是超参数?3.2如何寻找超参数的最优值?3.3超参数搜索一般过程?4激活函数4

    2022年5月21日
    35
  • stringtokenizer是什么意思_string getbytes

    stringtokenizer是什么意思_string getbytesStringTokenizer是一个用来分隔String的应用类。构造函数publicStringTokenizer(Stringstr)publicStringTokenizer(Stringstr,Stringdelim)publicStringTokenizer(Stringstr,Stringdelim,booleanreturnDelims)第一个参

    2022年8月11日
    4
  • python编程考试有哪些(python编程考试模拟题)

    python编程考试有哪些(python编程考试模拟题)2021国内外主流机器人编程赛事+等级考试Scratch编程、C++编程、Python编程等多个赛项,评比类、竞技类不同比赛形式自主选择。多个国内外主流机器人编程赛事,总能帮助孩子找到施展能力、表现创意的舞台。机器人、编程、人工智能等级考试篇全国青少年机器人技术等级考试和全国青少年软件编程等级考试均由中国电子…。2021机器人编程赛事+等级考试攻略之国内外主流赛事及能力测评篇上周,玛酷在公众号发布了一篇名为《2021机器人编程赛事+等级考试攻略之教育部白名单赛事篇》的文章。文章中为大家介绍了20

    2022年5月17日
    62
  • databus mysql搭建_databus bootstrap 部署

    databus mysql搭建_databus bootstrap 部署databus分为relaybootstrap-producer(bst-producer)bootstrap-server(bst-server)client,他们之间的关系可以去网上找这里主要介绍部署这四个工程的方法1relay侦听端口为111151.1relay.propertiesdatabus.relay.container.httpPort=11115data…

    2022年10月17日
    0

发表回复

您的邮箱地址不会被公开。 必填项已用 * 标注

关注全栈程序员社区公众号