2015-06-23 3 views

Antwort

11

Vielleicht

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

in einem anderen Terminal

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

Ergebnisse 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 

Aber das sieht statisch :(

Starten Sie Ihre App über puma wie folgt aus:

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

können Sie später per Webbrowser abfragen:

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

Resultierende in :

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

Welche dynamischere ...

Edit_0 aussieht:

Als Arbeiter Prozesse sind, könnte man auch Hebelwerkzeuge vom Betriebssystem zur Verfügung gestellten Informationen zu sammeln, z.B. auf Linux:

eine Puma-Instanz starten:

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 

Anfang Verwenden von Arbeitern zu untersuchen:

$ top -p1921 -p1929 -p1937 -n 1 

uns

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 

von denen gibt eine relevante Informationen zu analysieren, kann wie CPU- oder RAM-Auslastung.

+0

thx @benjamin aber wo ist der '-S' Parameter dokumentiert? – Tal

+0

@Tal, in Puma Version 2.15.3 zeigt ein Aufruf von "puma --help" eine kurze Dokumentation. Ich werde meine Antwort aktualisieren, um Ihnen den Inhalt zu zeigen ... – benjamin

+0

thx @benjamin, aber leider scheint es, dass dies nicht die Schlüsselinformationen, die ich suche, ist der Zustand der Arbeiter (beschäftigt/Leerlauf) – Tal

0

Sie das pumactl Tool verwenden können:

$ pumactl --help 
+1

thx Yuri, aber das erlaubt mir nicht, die Anzahl der Worker/Threads zu überwachen, was erforderlich ist. vermisse ich etwas? – Tal

2

Ich benutze den Gott oder den Monit.

God ein Rubin Edelstein ist, ist Monit ein Monitoring-Tool

  • Monitor Server,
  • Prozesse,
  • Benachrichtigungen für die Ressourcennutzung senden,
  • Ihre Prozesse neu starten, wenn abgestürzt,
  • Bereitstellung von Terminal- und Web-UI zur Überprüfung des Prozessstatus.