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
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
|
#!/bin/sh
#
# Copyright (c) 1995,2003 Silicon Graphics, Inc. All Rights Reserved.
#
# This program is free software; you can redistribute it and/or modify it
# under the terms of the GNU General Public License as published by the
# Free Software Foundation; either version 2 of the License, or (at your
# option) any later version.
#
# This program is distributed in the hope that it will be useful, but
# WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
# or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
# for more details.
#
# source the PCP configuration environment variables
. $PCP_DIR/etc/pcp.env
if [ -d "$PCP_TMPFILE_DIR" ]
then
tmp=`mktemp -d "$PCP_TMPFILE_DIR/pcp.XXXXXXXXX"` || exit 1
else
# if configure --prefix is used in a the build, then $PCP_TMPFILE_DIR
# may not yet exist ... /tmp is a safe bet
#
tmp=`mktemp -d /tmp/pcp.XXXXXXXXX` || exit 1
fi
status=1
trap "rm -rf $tmp; exit \$status" 0 1 2 3 15
prog=`basename $0`
OLD=stdpmid
NEW=$tmp/new
SOURCE=""
for file in `echo stdpmid.*`
do
case $file
in
stdpmid.'*'|stdpmid.O|stdpmid.O.*|stdpmid.N|stdpmid.N.*|stdpmid.rpmorig|stdpmid.*.rpmorig)
;;
*)
SOURCE="$SOURCE $file"
;;
esac
done
[ -z "$SOURCE" ] && exit # nothing to do - the norm nowadays
# post-processing with sed ...
# - removes comments
# - maps white space to a single space
# - performs domain re-numbering that occured for LAB and ASH
# between PCP 2.0 and PCP 2.1 to avoid duplicates in the interim
#
# Note on sort. Used to be "sort -n +1 -2", but changed to "sort -n -k2,3"
# to avoid problems with more recent Linux coreutils versions.
#
for file in $SOURCE
do
sed <$file \
-e '/^#/d' \
-e 's/[ ][ ]*/ /' \
-e '/^LAB /s/254/246/' \
-e '/^ASH /s/7/11/'
done \
| sort -n -k2,3 \
| uniq >$tmp/tmp
if [ -s "$tmp/tmp" ]
then
error=false
else
echo "$prog: Error: failed to create temporary file"
exit
fi
# scan for duplicate domain name, but different domain number
#
$PCP_AWK_PROG '{ print $1 }' <$tmp/tmp \
| sort \
| uniq -c \
| while read cnt domain
do
[ $cnt -eq 1 ] && continue
echo "$prog: Error: duplicate for domain name \"$domain\" ..."
grep "^$domain[ ]" $SOURCE | sed -e 's/^/ /'
error=true
done
# scan for duplicate domain number, but different domain name
#
$PCP_AWK_PROG '{ print $2 }' <$tmp/tmp \
| sort \
| uniq -c \
| while read cnt number
do
[ $cnt -eq 1 ] && continue
echo "$prog: Error: duplicate for domain number \"$number\" ..."
grep "[ ]$number\$" $SOURCE | sed -e 's/^/ /'
error=true
done
$error && exit
# preamble
#
cat <<'End-of-File' >$NEW
/*
* NOTE:
* Do not edit this file (it is re-created by Make.stdpmid).
* To make changes, edit one of the stdpmid.* files, most probably
* stdpmid.local, and as root
* # make stdpmid
*
* The following domain number assignments are assumed to apply
*
* Domain Number Range Use
* 0 reserved -- DO NOT USE
* 1-31 production PMDAs from PCP packages (#1)
* 32-39 ORACLE DBMS PMDAs
* 40-47 Sybase DBMS PMDAs
* 48-55 Informix DBMS PMDAs
* 56-58 SNMP Gateway PMDA
* 59-63 Linux PMDAs
* 64-69 ISV PMDAs
* 70-128 production PMDAs from PCP packages (#2)
* 129-510 End-User PMDAs and demo PMDAs
* 511 reserved for dynamic PMNS entries -- DO NOT USE
*
* A Performance Metrics Identifier (PMID) is internally encoded as
* 1 bits - flag reserved for internal use
* 9 bits - the Performance Metric Domain Agent (PMDA) domain number
* from the list below
* 12 bits - cluster within domain
* 10 bits - serial within cluster
*/
#ifndef __STDPMID
#define __STDPMID
End-of-File
cat $tmp/tmp \
| while read domain number
do
echo "#define $domain $number" >>$NEW
done
echo '
#endif' >>$NEW
# only update if it has changed
#
if [ -f $OLD ]
then
if cmp -s $OLD $NEW >/dev/null 2>&1
then
rm -f $NEW
fi
fi
if [ -f $NEW ]
then
cp $NEW $OLD
chmod 444 $NEW
fi
status=0
exit
|