📄 featurestats.sh
字号:
#!/bin/ksh## SAMPLE NAME: featureStats## FUNCTIONS: This sample shell script displays total active feature# statistics on a feature owner area basis.## USAGE: featureStats ownerArea## ENVIRONMENT# VARIABLE(S): CMVC_FAMILY [CMVC_BECOME]## ORIGINS: 27## 5765-039 (C) COPYRIGHT International Business Machines Corp. 1991,1993# 5765-207 (C) COPYRIGHT International Business Machines Corp. 1993# 5765-202 (C) COPYRIGHT International Business Machines Corp. 1993# 5622-063 (C) COPYRIGHT International Business Machines Corp. 1993# 5765-069 (C) COPYRIGHT International Business Machines Corp. 1991,1993# All Rights Reserved# Licensed Materials - Property of IBM## US Government Users Restricted Rights - Use, duplication or# disclosure restricted by GSA ADP Schedule Contract with IBM Corp.### NOTICE TO USERS OF THE SOURCE CODE EXAMPLES## INTERNATIONAL BUSINESS MACHINES CORPORATION PROVIDES THE SOURCE CODE# EXAMPLES, BOTH INDIVIDUALLY AND AS ONE OR MORE GROUPS, "AS IS" WITHOUT# WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT# LIMITED TO THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A# PARTICULAR PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE# OF THE SOURCE CODE EXAMPLES, BOTH INDIVIDUALLY AND AS ONE OR MORE GROUPS,# IS WITH YOU. SHOULD ANY PART OF THE SOURCE CODE EXAMPLES PROVE# DEFECTIVE, YOU (AND NOT IBM OR AN AUTHORIZED RISC System/6000* WORKSTATION# DEALER) ASSUME THE ENTIRE COST OF ALL NECESSARY SERVICING, REPAIR OR# CORRECTION.## * RISC System/6000 is a trademark of International Business Machines# Corporation.## /usr/lpp/cmvc/samples/featureStats## *************************************************************************# Note: This file produces 132 column output and is easier to view and# edit if displayed in 132 columns.# *************************************************************************#if [ $# -eq 0 ]then echo "\nusage: $0 ownerArea\n" echo "This sample shell script displays total active feature" echo "statistics on a feature owner area basis.\n" exit 1fiif [ -z "$CMVC_FAMILY" ]then echo "The CMVC family must be set with the CMVC_FAMILY environment variable." exit 1fi# Clean up on interrupttrap 'echo "\n$0: Interrupted."; cleanup; exit 1' 2 3 15cleanup(){ rm -f /tmp/dstat$$ 2>/dev/null}Report -vi FeatureView -w "state not in ('closed','canceled') and ownerArea= '$1'" \-raw | awk -F'|' '{print $3,$6,$8}' | sort >/tmp/dstat$$cat /tmp/dstat$$ | \awk '{ # When field one changes, output the "sum" line, unless this is the # first record, since it is always different. if ($1 != saveComp) { if (NR == 1) { printf "\n\n FEATURE STATISTICS FOR DEPARTMENT '$1'\n" printf "\n%32.32s %6.6s %7.7s %6.6s %8.8s %6.6s\n", "Component", "Open", "Working", "Verify", "Returned", "Total" printf "%32.32s %6.6s %7.7s %6.6s %8.8s %6.6s\n", "---------------------------------", "----", "-------", "------", "--------", "------" allOpen = 0 allWork = 0 allVerify = 0 allReturn = 0 } else { allTotal += total printf "%32.32s %6.6s %7.7s %6.6s %8.8s %6.6s\n", saveComp, open, work, verify, returned, total } # Reset the save value and the "sum". saveComp = $1 open = 0 work = 0 verify = 0 returned = 0 total = 0 } # Accumulate the sum for every record. total += 1 if ($2 == "open") { open += 1 allOpen += 1 } else if ($2 == "working") { work += 1 allWork += 1 } else if ($2 == "verify") { verify += 1 allVerify += 1 } else if ($2 == "returned") { returned += 1 allReturn += 1 } }END { # Output the last "sum" line after the last record was read. printf "%32.32s %6.6s %7.7s %6.6s %8.8s %6.6s\n", saveComp, open, work, verify, returned, total # Output the "all" totals allTotal += total if (allTotal != 0) { printf "%32.32s %6.6s %7.7s %6.6s %8.8s %6.6s\n", "---------------------------------", "----", "-------", "------", "--------", "------" printf "%32.32s %6.6s %7.7s %6.6s %8.8s %6.6s\n", "TOTAL", allOpen, allWork, allVerify, allReturn, allTotal } }'[ -r /tmp/dstat$$ ] && rm -f /tmp/dstat$$
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -