たごもりすメモ

コードとかその他の話とか。

PassengerMonitor: Rack Middleware returns status like mod_status

Phusion Passenger has 'passenger-status', shows passenger's process status and other information. But, for continuous monitoring, we want to monitor passenger's status over network.
Apache httpd has 'mod_status'. Now, I wrote Rack middleware 'PassengerMonitor'. It returns passenger's process status with mod_status-like format.

https://github.com/tagomoris/passenger-monitor (Apache License v2)

Caution: This works with Passenger-3.x only.

How To Use

  1. Clone git repository above, or download 'passenger-monitor.rb', and place with your rack application.
  2. Insert codes below into config.ru (or app.rb for Sinatra project).
require 'passenger-monitor' # or use 'require_relative' for ruby 1.9 without custom $LOAD_PATH
use PassengerMonitor, :path => '/___server-status', :allow => ['127.0.0.1', '10.0.0.0/8', '192.168.10.0/24']
    • path: PassengerMonitor uses specified path as entry point. You MUST specify not to overwrite your application's path.
    • allow: Source IP/Network list you allow to access PassengerMonitor status information.
  1. Change user Passenger works.
    • Phusion Passenger run on 'nobody' user in default, but nobody user cannot access Passenger's status. So you should specify directives below in Apache configuration.
 PassengerDefaultUser root
    • You must specify owner user of file 'passenger-status-password.txt'.
 /tmp/passenger.1.0.26390/generation-0/passenger-status-password.txt

After configuration and restarting httpd, you can access Passenger's process status from allowed network by 'GET /___server-status'.

Busy Processes (Active): 1
Idle Processes: 0
Total Processes (Count): 1
Max Processes: 6
Global Queue Size: 0

'passenger-status' doesn't have 'Idle Process' information. I add this field as (count - active).

What I think to do next...
Memory status
Phusion Passenger 3.0 provides memory status, so we can add features to show memory status information. But, usually, we are monitoring memory status per host, not per application server process. How many people wants continuous memory status monitoring of processes over http?
Passenger's UID
I think that 'PassengerDefaultUser root' is not good configuration. For this problem, we shoud write patches for passenger. Hmm...
Ruby Advent Calendar 2010: jp-en

This entry is for Ruby Advent Calendar jp-en: 2010.

Previous post is from sorah, And next post will be from ser1zw.