def _AnalyzeAsadmSummaryResults()

in perfkitbenchmarker/traces/asadm.py [0:0]


def _AnalyzeAsadmSummaryResults(metadata, output, samples):
  """Parse asadm result.

  Sample data:
    [ 2023-10-18 21:35:28 'summary' sleep: 2.0s iteration: 77 ]
    ~~~~~~~~~~~~~~~~~~~~~~~~~Cluster Summary~~~~~~~~~~~~~~~~~~~~~~~~~
    Migrations                |False
    Server Version            |E-6.2.0.19
    OS Version                |Ubuntu 20.04.6 LTS (5.15.0-1042-gcp)
    Cluster Size              |1
    Devices Total             |12
    Devices Per-Node          |12
    Devices Equal Across Nodes|True
    Memory Total              |1.087 TB
    Memory Used               |53.644 GB
    Memory Used %             |4.82
    Memory Avail              |1.034 TB
    Memory Avail%             |95.18
    Device Total              |24.000 TB
    Device Used               |898.540 GB
    Device Used %             |3.66
    Device Avail              |23.040 TB
    Device Avail%             |96.0
    License Usage Latest      |865.851 GB
    Active                    |1
    Total                     |2
    Active Features           |KVS
    Number of rows: 21

    ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~Namespace
    Summary~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    Namespace|~~~~Drives~~~~|~~~~~~~Memory~~~~~~~|~~~~~~~~Device~~~~~~~|Replication|
    Master|~License~~
            |Total|Per-Node|   Total|Used|Avail%|    Total|Used|Avail%|
            Factors|  Objects|~~Usage~~~
            |     |        |        |   %|      |         |   %|      |
            |         |    Latest
    bar      |    0|       0|4.000 GB| 0.0| 100.0|       --|  --|    --|
    2|  0.000  |  0.000 B
    test     |   12|      12|1.083 TB|4.84| 95.16|24.000 TB|3.66|  96.0|
    1|900.000 M|865.851 GB
    Number of rows: 2
    0. timestamp: 1234567890

  Args:
    metadata: metadata of the sample.
    output: the output of the stress-ng benchmark.
    samples: list of samples to return.
  """
  output_lines = output.splitlines()
  timestamps_in_ms = []
  memory_used = []
  memory_used_percentages = []
  disk_used = []
  disk_used_percentages = []
  for line in output_lines:
    if not line:  # Skip if the line is empty.
      continue
    if re.search(r'\[.*\]', line):
      timestamps_in_ms.append(ParseTimestamp(line))
      continue
    line_split = line.split('|')
    if not line_split or len(line_split) != 2:
      continue
    name = line_split[0].strip()
    value_str = line_split[1].strip()
    if name == 'Memory Used':
      value, unit = ParseUsedValue(value_str)
      memory_used.append(ConvertToGB(value, unit))
    elif name == 'Memory Used %':
      memory_used_percentages.append(float(value_str))
    elif name == 'Device Used':
      value, unit = ParseUsedValue(value_str)
      disk_used.append(ConvertToGB(value, unit))
    elif name == 'Device Used %':
      disk_used_percentages.append(float(value_str))

  effective_metric_length = len(timestamps_in_ms)
  if (
      not len(timestamps_in_ms)
      == len(memory_used)
      == len(memory_used_percentages)
      == len(disk_used)
      == len(disk_used_percentages)
  ):
    logging.warning(
        'Lists are not in the same length: timestamps[%d], memory_used[%d],'
        ' memory_used_percentages[%d], disk_used[%d],'
        ' disk_used_percentages[%d]',
        len(timestamps_in_ms),
        len(memory_used),
        len(memory_used_percentages),
        len(disk_used),
        len(disk_used_percentages),
    )
    effective_metric_length = min(
        len(timestamps_in_ms),
        len(memory_used),
        len(memory_used_percentages),
        len(disk_used),
        len(disk_used_percentages),
    )
  samples.extend([
      sample.CreateTimeSeriesSample(
          values=memory_used[:effective_metric_length],
          timestamps=timestamps_in_ms[:effective_metric_length],
          metric=MEMORY_USED_METRIC,
          units=DEFAULT_RESOURCE_SIZE_UNIT,
          interval=metadata['interval'],
      ),
      sample.CreateTimeSeriesSample(
          values=memory_used_percentages[:effective_metric_length],
          timestamps=timestamps_in_ms[:effective_metric_length],
          metric=MEMORY_USED_PERCENTAGES_METRIC,
          units='%',
          interval=metadata['interval'],
      ),
      sample.CreateTimeSeriesSample(
          values=disk_used[:effective_metric_length],
          timestamps=timestamps_in_ms[:effective_metric_length],
          metric=DISK_USED_METRIC,
          units=DEFAULT_RESOURCE_SIZE_UNIT,
          interval=metadata['interval'],
      ),
      sample.CreateTimeSeriesSample(
          values=disk_used_percentages[:effective_metric_length],
          timestamps=timestamps_in_ms[:effective_metric_length],
          metric=DISK_USED_PERCENTAGES_METRIC,
          units='%',
          interval=metadata['interval'],
      ),
  ])