The London Perl and Raku Workshop takes place on 26th Oct 2024. If your company depends on Perl, please consider sponsoring and/or attending.

NAME

Mojolicious::Plugin::ServerStatus - show server status like Apache's mod_status

SYNOPSIS

    plugin 'ServerStatus' => {
        path => '/server-status',
        allow => [ '127.0.0.1', '192.168.0.0/16' ],
    };

  % curl http://server:port/server-status
  Uptime: 1234567789
  Total Accesses: 123
  BusyWorkers: 2
  IdleWorkers: 3
  --
  pid status remote_addr host method uri protocol ss
  20060 A 127.0.0.1 localhost:10001 GET / HTTP/1.1 1
  20061 .
  20062 A 127.0.0.1 localhost:10001 GET /server-status HTTP/1.1 0
  20063 .
  20064 .

  # JSON format
  % curl http://server:port/server-status?json
  {"Uptime":"1332476669","BusyWorkers":"2",
   "stats":[
     {"protocol":null,"remote_addr":null,"pid":"78639",
      "status":".","method":null,"uri":null,"host":null,"ss":null},
     {"protocol":"HTTP/1.1","remote_addr":"127.0.0.1","pid":"78640",
      "status":"A","method":"GET","uri":"/","host":"localhost:10226","ss":0},
     ...
  ],"IdleWorkers":"3"}

DESCRIPTION

Mojolicious::Plugin::ServerStatus is display server status in multiprocess Mojo servers such as morbo and hypnotoad . This module changes status only before and after executing the application. so cannot monitor keepalive session and network i/o wait.

CONFIGURATIONS

path
  path => '/server-status',

location that displays server status

allow
  allow => '127.0.0.1'
  allow => ['192.168.0.0/16', '10.0.0.0/8']

host based access control of a page of server status. supports IPv6 address.

scoreboard
  scoreboard => '/path/to/dir'

Scoreboard directory, Mojolicious::Plugin::ServerStatus stores processes activity information in

counter_file
  counter_file => '/path/to/counter_file'

Enable Total Access counter

skip_ps_command
  skip_ps_command => 1 or 0

ServerStatus executes `ps command` to find all worker processes. But in some systems that does not mount "/proc" can not find any processes. IF 'skip_ps_command' is true, ServerStatus does not `ps`, and checks only processes that already did process requests.

TOTAL BYTES

The largest integer that 32-bit Perl can store without loss of precision is 2**53. So rather than getting all fancy with Math::BigInt, we're just going to be conservative and wrap that around to 0. That's enough to count 1 GB per second for a hundred days.

WHAT DOES "SS" MEAN IN STATUS

Seconds since beginning of most recent request

AUTHOR

fu kai <iakuf {at} 163.com>

SEE ALSO

Original ServerStatus by <https://metacpan.org/pod/Plack::Middleware::ServerStatus::Lite>

Plack::Middleware::ServerStatus::Lite

LICENSE

This library is free software; you can redistribute it and/or modify it under the same terms as Perl itself.