source: common/create-sbu_du-report.sh@ 9c43643

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

Typo fixes.

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