Hoststats view

Example of usage:

import asyncio

from activelogic import liveview
from pprint import pprint


async def process_data_in_update(data):
    pprint(data)


async def liveviewexample():
    v = liveview.HoststatsView('ws://192.168.1.25:8000/hoststats-view')

    v.add_metrics('quality_rtt_samples_ext', 'quality_rtt_samples_int', 3)
    d1 = liveview.Dimension('subscriber', 'session/subscriber')
    d2 = liveview.Dimension('service_plan', 'session/service_plan')
    v.add_dimensions(d1, d2)

    vt = liveview.HoststatsViewType
    v.set_view_type(vt.NO_AGGREGATION)

    f1 = liveview.ViewExcludeFilter('session_context', 'Sub10_0_0_3', 'session/subscriber')
    f2 = liveview.ViewExcludeFilter('session_context', 'Sub10_0_0_1', 'session/subscriber')
    v.add_filters(f1, f2)

    await v.connect()

    print("Available dimensions:", v.dimensions())

    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.HoststatsView

Object representing a Hoststats view which can have ViewFilters, Dimensions, Metrics and view type

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 HoststatsView.connect().

v = HostatsView("ws://172.21.91.128:8000/hoststats-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 = HoststatsView("wss://172.21.91.128:443/hoststats-view", ssl_context)
async HoststatsView.connect()

Attempts to open a connection to the websocket server.

HoststatsView.connected()
Returns

True if connection is up, otherwise False.

async HoststatsView.close()

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

HoststatsView.set_view_type(view_type)

Sets the view type.

Parameters

view_type (HoststatsViewType) – The aggregation view type

HoststatsView.set_partition_dimension_id(dim_id)

Set dimension to partition by

Parameters

dim_id (int) – Dimension id

HoststatsView.add_partition_ids(ids)

Set partition ids to subscribe to

Parameters

ids (list) – List of partition ids

HoststatsView.add_filters(*filters)

Adds one or more filters to a View

>>> v.add_filters(ViewIncludeFilter('Host', '10.0.0.249'))
HoststatsView.add_metrics(*metrics)

Sets the metrics to be returned on message updates.

Parameters

metrics (str/int) – Metric names or Metric ids

async HoststatsView.wait_for_update()

Wait for the next update.

Returns

dict

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

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

Each row is returned as a dict with the keys dimensions, hf_metrics, lf_metrics and timestamp.

class activelogic.liveview.HoststatsViewType

Defines the view types a host stats view supports:

Variables
  • NO_AGGREGATION – No aggregation

  • TIMESTAMP – Timestamp based aggregation

  • DIMENSION – Dimension based aggregation

HoststatsViewFilter

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 HoststatsView.

HoststatsView.filters()

List of available filters presented by the connected system

Returns

List of filters that can be applied on a View

HoststatsViewDimensions

Dimensions that can be applied on a HoststatsView.

HoststatsView.dimensions()

List of available dimensions presented by the connected system.

Returns

List of dimensions that can be applied on a HoststatsView

HoststatsViewMetrics

Metrics that can be applied on a HoststatsView.

HoststatsView.lf_metrics()

List of available low fequency metrics presented by the connected system.

Returns

List of low frequency metrics that can be applied on a HoststatsView

HoststatsViewViewTypes

View types that can be applied on a HoststatsView.

HoststatsView.view_types()

List of available view types presented by the connected system.

Returns

List of view types that can be applied on a HoststatsView