/var/lib/pcp/testsuite/archives/mk.dyninsts is in pcp-testsuite 4.0.1-1.
This file is owned by root:root, with mode 0o755.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 | #!/usr/bin/env pmpython
# -*- coding: utf-8 -*-
# pylint: disable=invalid-name
""" Generate a test archive for testing dynamic header / instances """
from pcp import pmapi, pmi
# Our metrics for testing
metrics = ["disk.dev.read", "disk.dev.write", "mem.util.free", "mem.util.used"]
# Instances / disk
insts_d = ["sda", "sdb", "sdc", "sdd", "sde"]
# Get a context
pmfg = pmapi.fetchgroup()
ctx = pmfg.get_context()
# Initialize the archive
arch = pmi.pmiLogImport("dyninsts")
arch.pmiSetHostname("localhost")
arch.pmiSetTimezone("UTC")
for metric in metrics:
pmids = ctx.pmLookupName(metric)
descs = ctx.pmLookupDescs(pmids)
arch.pmiAddMetric(metric,
pmids[0],
descs[0].contents.type,
descs[0].contents.indom,
descs[0].contents.sem,
descs[0].contents.units)
inst = -1
for name in insts_d:
inst += 1
pmids = ctx.pmLookupName("disk.dev.read")
descs = ctx.pmLookupDescs(pmids)
indom = descs[0].contents.indom
arch.pmiAddInstance(indom, name, inst)
# Timestamp
start = 0
batch = -1
# Two instance values (cumulative counters) appear
for _ in range(2):
batch += 1
for name in insts_d:
if name in ('sda', 'sdb'):
arch.pmiPutValue("disk.dev.read", name, "%d" % batch)
arch.pmiPutValue("disk.dev.write", name, "%d" % batch)
arch.pmiWrite(start + batch, 0)
# Two more instance values and a singular metric value appear
for _ in range(2):
batch += 1
for name in insts_d:
if name in ('sda', 'sdb', 'sdc', 'sdd'):
arch.pmiPutValue("disk.dev.read", name, "%d" % batch)
arch.pmiPutValue("disk.dev.write", name, "%d" % batch)
arch.pmiPutValue("mem.util.used", None, "%d" % batch)
arch.pmiWrite(start + batch, 0)
# Two instance values disappear
for _ in range(2):
batch += 1
for name in insts_d:
if name in ('sdb', 'sdd'):
arch.pmiPutValue("disk.dev.read", name, "%d" % batch)
arch.pmiPutValue("disk.dev.write", name, "%d" % batch)
arch.pmiPutValue("mem.util.used", None, "%d" % batch)
arch.pmiWrite(start + batch, 0)
# Two instance values still missing, the singular metric disappears,
# a new instance values appears but only for one, not both, metrics
for _ in range(2):
batch += 1
for name in insts_d:
if name in ('sdb', 'sdd'):
arch.pmiPutValue("disk.dev.read", name, "%d" % batch)
arch.pmiPutValue("disk.dev.write", name, "%d" % batch)
if name in ('sde'):
arch.pmiPutValue("disk.dev.read", name, "%d" % batch)
arch.pmiWrite(start + batch, 0)
# All values available
for _ in range(5):
batch += 1
for name in insts_d:
arch.pmiPutValue("disk.dev.read", name, "%d" % batch)
arch.pmiPutValue("disk.dev.write", name, "%d" % batch)
arch.pmiPutValue("mem.util.used", None, "%d" % batch)
arch.pmiWrite(start + batch, 0)
# Three instance values disappear
for _ in range(2):
batch += 1
for name in insts_d:
if name in ('sda', 'sdc'):
arch.pmiPutValue("disk.dev.read", name, "%d" % batch)
arch.pmiPutValue("disk.dev.write", name, "%d" % batch)
arch.pmiPutValue("mem.util.used", None, "%d" % batch)
arch.pmiWrite(start + batch, 0)
# All previous values gone, new singular metric appear
for _ in range(2):
batch += 1
arch.pmiPutValue("mem.util.free", None, "%d" % batch)
arch.pmiWrite(start + batch, 0)
# With both singular metrics gone, one lone instance appears for
# the last time, but at different times for the multi-valued metrics
i = 0
for _ in range(3):
batch += 1
for name in insts_d:
if name in ('sdb'):
arch.pmiPutValue("disk.dev.read", name, "%d" % batch)
if i:
arch.pmiPutValue("disk.dev.write", name, "%d" % batch)
i = 1
arch.pmiWrite(start + batch, 0)
# Done
arch.pmiEnd()
|