Current File : //bin/proc_tracedata
#!/usr/bin/bash
#
# Copyright 2008 Sun Microsystems, Inc.  All rights reserved.
# Use is subject to license terms.
#
# Script to process trace output data into a sorted list suitable for use
# in constructing an optimized ISO with mkisofs -sort.  See mkisofs(8) for more
# information.
#

if [ $# != 2 ]
then
	echo "proc_tracedata <iosnoop output> <output file>"
	exit 1
fi

cat $1 | egrep -v "xkblayout|unknown|librt|libm|iosnp|etc|PATHNAME|zlib|sched|dtrace|repository|var|libc|bsnp|sout|devices" | nawk ' BEGIN { path = ""; amt = 0 } {
	if ($8 ~ /<none>/) {
		cpath = $9
	} else {
		cpath = $8
	}
	if (match(cpath, "^/usr") > 0) {
		cmd=sprintf("/usr/bin/test -d %s", cpath, cpath)
		rv=system(cmd)
		if (rv > 0) {
			if (match(cpath, /\\0$/) > 0) {
				cpath = sub(/\\0$/, "", cpath);
			}
			if (length(path) > 0) {
				re = "^" path "$"
				if (match(cpath, re) > 0) {
					amt += $7
				} else {
					print amt, path
					amt = $7
					path = cpath
				}
			} else {
				path = cpath
				amt = $7
			}
		}
	}
}

END {
	if (length(path) > 0) {
		print amt, path
	}
} ' | sed 's/ \// /' > /tmp/slist.$$

/usr/bin/proc_slist /tmp/slist.$$ > $2