/var/lib/pcp/testsuite/archives/mk.rank-pred 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 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 | #!/usr/bin/env pmpython
# -*- coding: utf-8 -*-
# pylint: disable=invalid-name
""" Generate a test archive for testing ranking, predicates, and limit filtering """
from pcp import pmapi, pmi
# Our metrics for testing
metrics = ["disk.dev.read", "disk.dev.write",
"kernel.pernode.cpu.user", "kernel.pernode.cpu.sys",
"mem.util.used"]
# Instances / disk
insts_d = ["sda", "sdb", "sdc", "sdd", "sde"]
# Instance / kernel
insts_k = ["cpu0", "cpu1", "cpu2", "cpu3", "cpu4", "cpu5", "cpu6", "cpu7"]
# Get a context
pmfg = pmapi.fetchgroup()
ctx = pmfg.get_context()
# Initialize the archive
arch = pmi.pmiLogImport("rank-pred")
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)
inst = -1
for name in insts_k:
inst += 1
pmids = ctx.pmLookupName("kernel.pernode.cpu.user")
descs = ctx.pmLookupDescs(pmids)
indom = descs[0].contents.indom
arch.pmiAddInstance(indom, name, inst)
# Timestamp
start = 0
batch = -1
# Start values
for _ in range(2):
batch += 1
value = batch
for name in insts_d:
arch.pmiPutValue("disk.dev.read", name, "%d" % value)
arch.pmiPutValue("disk.dev.write", name, "%d" % value)
for name in insts_k:
arch.pmiPutValue("kernel.pernode.cpu.user", name, "%d" % value)
arch.pmiPutValue("kernel.pernode.cpu.sys", name, "%d" % value)
arch.pmiPutValue("mem.util.used", None, "%d" % value)
arch.pmiWrite(start + batch, 0)
# Values for ranking tests
for _ in range(5):
batch += 1
for name in insts_d:
value = batch
if name == insts_d[1]:
value *= 2
if name == insts_d[3]:
value *= 3
arch.pmiPutValue("disk.dev.read", name, "%d" % value)
arch.pmiPutValue("disk.dev.write", name, "%d" % value)
for name in insts_k:
value = batch
if name == insts_k[1]:
value *= 2
if name == insts_k[3]:
value *= 3
arch.pmiPutValue("kernel.pernode.cpu.user", name, "%d" % value)
arch.pmiPutValue("kernel.pernode.cpu.sys", name, "%d" % value)
arch.pmiPutValue("mem.util.used", None, "%d" % batch)
arch.pmiWrite(start + batch, 0)
# Values for predicate tests
base = 100
for _ in range(5):
batch += 1
value = base + batch
arch.pmiPutValue("disk.dev.read", "sdc", "%d" % value)
arch.pmiPutValue("kernel.pernode.cpu.sys", "cpu2", "%d" % value)
for name in insts_d:
value = batch
arch.pmiPutValue("disk.dev.write", name, "%d" % value)
if name == "sdc":
continue
arch.pmiPutValue("disk.dev.read", name, "%d" % value)
for name in insts_k:
value = batch
arch.pmiPutValue("kernel.pernode.cpu.user", name, "%d" % value)
if name == "cpu2":
continue
arch.pmiPutValue("kernel.pernode.cpu.sys", name, "%d" % value)
arch.pmiPutValue("mem.util.used", None, "%d" % batch)
arch.pmiWrite(start + batch, 0)
# End values before limit tests
for _ in range(2):
batch += 1
for name in insts_d:
arch.pmiPutValue("disk.dev.read", name, "%d" % 1000)
arch.pmiPutValue("disk.dev.write", name, "%d" % 1000)
for name in insts_k:
arch.pmiPutValue("kernel.pernode.cpu.user", name, "%d" % 1000)
arch.pmiPutValue("kernel.pernode.cpu.sys", name, "%d" % 1000)
arch.pmiPutValue("mem.util.used", None, "%d" % 1000)
arch.pmiWrite(start + batch, 0)
# Continue with even values
for _ in range(2):
batch += 1
for name in insts_d:
arch.pmiPutValue("disk.dev.read", name, "%d" % 1000)
arch.pmiPutValue("disk.dev.write", name, "%d" % 1000)
for name in insts_k:
arch.pmiPutValue("kernel.pernode.cpu.user", name, "%d" % 1000)
arch.pmiPutValue("kernel.pernode.cpu.sys", name, "%d" % 1000)
arch.pmiPutValue("mem.util.used", None, "%d" % 1000)
arch.pmiWrite(start + batch, 0)
# End with predicate instances low, others high, all varying
for i in range(2):
batch += 1
for j, name in enumerate(insts_d):
arch.pmiPutValue("disk.dev.read", name, "%d" % (10 + j))
arch.pmiPutValue("disk.dev.write", name, "%d" % (100 - j))
for j, name in enumerate(insts_k):
arch.pmiPutValue("kernel.pernode.cpu.user", name, "%d" % (10 + j))
arch.pmiPutValue("kernel.pernode.cpu.sys", name, "%d" % (100 - j))
arch.pmiPutValue("mem.util.used", None, "%d" % batch)
arch.pmiWrite(start + batch, 0)
# Done
arch.pmiEnd()
|