/var/lib/pcp/testsuite/archives/mk.value-test 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 | #!/usr/bin/env pmpython
# -*- coding: utf-8 -*-
# pylint: disable=invalid-name
""" Generate a test archive with challenging values """
import sys
from pcp import pmapi, pmi
# Our metrics for testing
metrics = ["kernel.all.uptime", "sample.float.one", "kernel.uname.release"]
# Get a context
pmfg = pmapi.fetchgroup()
ctx = pmfg.get_context()
# Initialize the archive
arch = pmi.pmiLogImport("value-test")
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)
# Timestamp
start = 0
batch = -1
# Start with sane values
batch += 1
arch.pmiPutValue("kernel.all.uptime", None, "%d" % 1234567)
arch.pmiPutValue("sample.float.one", None, "%f" % 1234567.0)
arch.pmiPutValue("kernel.uname.release", None, "1.2.3")
arch.pmiWrite(start + batch, 0)
if sys.version_info[0] >= 3:
int_max = sys.maxsize
else:
int_max = sys.maxint
# Integer tests
batch += 1
arch.pmiPutValue("kernel.all.uptime", None, "%d" % (int_max+1))
arch.pmiWrite(start + batch, 0)
batch += 1
arch.pmiPutValue("kernel.all.uptime", None, "%d" % int_max)
arch.pmiWrite(start + batch, 0)
batch += 1
arch.pmiPutValue("kernel.all.uptime", None, "%d" % 1)
arch.pmiWrite(start + batch, 0)
batch += 1
arch.pmiPutValue("kernel.all.uptime", None, "%d" % 0)
arch.pmiWrite(start + batch, 0)
batch += 1
arch.pmiPutValue("kernel.all.uptime", None, "%d" % -1)
arch.pmiWrite(start + batch, 0)
batch += 1
arch.pmiPutValue("kernel.all.uptime", None, "%d" % -int_max)
arch.pmiWrite(start + batch, 0)
batch += 1
arch.pmiPutValue("kernel.all.uptime", None, "%d" % (-int_max-1))
arch.pmiWrite(start + batch, 0)
# Floating point tests
batch += 1
arch.pmiPutValue("sample.float.one", None, "%f" % float("NaN"))
arch.pmiWrite(start + batch, 0)
batch += 1
arch.pmiPutValue("sample.float.one", None, "%f" % float("inf"))
arch.pmiWrite(start + batch, 0)
batch += 1
arch.pmiPutValue("sample.float.one", None, "%f" % (int_max+1))
arch.pmiWrite(start + batch, 0)
batch += 1
arch.pmiPutValue("sample.float.one", None, "%f" % int_max)
arch.pmiWrite(start + batch, 0)
batch += 1
arch.pmiPutValue("sample.float.one", None, "%f" % 1)
arch.pmiWrite(start + batch, 0)
batch += 1
arch.pmiPutValue("sample.float.one", None, "%f" % 0)
arch.pmiWrite(start + batch, 0)
batch += 1
arch.pmiPutValue("sample.float.one", None, "%f" % -1)
arch.pmiWrite(start + batch, 0)
batch += 1
arch.pmiPutValue("sample.float.one", None, "%f" % -int_max)
arch.pmiWrite(start + batch, 0)
batch += 1
arch.pmiPutValue("sample.float.one", None, "%f" % (-int_max-1))
arch.pmiWrite(start + batch, 0)
batch += 1
arch.pmiPutValue("sample.float.one", None, "%f" % float("-inf"))
arch.pmiWrite(start + batch, 0)
batch += 1
arch.pmiPutValue("sample.float.one", None, "%f" % float("-NaN"))
arch.pmiWrite(start + batch, 0)
# String tests
batch += 1
arch.pmiPutValue("kernel.uname.release", None, "null:\00:string")
arch.pmiWrite(start + batch, 0)
batch += 1
arch.pmiPutValue("kernel.uname.release", None, "line:\n:break")
arch.pmiWrite(start + batch, 0)
batch += 1
arch.pmiPutValue("kernel.uname.release", None, "this:\":is:\\':a:':quote:\\\":test")
arch.pmiWrite(start + batch, 0)
batch += 1
arch.pmiPutValue("kernel.uname.release", None, "char:<:&:`:$:;:!:#: :?:*:|:~:>:test")
arch.pmiWrite(start + batch, 0)
batch += 1
arch.pmiPutValue("kernel.uname.release", None, "")
arch.pmiWrite(start + batch, 0)
batch += 1
arch.pmiPutValue("kernel.uname.release", None, "dont:\n;touch /tmp/toast;\n:eval")
arch.pmiWrite(start + batch, 0)
batch += 1
arch.pmiPutValue("kernel.uname.release", None, "X" * 1024)
arch.pmiWrite(start + batch, 0)
batch += 1
arch.pmiPutValue("kernel.uname.release", None, "X" * 1024 * 1024)
arch.pmiWrite(start + batch, 0)
batch += 1
arch.pmiPutValue("kernel.uname.release", None, "X" * 1024 ** 3)
arch.pmiWrite(start + batch, 0)
batch += 1
arch.pmiPutValue("kernel.uname.release", None, "some:åäöšŠžŽ€🙃§½¼¾:unicode")
arch.pmiWrite(start + batch, 0)
# End with sane values
batch += 1
arch.pmiPutValue("kernel.all.uptime", None, "%d" % 7654321)
arch.pmiPutValue("sample.float.one", None, "%f" % 7654321)
arch.pmiPutValue("kernel.uname.release", None, "3.2.1")
arch.pmiWrite(start + batch, 0)
# Done
arch.pmiEnd()
|