Skip to main content

SystemStatus

Provides a simple interface for evaluating system resource usage from snapshots collected by Snapshotter.

This class aggregates and interprets snapshots from a Snapshotter instance to evaluate the current and historical status of system resources like CPU, memory, event loop, and client API usage. It exposes two methods get_current_system_info and get_historical_system_info. The system information is computed using a weighted average of overloaded messages in the snapshots, with the weights being the time intervals between the snapshots. Each resource is computed separately, and the system is considered as overloaded whenever at least one resource is overloaded.

get_current_system_info returns a SystemInfo data structure that represents the current status of the system. The length of the current timeframe in seconds is configurable by the max_snapshot_age option and represents the max age of snapshots to be considered for the computation.

SystemStatus.get_historical_system_info returns a SystemInfo that represents the long-term status of the system. It considers the full snapshot history available in the Snapshotter instance.

Index

Methods

__init__

  • __init__(*, snapshotter, max_snapshot_age, cpu_overload_threshold, memory_overload_threshold, event_loop_overload_threshold, client_overload_threshold): None
  • A default constructor.


    Parameters

    • optionalkeyword-onlysnapshotter: Snapshotter

      The Snapshotter instance to be queried for SystemStatus.

    • optionalkeyword-onlymax_snapshot_age: timedelta = timedelta(seconds=5)

      Defines max age of snapshots used in the SystemStatus.get_current_system_info measurement.

    • optionalkeyword-onlycpu_overload_threshold: float = 0.4

      Sets the threshold of overloaded snapshots in the CPU sample. If the sample exceeds this threshold, the system will be considered overloaded.

    • optionalkeyword-onlymemory_overload_threshold: float = 0.2

      Sets the threshold of overloaded snapshots in the memory sample. If the sample exceeds this threshold, the system will be considered overloaded.

    • optionalkeyword-onlyevent_loop_overload_threshold: float = 0.6

      Sets the threshold of overloaded snapshots in the event loop sample. If the sample exceeds this threshold, the system will be considered overloaded.

    • optionalkeyword-onlyclient_overload_threshold: float = 0.3

      Sets the threshold of overloaded snapshots in the Client sample. If the sample exceeds this threshold, the system will be considered overloaded.

    Returns None

get_current_system_info

  • Retrieves and evaluates the current status of system resources.

    Considers snapshots within the _max_snapshot_age timeframe and determines if the system is currently overloaded based on predefined thresholds for each resource type.


    Returns SystemInfo

get_historical_system_info

  • Retrieves and evaluates the historical status of system resources.

    Considers the entire history of snapshots from the Snapshotter to assess long-term system performance and determines if the system has been historically overloaded.


    Returns SystemInfo