#!/bin/bash
start='2012-07-25 15:45'
end='2012-07-25 22:45'
reportName="responseTimeReport"
reportNameByMin="responseTimeReportByMin"
hour_S=`echo ${start:11:2} | sed s/^0//`
hour_E=`echo ${end:11:2} | sed s/^0//`
awk -v start="$start" -v end="$end" -v reportNameByMin="$reportNameByMin" -F, '
$2>=start && $2<=end
{
arr_num[$3"@"substr($2,1,16)"@"$4"@"$5]++;
arr_rsp[$3"@"substr($2,1,16)"@"$4"@"$5]+=$6;
}
END{
for(key in arr_num){arr_sort[i++]=key};
len=asort(arr_sort);
for(i=1;i<=len;i++){key=arr_sort[i]; split(key, arr_key, "@");
if(arr_key[4]=="TRADING_ELIGIBILITY_CHECKING"){arr_key[4]="TRADING_ELI_CHEC"}else{};
printf("%s,%s,%s,%s,%d,%.2f\n", arr_key[1],arr_key[2],arr_key[3],arr_key[4],arr_num[key],arr_rsp[key]/arr_num[key]) > reportNameByMin};
}' debug.log
echo -e "##Overall Result##" > $reportName
awk -v reportName="$reportName" -F, '{arr_num[$3"@"$4]+=$5; arr_rsp[$3"@"$4]+=($5*$6);total+=$5}END{printf("Total volume: "total"\n\n") >> reportName; printf("%s\t%-20s\t%s\t%s\n", "CHANNEL","FUN","VOLUME","AVG(ms)") >> reportName; printf("%s\t%-20s\t%s\t%s\n", "-------","--------------------","------","-------") >> reportName; for(key in arr_num){arr_sort[i++]=key}; len=asort(arr_sort); for(i=1;i<=len;i++){key=arr_sort[i]; split(key, arr_key, "@"); printf("%-5s\t%-20s\t%6d\t%6.2f\t\n", arr_key[1],arr_key[2],arr_num[key],arr_rsp[key]/arr_num[key]) >> reportName};}' $reportNameByMin
echo -e "\n##Result by machine##" >> $reportName
awk -v reportName="$reportName" -F, '{arr_num[$1"@"$3"@"$4]+=$5; arr_rsp[$1"@"$3"@"$4]+=($5*$6);}END{printf("%-20s\t%s\t%-20s\t%s\t%s\n", "HOST","CHANNEL","FUN","VOLUME","AVG(ms)") >> reportName; printf("%-20s\t%s\t%-20s\t%s\t%s\n", "--------------------","-------","--------------------","------","-------") >> reportName; for(key in arr_num){arr_sort[i++]=key}; len=asort(arr_sort); for(i=1;i<=len;i++){key=arr_sort[i]; split(key, arr_key, "@"); printf("%-20s\t%-5s\t%-20s\t%6d\t%6.2f\t\n", arr_key[1],arr_key[2],arr_key[3],arr_num[key],arr_rsp[key]/arr_num[key]) >> reportName};}' $reportNameByMin
if [ $((hour_E - hour_S)) == 1 ];
then
echo -e "\n##Result by 15 minutes##" >> $reportName
awk -v start="${start//[-:]/ } 00" -v end="${end//[-:]/ } 00" -v reportName="$reportName" -F, 'BEGIN{Time1=strftime("%Y-%m-%d %H:%M",mktime(start)+15*60);Time2=strftime("%Y-%m-%d %H:%M",mktime(start)+30*60);Time3=strftime("%Y-%m-%d %H:%M",mktime(start)+45*60);Time4=strftime("%Y-%m-%d %H:%M",mktime(start)+60*60);}{if($2<Time1){arr_num1[$3"@"$4]+=$5;arr_rsp1[$3"@"$4]+=($5*$6)}else if($2<Time2){arr_num2[$3"@"$4]+=$5;arr_rsp2[$3"@"$4]+=($5*$6)}else if($2<Time3){arr_num3[$3"@"$4]+=$5;arr_rsp3[$3"@"$4]+=($5*$6)}else if($2<Time4){arr_num4[$3"@"$4]+=$5;arr_rsp4[$3"@"$4]+=($5*$6)}else{};}END{printf("%s\t%-20s\t%s\t%s\t%s\t%s\t%s\t%s\t%s\t%s\n", "CHANNEL","FUN","VOL15","AVG15","VOL30","AVG30","VOL45","AVG45","VOL60","AVG60") >> reportName; printf("%s\t%-20s\t%s\t%s\t%s\t%s\t%s\t%s\t%s\t%s\n","-------","--------------------","------","-------","------","-------","------","-------","------","-------") >> reportName; for(key in arr_num1){arr_sort[i++]=key}; len=asort(arr_sort); for(i=1;i<=len;i++){key=arr_sort[i]; split(key, arr_key, "@"); printf("%-5s\t%-20s\t%6d\t%6.2f\t%6d\t%6.2f\t%6d\t%6.2f\t%6d\t%6.2f\n", arr_key[1],arr_key[2],arr_num1[key],arr_rsp1[key]/(arr_num1[key]+1),arr_num2[key],arr_rsp2[key]/(arr_num2[key]+1),arr_num3[key],arr_rsp3[key]/(arr_num3[key]+1),arr_num4[key],arr_rsp4[key]/(arr_num4[key]+1)) >> reportName};}' $reportNameByMin
echo -e "\n##Result by machine/15 minutes##" >> $reportName
awk -v start="${start//[-:]/ } 00" -v end="${end//[-:]/ } 00" -v reportName="$reportName" -F, 'BEGIN{Time1=strftime("%Y-%m-%d %H:%M",mktime(start)+15*60);Time2=strftime("%Y-%m-%d %H:%M",mktime(start)+30*60);Time3=strftime("%Y-%m-%d %H:%M",mktime(start)+45*60);Time4=strftime("%Y-%m-%d %H:%M",mktime(start)+60*60);}{if($2<Time1){arr_num1[$1"@"$3"@"$4]+=$5;arr_rsp1[$1"@"$3"@"$4]+=($5*$6)}else if($2<Time2){arr_num2[$1"@"$3"@"$4]+=$5;arr_rsp2[$1"@"$3"@"$4]+=($5*$6)}else if($2<Time3){arr_num3[$1"@"$3"@"$4]+=$5;arr_rsp3[$1"@"$3"@"$4]+=($5*$6)}else if($2<Time4){arr_num4[$1"@"$3"@"$4]+=$5;arr_rsp4[$1"@"$3"@"$4]+=($5*$6)}else{};}END{printf("%-20s\t%s\t%-20s\t%s\t%s\t%s\t%s\t%s\t%s\t%s\t%s\n", "HOST","CHANNEL","FUN","VOL15","AVG15","VOL30","AVG30","VOL45","AVG45","VOL60","AVG60") >> reportName; printf("%-20s\t%s\t%-20s\t%s\t%s\t%s\t%s\t%s\t%s\t%s\t%s\n", "--------------------","-------","--------------------","------","-------","------","-------","------","-------","------","-------") >> reportName; for(key in arr_num1){arr_sort[i++]=key}; len=asort(arr_sort); for(i=1;i<=len;i++){key=arr_sort[i]; split(key, arr_key, "@"); printf("%-20s\t%-5s\t%-20s\t%6d\t%6.2f\t%6d\t%6.2f\t%6d\t%6.2f\t%6d\t%6.2f\n", arr_key[1],arr_key[2],arr_key[3],arr_num1[key],arr_rsp1[key]/(arr_num1[key]+1),arr_num2[key],arr_rsp2[key]/(arr_num2[key]+1),arr_num3[key],arr_rsp3[key]/(arr_num3[key]+1),arr_num4[key],arr_rsp4[key]/(arr_num4[key]+1)) >> reportName};}' $reportNameByMin
echo -e "\n##Volume by machine##" >> $reportName
awk -v start="${start//[-:]/ } 00" -v end="${end//[-:]/ } 00" -v reportName="$reportName" -F, 'BEGIN{Time1=strftime("%Y-%m-%d %H:%M",mktime(start)+15*60);Time2=strftime("%Y-%m-%d %H:%M",mktime(start)+30*60);Time3=strftime("%Y-%m-%d %H:%M",mktime(start)+45*60);Time4=strftime("%Y-%m-%d %H:%M",mktime(start)+60*60);}{if($2<Time1){arr_num1[$1]+=$5;arr_rsp1[$1]+=($5*$6)}else if($2<Time2){arr_num2[$1]+=$5;arr_rsp2[$1]+=($5*$6)}else if($2<Time3){arr_num3[$1]+=$5;arr_rsp3[$1]+=($5*$6)}else if($2<Time4){arr_num4[$1]+=$5;arr_rsp4[$1]+=($5*$6)}else{};arr_numTotal[$1]+=$5}END{printf("%-20s\t%s\t%s\t%s\t%s\t%s\n", "HOST","VOL15","VOL30","VOL45","VOL60","TOTAL") >> reportName; printf("%-20s\t%s\t%s\t%s\t%s\t%s\n", "--------------------","-------","------","-------","------","-------") >> reportName; for(key in arr_num1){arr_sort[i++]=key}; len=asort(arr_sort); for(i=1;i<=len;i++){key=arr_sort[i];printf("%-20s\t%6d\t%6d\t%6d\t%6d\t%6d\n",key,arr_num1[key],arr_num2[key],arr_num3[key],arr_num4[key],arr_numTotal[key]) >> reportName};}' $reportNameByMin
echo -e "\n##Volume by minute##" >> $reportName
awk -v reportName="$reportName" -F, '{arr_num[substr($2,1,16)]+=$5;}END{printf("%-20s\t%s\n", "MINUTE","VOLUME") >> reportName; printf("%-20s\t%s\n", "--------------------","------") >> reportName; for(key in arr_num){printf("%-20s\t%6d\n",key,arr_num[key]) >> reportName};}' $reportNameByMin
elif [ $((hour_E - hour_S)) == 8 ];
then
echo -e "\n##Result by 2 hours##" >> $reportName
awk -v start="${start//[-:]/ } 00" -v end="${end//[-:]/ } 00" -v reportName="$reportName" -F, 'BEGIN{Time1=strftime("%Y-%m-%d %H:%M",mktime(start)+2*60*60);Time2=strftime("%Y-%m-%d %H:%M",mktime(start)+4*60*60);Time3=strftime("%Y-%m-%d %H:%M",mktime(start)+6*60*60);Time4=strftime("%Y-%m-%d %H:%M",mktime(start)+8*60*60);}{if($2<Time1){arr_num1[$3"@"$4]+=$5;arr_rsp1[$3"@"$4]+=($5*$6)}else if($2<Time2){arr_num2[$3"@"$4]+=$5;arr_rsp2[$3"@"$4]+=($5*$6)}else if($2<Time3){arr_num3[$3"@"$4]+=$5;arr_rsp3[$3"@"$4]+=($5*$6)}else if($2<Time4){arr_num4[$3"@"$4]+=$5;arr_rsp4[$3"@"$4]+=($5*$6)}else{};}END{printf("%s\t%-20s\t%s\t%s\t%s\t%s\t%s\t%s\t%s\t%s\n", "CHANNEL","FUN","VOL2","AVG2","VOL4","AVG4","VOL6","AVG6","VOL8","AVG8") >> reportName; printf("%s\t%-20s\t%s\t%s\t%s\t%s\t%s\t%s\t%s\t%s\n","-------","--------------------","------","-------","------","-------","------","-------","------","-------") >> reportName; for(key in arr_num1){arr_sort[i++]=key}; len=asort(arr_sort); for(i=1;i<=len;i++){key=arr_sort[i]; split(key, arr_key, "@"); printf("%-5s\t%-20s\t%6d\t%6.2f\t%6d\t%6.2f\t%6d\t%6.2f\t%6d\t%6.2f\n", arr_key[1],arr_key[2],arr_num1[key],arr_rsp1[key]/(arr_num1[key]+1),arr_num2[key],arr_rsp2[key]/(arr_num2[key]+1),arr_num3[key],arr_rsp3[key]/(arr_num3[key]+1),arr_num4[key],arr_rsp4[key]/(arr_num4[key]+1)) >> reportName};}' $reportNameByMin
echo -e "\n##Result by machine/2 hours##" >> $reportName
awk -v start="${start//[-:]/ } 00" -v end="${end//[-:]/ } 00" -v reportName="$reportName" -F, 'BEGIN{Time1=strftime("%Y-%m-%d %H:%M",mktime(start)+2*60*60);Time2=strftime("%Y-%m-%d %H:%M",mktime(start)+4*60*60);Time3=strftime("%Y-%m-%d %H:%M",mktime(start)+6*60*60);Time4=strftime("%Y-%m-%d %H:%M",mktime(start)+8*60*60);}{if($2<Time1){arr_num1[$1"@"$3"@"$4]+=$5;arr_rsp1[$1"@"$3"@"$4]+=($5*$6)}else if($2<Time2){arr_num2[$1"@"$3"@"$4]+=$5;arr_rsp2[$1"@"$3"@"$4]+=($5*$6)}else if($2<Time3){arr_num3[$1"@"$3"@"$4]+=$5;arr_rsp3[$1"@"$3"@"$4]+=($5*$6)}else if($2<Time4){arr_num4[$1"@"$3"@"$4]+=$5;arr_rsp4[$1"@"$3"@"$4]+=($5*$6)}else{};}END{printf("%-20s\t%s\t%-20s\t%s\t%s\t%s\t%s\t%s\t%s\t%s\t%s\n", "HOST","CHANNEL","FUN","VOL2","AVG2","VOL4","AVG4","VOL6","AVG6","VOL8","AVG8") >> reportName; printf("%-20s\t%s\t%-20s\t%s\t%s\t%s\t%s\t%s\t%s\t%s\t%s\n", "--------------------","-------","--------------------","------","-------","------","-------","------","-------","------","-------") >> reportName; for(key in arr_num1){arr_sort[i++]=key}; len=asort(arr_sort); for(i=1;i<=len;i++){key=arr_sort[i]; split(key, arr_key, "@"); printf("%-20s\t%-5s\t%-20s\t%6d\t%6.2f\t%6d\t%6.2f\t%6d\t%6.2f\t%6d\t%6.2f\n", arr_key[1],arr_key[2],arr_key[3],arr_num1[key],arr_rsp1[key]/(arr_num1[key]+1),arr_num2[key],arr_rsp2[key]/(arr_num2[key]+1),arr_num3[key],arr_rsp3[key]/(arr_num3[key]+1),arr_num4[key],arr_rsp4[key]/(arr_num4[key]+1)) >> reportName};}' $reportNameByMin
echo -e "\n##Volume by machine##" >> $reportName
awk -v start="${start//[-:]/ } 00" -v end="${end//[-:]/ } 00" -v reportName="$reportName" -F, 'BEGIN{Time1=strftime("%Y-%m-%d %H:%M",mktime(start)+2*60*60);Time2=strftime("%Y-%m-%d %H:%M",mktime(start)+4*60*60);Time3=strftime("%Y-%m-%d %H:%M",mktime(start)+6*60*60);Time4=strftime("%Y-%m-%d %H:%M",mktime(start)+8*60*60);}{if($2<Time1){arr_num1[$1]+=$5;arr_rsp1[$1]+=($5*$6)}else if($2<Time2){arr_num2[$1]+=$5;arr_rsp2[$1]+=($5*$6)}else if($2<Time3){arr_num3[$1]+=$5;arr_rsp3[$1]+=($5*$6)}else if($2<Time4){arr_num4[$1]+=$5;arr_rsp4[$1]+=($5*$6)}else{};arr_numTotal[$1]+=$5}END{printf("%-20s\t%s\t%s\t%s\t%s\t%s\n", "HOST","VOL2","VOL4","VOL6","VOL8","TOTAL") >> reportName; printf("%-20s\t%s\t%s\t%s\t%s\t%s\n", "--------------------","-------","------","-------","------","-------") >> reportName; for(key in arr_num1){arr_sort[i++]=key}; len=asort(arr_sort); for(i=1;i<=len;i++){key=arr_sort[i];printf("%-20s\t%6d\t%6d\t%6d\t%6d\t%6d\n",key,arr_num1[key],arr_num2[key],arr_num3[key],arr_num4[key],arr_numTotal[key]) >> reportName};}' $reportNameByMin
echo -e "\n##Volume by minute##" >> $reportName
awk -v reportName="$reportName" -F, '{arr_num[substr($2,1,16)]+=$5;}END{printf("%-20s\t%s\n", "MINUTE","VOLUME") >> reportName; printf("%-20s\t%s\n", "--------------------","------") >> reportName; for(key in arr_num){printf("%-20s\t%6d\n",key,arr_num[key]) >> reportName};}' $reportNameByMin
else
echo -e "\n\nWrong start/end time!" >> $reportName
fi
cat $reportName
rm -f $reportNameByMin
相关推荐
像 cut 或 awk,但不会因分隔符转义而窒息。 安装 pip install pluckr 。 完毕。 用法 从 stdin 中获取第 2 列和第 3 列( -f是单索引): pluckr -f 2,3 < sample1.csv 或直接从文件: pluckr -f 2,1 ...
瓦克 类似于awk的VCF解析器 ##目录 ##用法 usage: vawk [-h] [-v VAR] [--header] [--debug] cmd [vcf] positional arguments: ... the I$ prefix and the SAMPLE field can be split using the S$ prefix. For e
掌握`grep`、`find`、`sed`和`awk`等高级命令,可以提高在终端中的工作效率。 3. **用户与权限管理**:在Linux中,每个用户都有自己的UID和GID,以及相应的权限。`adduser`和`userdel`命令用于添加和删除用户,`...
在Linux环境中,可以使用各种工具来处理这种数据,比如awk、sed、grep等,或者编写bash脚本来实现更复杂的逻辑。例如,你可能会创建一个脚本来查找特定的错误代码、监控特定的系统指标,或者定期汇总信息。 为了...
sample AIX system manager ---use OS running perf data ananly. using AWK and some tools like vmstat .. get txt file to process.
源文件格式key,value ==》 经过处理后*3$3set$3key$5value 使用方式LANG=C ./sample.awk test.csv | redis-cli --pipe -h 127.0.0.1 -p 6379
5. `ctrl2poscar.awk-sample.sh`:这可能是ctrl2poscar.awk脚本的一个示例用法,展示如何在命令行中调用和执行转换。 6. `create-tar.sh`:创建tar归档文件的脚本,用于打包和分发这些转换工具。 7. `gpl-3.0.txt`:...
此外,除了编写自定义脚本,还有现成的工具可以辅助完成类似的任务,比如Unix/Linux命令行中的`sed`或`awk`,以及Windows的`findstr`配合`for /f`命令。这些工具提供了强大的文本处理能力,且无需编写代码。 总结来...
sed经常与其他文本处理工具(如awk、grep等)一起使用,以实现更为复杂的数据处理需求。例如,结合awk对文件进行排序后再进行替换: ```bash awk '{print $0 | "sort"}' file.txt | sed 's/tiger/wolf/' ``` #### ...
- **配置文件结构**: 配置文件采用类似于脚本语言的格式,尽管其复杂度远低于Perl或awk等高级编程语言。 - **初始配置**: 开始使用Fvwm时,可以从随Fvwm源码发行的`system.fvwm2rc`文件着手。该文件位于源码包的`...
# Download sample PacBio from the PBcR website wget -O- http://www.cbcb.umd.edu/software/PBcR/data/selfSampleData.tar.gz | tar zxf - awk ' NR%4==1||NR%4==2 ' selfSampleData/pacbio_filtered.fastq | sed...
在 Windows 下,请确保 Cygwin 1.7 或更高版本,awk 升级到最新版本,GNU Make 3.81 或更高版本。 第 1 步:安装 NDK 下载完成后,请解压缩 NDK,並将其放入合适的目录中。请记住您将其放在哪里。在 Windows 下的 ...
$filePath = "sample_data.txt" $fileContent = Get-Content $filePath # 定义排序键 $fileContent | ForEach-Object { $key1 = $_.Substring(0, 2) $key2 = $_.Substring(2, 2) $key3 = $_.Substring(4) # ...
在上面的例子中,`xmllint --xpath "//book[@id=2]/name/text()" sample.xml`会返回id为2的书籍的名称。此外,`--noblanks`可以去除XML文件中的空格和换行,`--format`则可以用于美化XML格式。 其次,XPath是一种...
A Sample .bashrc File L. Converting DOS Batch Files to Shell Scripts M. Exercises M.1. Analyzing Scripts M.2. Writing Scripts N. Revision History O. Mirror Sites P. To Do List Q. Copyright 表格...
A Sample .bashrc File L. Converting DOS Batch Files to Shell Scripts M. Exercises M.1. Analyzing Scripts M.2. Writing Scripts N. Revision History O. Mirror Sites P. To Do List Q. Copyright 表格清单: ...
set title "Sample Plot" set xlabel "Current (mA)" set ylabel "Voltage (mV)" plot 'file.data' using 1:2 with lines ``` 通过运行`gnuplot file.gnu`命令,即可按照脚本中的设置绘制出图表。 #### 四、...