File: 1131

package info (click to toggle)
pcp 7.1.0-1
  • links: PTS
  • area: main
  • in suites: forky, sid
  • size: 252,748 kB
  • sloc: ansic: 1,483,656; sh: 182,366; xml: 160,462; cpp: 83,813; python: 24,980; perl: 18,327; yacc: 6,877; lex: 2,864; makefile: 2,738; awk: 165; fortran: 60; java: 52
file content (118 lines) | stat: -rwxr-xr-x 3,157 bytes parent folder | download
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
#!/bin/sh
# PCP QA Test No. 1131
# Exercise pcp2json, pcp2openmetrics, and pcp2opentelemetry.
#
# Copyright (c) 2025 Red Hat.
#

seq=`basename $0`
echo "QA output created by $seq"

. ./common.python

$python -c "from pcp import pmapi" >/dev/null 2>&1
[ $? -eq 0 ] || _notrun "python pcp pmapi module not installed"
$python -c "from collections import OrderedDict" >/dev/null 2>&1
[ $? -eq 0 ] || _notrun "python collections OrderedDict module not installed"

which pcp2json >/dev/null 2>&1 || _notrun "pcp2json not installed"
which pcp2openmetrics >/dev/null 2>&1 || _notrun "pcp2openmetrics not installed"
which pcp2opentelemetry >/dev/null 2>&1 || _notrun "pcp2opentelemetry not installed"

_cleanup()
{
    cd $here
    _restore_config $PCP_SYSCONF_DIR/labels
    $sudo rm -rf $tmp.*
}

status=1       # failure is the default!
signal=$PCP_BINADM_DIR/pmsignal
trap "_cleanup; exit \$status" 0 1 2 3 15

A="$here/archives/rep"
A1="$here/archives/20180606"
hostname=`hostname`
machineid=`_machine_id`
domainid=`_domain_name`

_archive_filter()
{
    sed -e "s,$A,ARCHIVE_PATH,g"
}

_value_filter()
{
    sed 's/\(\.[0-9]\)[0-9]*/\1/g'
}

_filter_pcp2openmetrics()
{
    # Note: need PMID filter for each platform, where the PMID of
    #       hinv.ncpu may be different
    #
    tee -a $seq_full \
    | col -b \
    | sed \
	-e '/hostname=/s/'$hostname'/HOST/' \
	-e '/domainname=/s/'$domainid'/DOMAINID/' \
	-e '/machineid=/s/'$machineid'/MACHINEID/' \
	-e '/groupid=/s/groupid="*[0-9][0-9]*"*/groupid="GROUPID"/' \
	-e '/userid=/s/userid="*[0-9][0-9]*"*/userid="USERID"/' \
	-e '/version=/s/version="*[^"]*"*/version="VERSION"/' \
	-e '/agent=/s/agent="*[^"]*"*/agent="AGENT"/' \
	-e 's/\(.*}\).*/\1 NCPU/' \
	-e '/PCP5 hinv_ncpu/{
s/ 60.0.32 / PMID /
s/ 85.0.0 / PMID /
}' \
    | LC_COLLATE=POSIX sort
}

_filter_pcp2opentelemetry()
{
   tee -a $here/$seq.full \
   | col -b \
   | sed \
       -e '/\"asInt\":/ s/[0-9][0-9]*/INTEGER/' \
       -e '/\"asDouble\":/ s/[0-9][0-9]*/DOUBLE/' \
       -e 's/\"version\": .*/\"version\": VERSION/' \
       -e 's/\"stringValue\": \".*\"/\"stringValue\": \"STRING\"/' \
       -e 's/\"timeUnixNano\": [0-9][0-9]*\.[0-9][0-9]*.*/\"timeUnixNano\": TIME/' \
   # end
}

# real QA test starts here
_save_config $PCP_SYSCONF_DIR/labels
$sudo rm -rf $PCP_SYSCONF_DIR/labels/*

echo "---"
pcp2json -a $A -H -I -z "" | _archive_filter
echo "---"
pcp2json -a $A -H -I -z -E "" | _archive_filter | _value_filter
echo "---"
pcp2json -a $A -H -I -Z UTC+0 -x "" | _archive_filter
echo "---"
pcp2json -a $A -H -I -z -X -b GB -P 2 -F $tmp.outfile ""
echo "---"
pcp2openmetrics -s1 -z hinv.ncpu | _filter_pcp2openmetrics
echo "---"
pcp2openmetrics -s2 -x hinv.ncpu | _filter_pcp2openmetrics
echo "---"
pcp2openmetrics -s2 -a $A1 hinv.ncpu disk.partitions.write | _archive_filter
echo "---"
pcp2opentelemetry -s1 -H -z hinv.ncpu | _filter_pcp2opentelemetry
echo "---"

cat $tmp.outfile | _archive_filter
which json_verify > /dev/null 2>&1
if [ $? -eq 0 ]; then
    json_verify < $tmp.outfile > /dev/null 2>&1
    [ $? -ne 0 ] && echo "JSON is not valid!"
fi
rm -f $tmp.outfile
echo "---"

# success, all done
status=0
exit