API

aiomonitor has tiny and simple to use API, just factory function and class that support context management protocol. Start monitor as simple as open file.

import asyncio
import aiomonitor

loop = asyncio.get_event_loop()
with aiomonitor.start_monitor(loop):
    print("Now you can connect with: nc localhost 50101")
    loop.run_forever()

Alternatively you can use more verbose try/finally approach but do not forget call close() methods, to join thread and finalize resources:

m = Monitor()
m.start()
try:
    loop.run_forever()
finally:
    m.close()

Refernece

MONITOR_HOST = '127.0.0.1'

Specifies the default host for monitor, by default monitor binded to localhost.

MONITOR_PORT = 50101

Specifies the default port for monitor, you can connect using telnet client

CONSOLE_PORT = 50102

Specifies the default port for asynchronous python REPL

aiomonitor.start_monitor(loop, host=None, port=MONITOR_PORT, console_port=CONSOLE_PORT, console_enabled=True)

Factory function, creates instance of Monitor and starts monitoring thread.

Parameters:
  • host (str) – hostname to serve monitor telnet server
  • port (int) – monitor port, by default 50101
  • console_port (int) – python REPL port, by default 50102
  • console_enabled (bool) – flag indicates if python REPL is requred to start with instance of monitor.
class aiomonitor.Monitor
Class has same arguments as start_monitor()
start()

Starts monitoring thread, where telnet server is executed.

close()

Joins background thread, and cleans up resources.

closed

Flag indicates if monitor was closed, currntly instance of Monitor can not be reused. For new monitor, new instance should be created.