supervisor-monitor监控

1. 监控的作用

1. supervisor可以通过配置[inet_http_server]开启web界面管理,为什么还要使用supervisor-monitor

在这里插入图片描述

2. supervisor-monitor是通过RPC远程调用进行管理多台服务器上的supervisor服务进程的,如果不使用它,假如一个公司有多个服务器,每个上面都部署了supervisor服务,那么管理起来就很不方便,每次需要逐个登录所有的supervisor服务去进行管理,而如果使用了supervisor-monitor,通过简单配置就能将所有服务器上的supervisor服务呈现在一个web管理面板上,管理效率就会大大提升。

2. 监控的安装与配置

1. supervisor-monitor是使用php语言开发的,所以我们需要安装php环境
  1. 安装php

    yum -y install php-fpm
    
  2. 修改配置文件中的用户,保持和nginx用户一致

    vim /etc/php-fpm.d/www.conf
    
    user = root
    group = root
    
  3. 启动php服务

    /usr/sbin/php-fpm -R &
    
2. 测试php是否安装成功
  1. 新建php测试配置文件

    vi /etc/nginx/conf.d/php.conf
    
  2. 内容如下

    server {
        listen       8082;  # 注意端口不要被占用
        server_name  10.10.139.182;
        
        root /usr/share/nginx/html/;
        
        location ~ .php$ {
            try_files $uri =404;
            fastcgi_pass   127.0.0.1:9000;
            fastcgi_index  index.php;
            fastcgi_param  SCRIPT_FILENAME  $document_root$fastcgi_script_name;
            fastcgi_param  SCHEME $scheme;
            include        fastcgi_params;
        }
    }
    
  3. 添加测试页面

    vim  /usr/share/nginx/html/index.php
    
  4. 内容如下

    <?php
        phpinfo();
    ?>
    
  5. 重启nginx

    systemctl restart nginx
    
  6. 浏览器访问http://10.10.139.182/8082/index.php端口
    在这里插入图片描述

3. 安装supervisord-monitor
  1. 克隆

    git clone https://github.com/mlazarov/supervisord-monitor.git
    
  2. 进入到supervisord-monitor/application/config中,将默认的配置文件重命名下:

    cd /root/supervisord-monitor/application/config
    
    cp supervisor.php.example supervisor.php
    
  3. 修改supervisor.php配置文件

    • 还可以通过修改配置文件,使得web界面展示不同效果
    $config['supervisor_servers'] = array(
            '10.10.139.182' => array(
                    'url' => 'http://10.10.139.182/RPC2',
                    'port' => '9001',  
                    'username' => 'admin',
                    'password' => 'password@'
            ),
    );
    

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

    此处需要注意:使用supervisor-monitor 时,port必须写成:0.0.0.0,而不能写本地回环地址或者本机ip,否则会出错
    在这里插入图片描述
    如果用户名和密码写错,到时候web管理界面会显示如下内容
    在这里插入图片描述

4. 配置nginx
  • 内容如下

    vim /etc/nginx/conf.d/supervisor.conf
    
    server {
        listen       8082 default_server;
        server_name  10.10.139.182;
        root         /root/supervisord-monitor/public_html;
        location / {
            index  index.php index.html;
         }
        location /control/ {
            index  index.php;
            rewrite  /(.*)$  /index.php?$1  last;
        }
        location ~ .php$ {
            try_files $uri =404;
            fastcgi_pass   127.0.0.1:9000;  # 这是php服务监控端口
            fastcgi_index  index.php;
            fastcgi_param  SCRIPT_FILENAME  $document_root$fastcgi_script_name;
            fastcgi_param  SCHEME $scheme;
            include        fastcgi_params;
        }
    }
    
5. 浏览器访问http://10.10.139.182:8082/

在这里插入图片描述

3. 使用httpd-tools配置访问密码

1.安装httpd-tools
yum -y install httpd-tools
2.生成密码文件
htpasswd -c /etc/nginx/conf.d/.htpasswd 用户名
3.如果想增加或修改密码
htpasswd -m /etc/nginx/conf.d/.htpasswd 用户名(如果重名则修改原有账户密码)
4.修改nginx配置文件,添加以下内容
location / {
    index  index.php index.html;
    auth_basic "Basic Auth";
    auth_basic_user_file "/etc/nginx/conf.d/.htpasswd";
 }
  • 修改后如下
server {
    listen       8082 default_server;
    server_name  10.10.139.182;
    root         /root/supervisord-monitor/public_html;
    location / {
        index  index.php index.html;
        auth_basic "Basic Auth";
        auth_basic_user_file "/etc/nginx/conf.d/.htpasswd";
     }
    location /control/ {
        index  index.php;
        rewrite  /(.*)$  /index.php?$1  last;
    }
    location ~ .php$ {
        try_files $uri =404;
        fastcgi_pass   127.0.0.1:9000;  # 这是php服务监控端口
        fastcgi_index  index.php;
        fastcgi_param  SCRIPT_FILENAME  $document_root$fastcgi_script_name;
        fastcgi_param  SCHEME $scheme;
        include        fastcgi_params;
    }
}
5.再次访问

在这里插入图片描述

  • 1
    点赞
  • 4
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值