Skip to content

Commit

Permalink
pmrep/pmconfig.py: fix archive writing with scaled metrics
Browse files Browse the repository at this point in the history
pmrep/pmconfig.py were already using metadata from the source to
write archive metadata and raw values instead of counter rates.
For scaled metrics the native type needs to be used so that created
archives remain compatible with pmlogger created archives and that
stored metadata and values match each other.

QA 1072 updated to test this.
  • Loading branch information
myllynen committed Jun 21, 2021
1 parent 7dec92f commit 3806df8
Show file tree
Hide file tree
Showing 3 changed files with 62 additions and 2 deletions.
6 changes: 6 additions & 0 deletions qa/1072
Expand Up @@ -88,6 +88,12 @@ pmrep -u -s 5 -o archive -F $tmp.new_archive4 -z $log hinv.machine mem.util.used
pmrep -u -a $tmp.new_archive4 -z hinv.machine mem.util.used
pmdumplog -z -dim $tmp.new_archive4

echo "=== pmrep archive creation with scaled values"
pmrep -u -s 5 -o archive -F $tmp.new_archive5 -z $log2 -i sda,sdc disk.dev.write_bytes,,,MB | _pid_filter
# Using -r to display the unit in the archive
pmrep -u -a $tmp.new_archive5 -z -r disk.dev.write_bytes
pmdumplog -z -dim $tmp.new_archive5

rm -f $tmp.a1-out* $tmp.a2-out* $tmp.new_archive*

# success, all done
Expand Down
49 changes: 49 additions & 0 deletions qa/1072.out
Expand Up @@ -93,4 +93,53 @@ Instance Domains in the Log ...

14:39:17.882326 1 metric
60.1.1 (mem.util.used): value 13573800
=== pmrep archive creation with scaled values
Recording 1 metrics to TMP.new_archive5:
5 samples(s) with 1.0 sec interval ~ 4 sec duration.
d.d.write_bytes d.d.write_bytes
sda sdc
Kbyte Kbyte
369846691 948239088
369847163 948239160
369847575 948239236
369848903 948239408
369849315 948239540
Note: timezone set to local timezone of host "billing02" from archive


Descriptions for Metrics in the Log ...
PMID: 60.0.39 (disk.dev.write_bytes)
Data Type: 32-bit unsigned int InDom: 60.1 0xf000001
Semantics: counter Units: Kbyte

Instance Domains in the Log ...
InDom: 60.1
00:28:01.923022 2 instances
0 or "sda"
2 or "sdc"

00:28:01.923022 1 metric
60.0.39 (disk.dev.write_bytes):
inst [0 or "sda"] value 369846691
inst [2 or "sdc"] value 948239088

00:29:01.925641 1 metric
60.0.39 (disk.dev.write_bytes):
inst [0 or "sda"] value 369847163
inst [2 or "sdc"] value 948239160

00:30:01.923324 1 metric
60.0.39 (disk.dev.write_bytes):
inst [0 or "sda"] value 369847575
inst [2 or "sdc"] value 948239236

00:31:01.922091 1 metric
60.0.39 (disk.dev.write_bytes):
inst [0 or "sda"] value 369848903
inst [2 or "sdc"] value 948239408

00:32:01.922742 1 metric
60.0.39 (disk.dev.write_bytes):
inst [0 or "sda"] value 369849315
inst [2 or "sdc"] value 948239540
== done
9 changes: 7 additions & 2 deletions src/python/pcp/pmconfig.py
Expand Up @@ -869,8 +869,8 @@ def metric_base_check(metric):
self.util.metrics[metric][3] = 1
else:
self.util.metrics[metric][3] = 0
# As a special service for the pmrep(1) utility,
# we force raw output with its archive mode.
# Force raw output with archive mode of any tool in order to
# create pmlogger(1) compatible archives that can be merged.
if (hasattr(self.util, 'type') and self.util.type == 1) or \
self.util.metrics[metric][3] == 'raw' or \
(hasattr(self.util, 'output') and self.util.output == 'archive'):
Expand Down Expand Up @@ -930,6 +930,11 @@ def is_time(unit):
if not self.util.metrics[metric][2]:
self.util.metrics[metric][2] = str(unit)

# Force native units with archive mode of any tool in order to
# create pmlogger(1) compatible archives that can be merged.
if hasattr(self.util, 'output') and self.util.output == 'archive':
self.util.metrics[metric][2] = str(unit)

# Finalize text label and unit/scale
try:
label = self.util.metrics[metric][2]
Expand Down

0 comments on commit 3806df8

Please sign in to comment.