doina

一个小菜鸟运维工程师.

Supervisor 集中管理工具 Supervisord-monitor

Supervisor 集中管理工具 Supervisord-monitor

  • 开源免费的集中管理工具,基于php开发,需要php环境
  • 监控无限制的supervisord服务器和进程
  • 启动/停止/重启过程
  • 阅读stderr日志
  • 发生stderr时启动新的Redmine票证
  • stderr发生时的声音警报
  • 静音提醒(一段时间后自动恢复)
  • 监控流程正常运行状态

项目地址

  • https://github.com/mlazarov/supervisord-monitor

准备php环境

#安装nginx和php
[root@node2 ~]# yum -y install nginx php php-fpm

#修改nginx主配置文件,去掉无用的配置
[root@node2 config]# cat /etc/nginx/nginx.conf
user nginx;
worker_processes auto;
error_log /var/log/nginx/error.log;
pid /run/nginx.pid;

include /usr/share/nginx/modules/*.conf;

events {
    worker_connections 1024;
}

http {
    log_format  main  '$remote_addr - $remote_user [$time_local] "$request" '
                      '$status $body_bytes_sent "$http_referer" '
                      '"$http_user_agent" "$http_x_forwarded_for"';

    access_log  /var/log/nginx/access.log  main;

    sendfile            on;
    tcp_nopush          on;
    tcp_nodelay         on;
    keepalive_timeout   65;
    types_hash_max_size 2048;

    include             /etc/nginx/mime.types;
    default_type        application/octet-stream;

    include /etc/nginx/conf.d/*.conf;
}


#新建一个nginx的虚拟主机
[root@node2 ~]# cat /etc/nginx/conf.d/supervisor-monitor.conf
 server {
        listen       80;
        server_name  localhost;
        root         /usr/local/supervisord-monitor/public_html;
        index        index.html index.htm index.php;

        location / {
            try_files $uri $uri/ /index.php;
        }
         location ~ \.php$ {
        try_files $uri =404;

        include fastcgi.conf;
        fastcgi_pass 127.0.0.1:9000;
        }
}

#修改php参数(只修改下面几个参数)
[root@node2 ~]# vim  /etc/php-fpm.d/www.conf
listen.owner = nobody
listen.group = nobody
listen.mode = 0666
user = nobody
group = nobody

#启动nginx
[root@node2 ~]# systemctl start nginx

#启动php-fpm
[root@node2 ~]# systemctl start php-fpm

#配置supervisord-monitor
[root@node2 ~]# git clone  https://github.com/mlazarov/supervisord-monitor  /usr/local/supervisord-monitor
正克隆到 '/usr/local/supervisord-monitor'...
remote: Counting objects: 512, done.
remote: Total 512 (delta 0), reused 0 (delta 0), pack-reused 512
接收对象中: 100% (512/512), 893.51 KiB | 445.00 KiB/s, done.
处理 delta 中: 100% (202/202), done.
[root@node2 ~]# cd /usr/local/supervisord-monitor/application/
config/      controllers/ core/        errors/      libraries/   views/
[root@node2 ~]# cd /usr/local/supervisord-monitor/application/config/
[root@node2 config]# cp  supervisor.php.example  supervisor.php

修改配置文件

[root@node2 config]# cat  supervisor.php
<?php

// Dashboard columns. 2 or 3
$config['supervisor_cols'] = 2;

// Refresh Dashboard every x seconds. 0 to disable
$config['refresh'] = 10;

// Enable or disable Alarm Sound
$config['enable_alarm'] = true;

// Show hostname after server name
$config['show_host'] = false;

$config['supervisor_servers'] = array(
        'node1' => array(
                'url' => 'http://10.241.0.10/RPC2',
                'port' => '9001',
                'username' => 'admin',
                'password' => 'baiyongjie'
        ),
        'node2' => array(
                'url' => 'http://10.241.0.11/RPC2',
                'port' => '9001',
                'username' => 'admin',
                'password' => 'baiyongjie'
        ),
        'node3' => array(
                'url' => 'http://10.241.0.12/RPC2',
                'port' => '9001',
                'username' => 'admin',
                'password' => 'baiyongjie'
        ),
);

// Set timeout connecting to remote supervisord RPC2 interface
$config['timeout'] = 3;

// Path to Redmine new issue url
$config['redmine_url'] = 'http://redmine.url/path_to_new_issue_url';

// Default Redmine assigne ID
$config['redmine_assigne_id'] = '69';

访问Supervisor-monitor

《Supervisor 集中管理工具 Supervisord-monitor》

《Supervisor 集中管理工具 Supervisord-monitor》

错误处理方法

[root@node2 ~]# for i in `ls /etc/supervisor/conf.d/*`; do sed -i 's/redirect_stderr=true/redirect_stderr=false/g'  $i; done

[root@node2 ~]# supervisorctl  update
kafka: stopped
kafka: updated process group
redis: stopped
redis: updated process group
zookeeper: stopped
zookeeper: updated process group

《Supervisor 集中管理工具 Supervisord-monitor》

点赞

发表评论

邮箱地址不会被公开。

此站点使用Akismet来减少垃圾评论。了解我们如何处理您的评论数据