Listing 6: Generate radar plot file
#!/bin/sh
#
# Listing 6 - Generates Radar plot file
#
if [ $# != 3 ]; then
MONTH=`date +%h`
DAY=`date +%d`
INFILE="extracted"
echo 'Running with default values....'
else
MONTH=$1
DAY=$2
INFILE=$3
fi
nawk -f radar.awk month=$MONTH day=$DAY $INFILE
#
# radar.awk
# Script generates ascii file suitable for importing
# into excel for radar plots.
#
BEGIN {
Seconds_Per_Minute=60
Minutes_Per_Hour=60
Hours_Per_Day=24
Seconds_Per_Hour=Minutes_Per_Hour*Seconds_Per_Minute
Seconds_Per_Day = Hours_Per_Day * Seconds_Per_Hour
i=0
Delta=600
Wstart=0
Wend=Wstart + Delta
while (getline < ARGV[3] > 0) {
Username[i] = $1
Portname[i] = $2
Start_Month[i] = $3
Start_Day[i] = $4
Start_Time[i] = $5
End_Time[i] = $6
i++
}
}
END {
printf("Blank,")
for ( k = 0; k < 144; k++ )
{
Bucket_Min = (k*10)
if ( Bucket_Min > 60 ) {
Bucket_Hr = Bucket_Min / 60
Bucket_Min = ( Bucket_Min % 60 )
}
if ( k % 4 == 0 )
printf("%02d:%02d,",Bucket_Hr,Bucket_Min)
else
printf(",");
}
printf("\n")
for ( day = 1; day < 32; day++ )
{
for (k = 0; k < 144; k++ )
hit[k]=0
k = 0
for ( j =0; j < i; j++ )
{
if (month == Start_Month[j] && day == Start_Day[j] ) {
Wstart = 0
Wend = Wstart + Delta
for ( k = 0; k < 144; k++ )
{
if ( Start_Time[j] < Wend ) {
if ( ( Start_Time[j] <= Wend ) \
&& ( Start_Time[j] > Wstart ) )
{
hit[k]++
}
else if ( End_Time[j] > Wend )
{
hit[k]++
Start_Time[j] = Wend - Start_Time[j]
}
}
Wend += Delta
Wstart += Delta
}
}
}
Bucket_Hr = 0
printf("%s %2d,",month,day)
for ( k = 0; k < 144; k++ )
{
Bucket_Min = (k*10)
if ( Bucket_Min > 60 ) {
Bucket_Hr = Bucket_Min / 60
Bucket_Min = ( Bucket_Min % 60 )
}
printf("%d,",hit[k])
}
printf("E\n")
}
} m
# End of File
|