如何监控puma服务器?

时间:2022-08-08 19:35:02

Is there a way to monitor the status of a puma server? most specifically, how many busy workers it has and how many threads each worker provisioned. best would be something similar to apache's mod_status

有没有办法监控美洲狮服务器的状态?最具体地说,它拥有多少繁忙的工作人员以及每个工作人员配置的线程数。最好的是类似于apache的mod_status

3 个解决方案

#1


12  

Maybe

也许

$ touch /path/to/your/stats.txt
$ puma -S /path/to/your/stats.txt

in another terminal

在另一个终端

$ watch cat /path/to/your/stats.txt

Results in:

结果是:

---
pid: 14364
config: !ruby/object:Puma::Configuration
  cli_options: 
  conf: 
  options:
    :min_threads: 0
    :max_threads: 16
    :quiet: false
    :debug: false
    :binds:
    - tcp://0.0.0.0:9292
    :workers: 0
    :daemon: false
    :mode: :http
    :before_fork: []
    :worker_timeout: 60
    :worker_boot_timeout: 60
    :worker_shutdown_timeout: 30
    :state: /path/to/your/stats.txt
    :config_file: 
    :control_auth_token: 21c9241912a8e0e7ddaabac667ff5682
    :tag: solar
    :environment: development

But that looks static :(

但那看起来很静:(

Starting your app via puma like this:

通过puma启动你的应用程序,如下所示:

$ puma -S /path/to/your/stats.txt -C config/puma.rb --control tcp://0.0.0.0:9191 --control-token foo config.ru

allows you later to query per your webbrowser:

允许您稍后根据您的webbrowser进行查询:

$ http://localhost:9191/stats?token=foo
or
$ pumactl -C tcp://0.0.0.0:9191 -T foo stats

Resulting in:

导致:

{ "workers": 3, "phase": 0, "booted_workers": 3 }

Which looks more dynamic...

哪个看起来更有活力......

Edit_0:

Edit_0:

As workers are processes, one could also leverage tools provided by the operating system to gather information, e.g. on Linux:

由于工作者是流程,人们还可以利用操作系统提供的工具来收集信息,例如在Linux上:

Starting a puma instance:

开始一个美洲狮实例:

puma -S p/stats.txt -C config/puma.rb --control tcp://0.0.0.0:9191 --control-token foo config.ru 
[1908] Puma starting in cluster mode...
[1908] * Version 2.15.3 (ruby 2.1.5-p273), codename: Autumn Arbor Airbrush
[1908] * Min threads: 8, max threads: 32
[1908] * Environment: development
[1908] * Process workers: 3
[1908] * Preloading application
[1908] * Listening on tcp://0.0.0.0:9292
[1908] Use Ctrl-C to stop
[1908] * Starting control server on tcp://0.0.0.0:9191
[1908] - Worker 0 (pid: 1921) booted, phase: 0
[1908] - Worker 1 (pid: 1929) booted, phase: 0
[1908] - Worker 2 (pid: 1937) booted, phase: 0

Using top to investigate workers:

使用top调查工人:

$ top -p1921 -p1929 -p1937 -n 1

gives us

给我们

Tasks:   3 total,   0 running,   3 sleeping,   0 stopped,   0 zombie
%Cpu(s):  8.4 us,  1.5 sy,  0.0 ni, 88.9 id,  1.2 wa,  0.0 hi,  0.0 si,  0.0 st
KiB Mem:   4058820 total,  1626576 used,  2432244 free,    56456 buffers
KiB Swap:  9609212 total,        0 used,  9609212 free.   424948 cached Mem

  PID USER      PR  NI    VIRT    RES    SHR S  %CPU %MEM     TIME+ COMMAND     
 1921 benjamin  20   0 1171600  85484   3116 S   0.0  2.1   0:00.38 puma        
 1929 benjamin  20   0 1171600  85264   2884 S   0.0  2.1   0:00.37 puma        
 1937 benjamin  20   0 1171600  85264   2884 S   0.0  2.1   0:00.42 puma

from which one can parse out relevant information like CPU or RAM utilization.

从中可以解析出CPU或RAM利用率等相关信息。

#2


2  

I use the god or monit.

我使用上帝或monit。

God is a ruby gem, Monit is a monitoring tool

上帝是一颗红宝石,Monit是一种监控工具

  • monitor servers,
  • 监控服务器,
  • processes,
  • 过程中,
  • send notifications for resource usage ,
  • 发送资源使用通知,
  • restart your processes if crashed,
  • 如果崩溃,重启你的进程,
  • provide terminal and web ui to check processes status.
  • 提供终端和web ui来检查进程状态。

#3


0  

You can use the pumactl tool:

你可以使用pumactl工具:

$ pumactl --help

#1


12  

Maybe

也许

$ touch /path/to/your/stats.txt
$ puma -S /path/to/your/stats.txt

in another terminal

在另一个终端

$ watch cat /path/to/your/stats.txt

Results in:

结果是:

---
pid: 14364
config: !ruby/object:Puma::Configuration
  cli_options: 
  conf: 
  options:
    :min_threads: 0
    :max_threads: 16
    :quiet: false
    :debug: false
    :binds:
    - tcp://0.0.0.0:9292
    :workers: 0
    :daemon: false
    :mode: :http
    :before_fork: []
    :worker_timeout: 60
    :worker_boot_timeout: 60
    :worker_shutdown_timeout: 30
    :state: /path/to/your/stats.txt
    :config_file: 
    :control_auth_token: 21c9241912a8e0e7ddaabac667ff5682
    :tag: solar
    :environment: development

But that looks static :(

但那看起来很静:(

Starting your app via puma like this:

通过puma启动你的应用程序,如下所示:

$ puma -S /path/to/your/stats.txt -C config/puma.rb --control tcp://0.0.0.0:9191 --control-token foo config.ru

allows you later to query per your webbrowser:

允许您稍后根据您的webbrowser进行查询:

$ http://localhost:9191/stats?token=foo
or
$ pumactl -C tcp://0.0.0.0:9191 -T foo stats

Resulting in:

导致:

{ "workers": 3, "phase": 0, "booted_workers": 3 }

Which looks more dynamic...

哪个看起来更有活力......

Edit_0:

Edit_0:

As workers are processes, one could also leverage tools provided by the operating system to gather information, e.g. on Linux:

由于工作者是流程,人们还可以利用操作系统提供的工具来收集信息,例如在Linux上:

Starting a puma instance:

开始一个美洲狮实例:

puma -S p/stats.txt -C config/puma.rb --control tcp://0.0.0.0:9191 --control-token foo config.ru 
[1908] Puma starting in cluster mode...
[1908] * Version 2.15.3 (ruby 2.1.5-p273), codename: Autumn Arbor Airbrush
[1908] * Min threads: 8, max threads: 32
[1908] * Environment: development
[1908] * Process workers: 3
[1908] * Preloading application
[1908] * Listening on tcp://0.0.0.0:9292
[1908] Use Ctrl-C to stop
[1908] * Starting control server on tcp://0.0.0.0:9191
[1908] - Worker 0 (pid: 1921) booted, phase: 0
[1908] - Worker 1 (pid: 1929) booted, phase: 0
[1908] - Worker 2 (pid: 1937) booted, phase: 0

Using top to investigate workers:

使用top调查工人:

$ top -p1921 -p1929 -p1937 -n 1

gives us

给我们

Tasks:   3 total,   0 running,   3 sleeping,   0 stopped,   0 zombie
%Cpu(s):  8.4 us,  1.5 sy,  0.0 ni, 88.9 id,  1.2 wa,  0.0 hi,  0.0 si,  0.0 st
KiB Mem:   4058820 total,  1626576 used,  2432244 free,    56456 buffers
KiB Swap:  9609212 total,        0 used,  9609212 free.   424948 cached Mem

  PID USER      PR  NI    VIRT    RES    SHR S  %CPU %MEM     TIME+ COMMAND     
 1921 benjamin  20   0 1171600  85484   3116 S   0.0  2.1   0:00.38 puma        
 1929 benjamin  20   0 1171600  85264   2884 S   0.0  2.1   0:00.37 puma        
 1937 benjamin  20   0 1171600  85264   2884 S   0.0  2.1   0:00.42 puma

from which one can parse out relevant information like CPU or RAM utilization.

从中可以解析出CPU或RAM利用率等相关信息。

#2


2  

I use the god or monit.

我使用上帝或monit。

God is a ruby gem, Monit is a monitoring tool

上帝是一颗红宝石,Monit是一种监控工具

  • monitor servers,
  • 监控服务器,
  • processes,
  • 过程中,
  • send notifications for resource usage ,
  • 发送资源使用通知,
  • restart your processes if crashed,
  • 如果崩溃,重启你的进程,
  • provide terminal and web ui to check processes status.
  • 提供终端和web ui来检查进程状态。

#3


0  

You can use the pumactl tool:

你可以使用pumactl工具:

$ pumactl --help