source: common/create-sbu_du-report.sh@ 0ac490b

1.0 2.3 2.3.x 2.4 ablfs ablfs-more legacy new_features trunk
Last change on this file since 0ac490b was 9ea3d54, checked in by Manuel Canales Esparcia <manuel@…>, 19 years ago

Added a script to calculate SBUs and disk usage.

  • Property mode set to 100755
File size: 4.2 KB
RevLine 
[9ea3d54]1#!/bin/bash
2#$Id$
3
4set -e
5
6LOGSDIR=$1
7VERSION=$2
8TESTLEVEL=$3
9
10# Make sure that we have a directory as first argument
11[[ ! -d "$LOGSDIR" ]] && \
12 echo -e "\nUSAGE: create-sbu_du-report.sh logs_directory [book_version testsuites_level]\n" && exit
13
14# Make sure that the first argument is a jhalfs logs directory
15[[ ! -f "$LOGSDIR"/000-masterscript.log ]] && \
16 echo -e "\nLooks like $LOGSDIR isn't a jhalfs logs directory.\n" && exit
17
18# If this script is run manually, the book version and testsuite levels
19# may be unknow
20[[ -z "$VERSION" ]] && VERSION=unknown
21[[ -z "$TESTLEVEL" ]] && TESTLEVEL=unknown
22
23# If there is iteration logs directories, copy the logs inside iteration-1
24# to the top level dir
25[[ -d "$LOGSDIR"/iteration-1 ]] && \
26 cp $LOGSDIR/iteration-1/* $LOGSDIR
27
28# Set the report file
29REPORT="$VERSION"-SBU_DU-$(date --iso-8601).report
30
31# Dump generation time stamp, book version, and testsuites level
32echo -e "\n`date`\n" > "$REPORT"
33echo -e "Book version is:\t$VERSION\n" >> "$REPORT"
34echo -e "Test suites level:\t$TESTLEVEL\n" >> "$REPORT"
35
36# Dump CPU and memory info
37echo -e "\n\t\tCPU type:\n" >> "$REPORT"
38cat /proc/cpuinfo >> "$REPORT"
39echo -e "\n\t\tMemory info:\n" >> "$REPORT"
40free >> "$REPORT"
41
42# Parse only that logs that have time data
43BUILDLOGS=`grep -l "^real\>" $LOGSDIR/*`
44
45# Match the first timed log to extract the SBU unit value from it
46BASELOG=`grep -l "^real\>" $LOGSDIR/* | head -n1`
47echo -e "\n\nUsing $BASELOG to obtain the SBU unit value." >> "$REPORT"
48BASEMINUTES=`grep "^real\>" $BASELOG | cut -f2 | sed -e 's/m.*//'`
49BASESECONDS=`grep "^real\>" $BASELOG | cut -f2 | sed -e 's/.*m//;s/s//'`
50SBU_UNIT=`echo "scale=3; $BASEMINUTES * 60 + $BASESECONDS" | bc`
51echo -e "The SBU unit value is equal to $SBU_UNIT seconds.\n" >> "$REPORT"
52
53# Set the first value to 0 for grand totals calculation
54SBU2=0
55INSTALL2=0
56INSTALLMB2=0
57
58for log in $BUILDLOGS ; do
59
60#Start SBU calculation
61 # Build time
62 BUILDTIME=`grep "^real\>" $log | cut -f2`
63 # Build time in seconds
64 MINUTES=`grep "^real\>" $log | cut -f2 | sed -e 's/m.*//'`
65 SECS=`grep "^real\>" $log | cut -f2 | sed -e 's/.*m//;s/s//'`
66 TIME=`echo "scale=3; $MINUTES * 60 + $SECS" | bc`
67 # Calculate build time in SBU
68 SBU=`echo "scale=3; $TIME / $SBU_UNIT" | bc`
69 # Append SBU value to SBU2 for grand total
70 SBU2="$SBU2 + $SBU"
71
72#Start disk usage calculation
73 # Disk usage before unpack the package
74 DU1=`grep "^KB: " $log | head -n1 | cut -f1 | sed -e 's/KB: //'`
75 DU1MB=`echo "scale=2; $DU1 / 1024" | bc`
76 # Disk usage before delete sources and build dirs
77 DU2=`grep "^KB: " $log | tail -n1 | cut -f1 | sed -e 's/KB: //'`
78 DU2MB=`echo "scale=2; $DU2 / 1024" | bc`
79 # Calculate disk space required to do the build
80 REQUIRED1=`echo "$DU2 - $DU1" | bc`
81 REQUIRED2=`echo "scale=2; $DU2MB - $DU1MB" | bc`
82
83 # Append installed files disk usage to the previous entry,
84 # except for the first parsed log
85 if [ "$log" != "$BASELOG" ] ; then
86 INSTALL=`echo "$DU1 - $DU1PREV" | bc`
87 INSTALLMB=`echo "scale=2; $DU1MB - $DU1MBPREV" | bc`
88 echo -e "Installed files disk usage:\t\t\t\t$INSTALL KB or $INSTALLMB MB\n" >> "$REPORT"
89 # Append install values for grand total
90 INSTALL2="$INSTALL2 + $INSTALL"
91 INSTALLMB2="$INSTALLMB2 + $INSTALLMB"
92 fi
93
94 # Set variables to calculate installed files disk usage
95 DU1PREV=$DU1
96 DU1MBPREV=$DU1MB
97
98 # Append log name
99 echo -e "\n\t$log" >> "$REPORT"
100
101 # Dump time values
102 echo -e "Build time is:\t\t\t$BUILDTIME" >> "$REPORT"
103 echo -e "Build time in seconds is\t$TIME" >> "$REPORT"
104 echo -e "Approximate SBU time is:\t$SBU" >> "$REPORT"
105
106 # Dump disk usage values
107 echo -e "\nDisk usage before unpack the package:\t\t\t$DU1 KB or $DU1MB MB" >> "$REPORT"
108 echo -e "Disk usage before delete sources and build dirs:\t$DU2 KB or $DU2MB MB" >> "$REPORT"
109 echo -e "Required space to build the package:\t\t\t$REQUIRED1 KB or $REQUIRED2 MB\n" >> "$REPORT"
110
111done
112
113# Dump grand totals
114TOTALSBU=`echo "scale=3; ${SBU2}" | bc`
115echo -e "\nTotal time required to build the systen:\t$TOTALSBU SBU\n" >> "$REPORT"
116TOTALINSTALL=`echo "${INSTALL2}" | bc`
117TOTALINSTALLMB=`echo "scale=2; ${INSTALLMB2}" | bc`
118echo -e "Total Installed files disk usage
119 (including /tools but not /sources):\t$TOTALINSTALL KB or $TOTALINSTALLMB MB\n" >> "$REPORT"
120
121
Note: See TracBrowser for help on using the repository browser.