Sophie

Sophie

distrib > Mandriva > 2010.0 > i586 > media > contrib-release > by-pkgid > 02a377929ab7e6fcfb9133a7cae77813 > files > 102

python-medusa-0.5.4-5mdv2010.0.noarch.rpm

===========================================================================
			  The Monitor Server
===========================================================================
The monitor server gives the developer a way to get into a server while
it's running.  Here's a quick demonstration of how to get to your server
objects while in the monitor:

[rushing@gnome medusa]$ python monitor_client.py 127.0.0.1 9999
Enter Password: 
Python 1.5 (#47, Jul 27 1998, 00:59:35)  [GCC egcs-2.90.29 980515 (egcs-1.0.3 release)]
Copyright 1991-1995 Stichting Mathematisch Centrum, Amsterdam
Welcome to <secure_monitor_channel connected 127.0.0.1:10775 at 81dbdd8>
>>> from __main__ import *
>>> dir()
['CHAT_PORT', 'FTP_PORT', 'HOSTNAME', 'HTTP_PORT', 'IP_ADDRESS', 'MONITOR_PORT', 'PUBLISHING_ROOT', '__builtins__', 'asyncore', 'chat_server', 'cs', 'debug_mode', 'default_handler', 'dh', 'filesys', 'fs', 'ftp', 'ftp_server', 'hs', 'http_server', 'lg', 'logger', 'monitor', 'ms', 'os', 'resolver', 'rs', 'sh', 'status_handler', 'status_objects', 'sys', 'uh', 'unix_user_handler']
>>> ms
<secure_monitor_server listening :9999 at 812a6f8>
>>> rs
<caching_resolver  at 8133890>
>>> hs
<http_server listening :8080 at 81237a0>
>>> dir(hs)
['_fileno', 'accept', 'accepting', 'addr', 'bind', 'bytes_in', 'bytes_out', 'close', 'connect', 'connect_ex', 'dup', 'exceptions', 'family_and_type', 'fileno', 'getpeername', 'getsockname', 'getsockopt', 'handlers', 'ip', 'listen', 'logger', 'makefile', 'port', 'recv', 'recvfrom', 'send', 'sendto', 'server_name', 'server_port', 'setblocking', 'setsockopt', 'shutdown', 'socket', 'total_clients', 'total_requests']
>>> hs.total_clients
<counter value=0 at 8122468>
>>> cs
<chat_server listening :8888 at 8125bf0>
>>> cs.close()
log: closing channel 9:<chat_server listening :8888 at 8125bf0>
>>> 

Use 'exit' or 'Ctrl-D' to close a monitor session.

===========================================================================
			 Emergency Debug Mode
===========================================================================

Bugs and memory leaks in long-running servers may take weeks to show
up.  A useful debugging technique is to leave a crippled or bloated
server running, but to move the servers' sockets to different ports so
that you can start up another fresh copy in the meanwhile.

This allows you to debug the servers without forcing you to leave your
site broken while you do it.

Here's how:

Uncomment the support for '/status/emergency_debug' in <status_handler.py>

When your server goes ballistic, simply hit this URL.  This will shut
down the servers, and restart them on new ports.  Add 10000 to the old
port number, so if you were running a web server on port 80, it will
be moved to 10080.

Start up another copy of your system, which will run on the original
ports.

Now you can debug the errant servers in isolation.  Beats using GDB!