The monitor Module

A utility that prints the DBMS activity statistics, like currently running processes and some details about each process.

It can be used as a command line utility to monitor database activity or monitor a specific process.

It can also be used as Python API to run a long-running process within a database with performance monitoring.

class Lock(data: List)[source]

Class resenting detailed information about a database lock

See also PostgreSQL Documentation

class DBMonitorConfig(subclass, doc)[source]

Configuration for DBActivityMonitor class, a subclass of a general class dorieh.platform.loader.common.DBConnectionConfig

It adds two parameters:

  • pid - process id to monitor. If it is given, then only this process is monitored

  • status - if this parameter is defined only processes with the specified status are monitored

Creates a new object

Parameters:
  • subclass – A concrete class containing configuration information Configuration options must be defined as class memebers with names, starting with one ‘_’ characters and values be instances of :class Argument:

  • description – Optional text to use as description. If not specified, then it is extracted from subclass documentation

pid: List[int]

process id list

state: Optional[str]

Display only processes in the given state

class DBActivityMonitor(context: Optional[DBConnectionConfig] = None)[source]

Main class of this module. Provides API to monitor database activity and execute long-running processes while monitoring their status.

classmethod get_instance(context: DBConnectionConfig) DBMonitorConfig[source]
run()[source]

This method is being run when the module is used as CLI. Prints current activity for selected processes. Processes are selected based on the value of pid and status configuration parameters.

See dorieh.platform.loader.monitor.DBMonitorConfig :return:

get_blocks()[source]

Internal method

get_indexing_progress() List[str][source]

This method provides a more detailed statistics for processes that build an index. :return:

get_activity(pid: Optional[int] = None) List[str][source]

Returns a list of statuses, one status for every processed being monitored.

Parameters:

pid – optional process id, if given only status of this process would be provided

Returns:

static execute(what: Callable, on_monitor: Callable)[source]

Executes a process in the database while periodically outputting the process status

Parameters:
  • what – A Python function that calls a process in the database

  • on_monitor – A Python callback function that is called to output the desired information

Returns:

log_activity(pid: int)[source]

Log activity of the given process using configured Python loggers :param _sphinx_paramlinks_dorieh.platform.loader.monitor.DBActivityMonitor.log_activity.pid: The process id to log the status of :return:

class Activity(activity: ~typing.Dict, known_blocks, now: <module 'datetime' from '/Library/Frameworks/Python.framework/Versions/3.10/lib/python3.10/datetime.py'>, msg_len=32)[source]

A class representing database activity