/usr/bin/pmie2col is in pcp 3.9.10.
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 | #!/bin/sh
#
# A crude ascii reporting tool, convert pmie to column output
#
# The pmie rules need to be of the form:
# load_1 = kernel.all.load #'1 minute';
# idle = kernel.all.cpu.idle;
# column_name=some other expression;
# ...
#
# Each pmie expression has to produce a singular value.
#
# With timestamps (pmie -e or pmie output from a PCP archive), lines look like
# metric (Tue Feb 13 05:01:19 2001): value
# load_1 (Tue Dec 23 12:20:45 2003): 0.24
# the first sed step in the filter sorts this out.
#
# First e-mailed to Patrick Aland <paland@stetson.edu> and pcp@oss.sgi.com
# on Wed, 24 Jan 2001.
#
# Get standard environment
. $PCP_DIR/etc/pcp.env
tmp=`mktemp -d /tmp/pcp.XXXXXXXXX` || exit 1
status=1
trap "rm -rf $tmp; exit \$status" 0 1 2 3 15
prog=`basename $0`
# For interactive use, works better with line buffered output from sed(1)
# and awk(1).
#
case "$PCP_PLATFORM"
in
linux|mingw|kfreebsd|gnu)
SED="sed -u"
;;
freebsd|darwin)
SED="sed -l"
;;
*)
SED=sed
;;
esac
echo > $tmp/usage
cat >> $tmp/usage <<EOF
Options:
-d=CHAR,--delimiter=CHAR set the output delimiter character
-p=N,--precision=N set the output floating point precision
-w=N,--width=N set the width of each column of output
--help
EOF
_usage()
{
pmgetopt --progname=$prog --config=$tmp/usage --usage
exit 1
}
pre=2 # floating point precision
wid=7 # reporting column width
delim=' '
ARGS=`pmgetopt --progname=$prog --config=$tmp/usage -- "$@"`
[ $? != 0 ] && exit 1
eval set -- "$ARGS"
while [ $# -gt 0 ]
do
case "$1"
in
-w) wid="$2"
shift
;;
-p) pre="$2"
shift
;;
-d) delim="$2"
shift
;;
--) shift
break
;;
-\?) _usage
;;
esac
shift
done
[ $# -eq 0 ] || _usage
# culled output at the start is produced by pmie and/or pmafm
$SED \
-e '/^pmie: timezone set to/d' \
-e '/^Note: running pmie serially, once per archive$/d' \
-e '/^Host: [A-Za-z0-9]* Archive: /d' \
-e '/^[^ ][^ ]* ([A-Z][a-z][a-z] [A-Z][a-z][a-z] *[0-9][0-9]* [0-2][0-9]:[0-5][0-9]:[0-5][0-9] [0-9][0-9][0-9][0-9]): /{
s/ (/|/
s/): /|/
}' \
-e '/^\([^ ][^ ]*\):/s//\1||/' \
| awk -F\| -v delim="$delim" '
NF == 0 { if (state == 0) {
ncol = i
print ""
}
if (stamp != "") printf "%24s ",stamp
for (i = 0; i < ncol; i++) {
if (v[i] == "?")
# no value
printf "%s%'$wid'.'$wid's",delim,"?"
else if (v[i]+0 == v[i])
# number
printf "%s%'$wid'.'$pre'f",delim,v[i]
else
# string
printf "%s%'$wid'.'$wid's",delim,v[i]
v[i] = "?"
}
print ""
i = 0
stamp = ""
state = 1
next
}
NF == 3 && stamp == "" { stamp = $2 }
state == 0 { if (i == 0 && stamp != "") printf "%24s ",""
printf "%s%'$wid'.'$wid's",delim,$1 }
{ v[i++] = $NF }'
status=0
exit
|