Aggregated view

Example of usage:

import asyncio
from activelogic import liveview


async def process_data_in_update(data):
    print(data)

async def liveviewexample():
    v = liveview.View('ws://127.0.1.2:8000/view')

    d = liveview.ViewDistribution('Local Host')
    d2 = liveview.ViewDistribution('Service')

    f = liveview.ViewIncludeFilter('Host', '10.0.0.249')

    v.add_distributions(d, d2)
    v.add_filters(f)
    v.expand_by_default(True)

    await v.connect()
    while v.connected():
        d = await v.wait_for_update()
        await process_data_in_update(d)

loop = asyncio.get_event_loop()
loop.run_until_complete(liveviewexample())
class activelogic.liveview.View

Object representing a liveview which can have ViewFilter and ViewDistributions

Parameters
  • ws_addr (str) – URL to which the websocket server will respond.

  • ssl (type) – Context used for the transport.

  • sslssl.SSLContext

This initializes the view. To connect, use View.connect().

v = View("ws://172.21.91.128:8000/view")

If the wss protocol is used, ssl must be:

  • A ssl.SSLContext object if the server uses a self-signed certificate.

  • True if the server uses a valid certificate that is signed by a CA that your Python installation trusts.

import ssl

ssl_context = ssl.SSLContext(ssl.PROTOCOL_TLS_CLIENT)
ssl_context.load_verify_locations("/path/to/certificate.pem")

v = View("wss://172.21.91.128:8000/view", ssl_context)
async View.connect()

Attempts to open a connection to the websocket server.

View.connected()
Returns

True if connection is up, otherwise False.

async View.close()

Performs the closing handshake and waits for the TCP connection to terminate.

View.add_distributions(*fields)

Adds one or more distributions to a View

>>> v.add_distributions(ViewDistribution('Local Host'), ViewDistribution('Service'))
View.add_filters(*filters)

Adds one or more filters to a View

>>> v.add_filters(ViewIncludeFilter('Host', '10.0.0.249'))
View.expand_by_default(expand)

If set to True, child items are included in data updates.

Parameters

expand (bool) – True or False

async View.wait_for_update()

Wait for the next update.

Returns

List of items.

This method is used to get continuous data updates from the connected system:

while v.connected():
    d = await v.wait_for_update()

Each item in the list of data is represented as a dict, where each key/value pair represents a column:

  • name - the name of the list item

  • children - child items, see expand_by_default()

  • inbound - inbound bandwidth

  • outbound - outbound bandwidth

  • in.int.quality - quality metric for inbound packets on internal channel interface

  • in.ext.quality - quality metric for inbound packets on external channel interface

  • out.int.quality - quality metric for outbound packets on internal channel interface

  • out.ext.quality - quality metric for outbound packets on external channel interface

  • in.shapingavg.latency - Average latency of inbound packets added by shaping

  • in.shapingmax.latency - Inbound packet with highest latency added by shaping

  • in.shapingdrops - Number of packets inbound dropped due to shaping

  • in.shapingtotal - Number of packets inbound processed by shaping

  • out.shapingavg.latency - Average latency of outbound packets added by shaping

  • out.shapingmax.latency - Outbound packet with highest latency added by shaping

  • out.shapingdrops - Number of packets outbound dropped due to shaping

  • out.shapingtotal - Number of packets outbound processed by shaping

  • int.rtt - Handshake RTT for internal side

  • ext.rtt - Handshake RTT for external side

  • connections - Total number of currently seen connections

ViewFilter

class activelogic.liveview.ViewIncludeFilter

Filter that only includes connections where property matches one of the specified values.

Parameters
  • name (str) – Filtering property

  • values – Value or tuple of filtering values.

  • arg (str) – Additional filtering argument.

>>> ViewIncludeFilter('Host', '10.0.0.249')
>>> ViewIncludeFilter('Flags', True, 'ASYMMETRIC')
>>> ViewIncludeFilter('Session Context', ('Gold', 'Silver', 'Bronze'), 'S1/plan')
class activelogic.liveview.ViewExcludeFilter

Filter that excludes connections where property matches one of the specified values.

Parameters
  • name (str) – Filtering property

  • values – Value or tuple of filtering values.

  • arg (str) – Additional filtering argument.

>>> ViewExcludeFilter('Host', '10.0.0.249')

Filters that can be applied on a View.

View.filters()

List of available filters presented by the connected system

Returns

List of filters that can be applied on a View

View.services()

List of available services presented by the connected system

Returns

List of services that can be used by a filter

ViewDistribution

class activelogic.liveview.ViewDistribution

Object representing a distribution on a view.

>>> d = ViewDistribution('Local Host')

Distributions that can be applied on a View.

View.fields()

List of available fields presented by the connected system

Returns

List of fields that can be applied for distribution on a View