## -*- mode: python; coding: utf-8 -*-

## qdisc-stats

AGGREGATOR='timeseries'
TOTAL_LENGTH=LENGTH
DESCRIPTION="Capture qdisc stats"
DEFAULTS={'PLOT': 'backlog'}


DATA_SETS = o([
    ('qdisc-stats',
     {'command': find_tc_iterate(TEST_PARAMETERS.get('interface'), STEP_SIZE, LENGTH),
      'units': 'ms',
      'runner': 'tc',}),
     ('qdisc-stats::backlog_pkts', {'units': 'packets', 'runner': 'null'}),
     ('qdisc-stats::backlog_bytes', {'units': 'bytes', 'runner': 'null'}),
     ('qdisc-stats::dropped', {'units': 'packets', 'data_transform': 'cumulative_to_events', 'runner': 'null'}),
     ('qdisc-stats::ecn_mark', {'units': 'packets', 'data_transform': 'cumulative_to_events', 'runner': 'null'}),
     ('qdisc-stats::delay', {'units': 'ms', 'runner': 'null'}),
])

PLOTS = o([
    ('backlog',
     {'description': 'Queue backlog',
      'type': 'timeseries',
      'axis_labels': ['Packets', 'Bytes'],
      'dual_axes': True,
      'series': [
          {'data': 'qdisc-stats::backlog_pkts',
           'label': 'Backlog (packets)'},
          {'data': 'qdisc-stats::backlog_bytes',
           'label': 'Backlog (bytes)',
           'axis': 2},
      ]}),
    ('drops',
     {'description': 'Packet drops',
      'type': 'timeseries',
      'axis_labels': ['Packets'],
      'series': [
          {'data': 'qdisc-stats::dropped',
           'label': 'Drops',
           'linestyle': '',
           'marker': 'x'},
          {'data': 'qdisc-stats::ecn_mark',
           'label': 'ECN marks',
           'linestyle': '',
           'marker': 'o'},
      ]}),
    ('delay',
     {'description': 'Queue delay',
      'type': 'timeseries',
      'axis_labels': ['Queueing delay (ms)'],
      'series': [
          {'data': 'qdisc-stats::delay',
           'label': 'Queue delay'}
      ]}),
])
