`
annan211
  • 浏览: 456231 次
  • 性别: Icon_minigender_1
  • 来自: 广州
社区版块
存档分类
最新评论

linux shell 分析 ab 测压命令

 
阅读更多
1 分析文档
 
#!/bin/bash
line_num=3
count_num=0
Concurrencyl=0
Timetakenl=0
Completerequestsl=0
Failedrequestsl=0
Requestspersecondl=0
Timeperrequestl=0
Timeperrequestacrossl=0
Transferratel=0
file_name="value.tmp"
result_file="result.csv"

if [ -f $file_name ]; then 
   rm  $file_name
fi

if [ -f $result_file ]; then
    rm  $result_file
fi
 echo "test project","testurl","Concurrent","time token","Completerequests","failed","per time(ms)","thread last time per time(ms)","Concurrent request last time(ms)","network (KB)">> $result_file
     
while read line
do
 if [ -z "$line" ] ; then
			echo $Timetakenl
			echo $Completerequestsl
			
			echo "一轮已经测试完毕"
			echo Average,,,$(echo "$Timetakenl / $line_num" |bc -l),$(echo "$Completerequestsl / $line_num" |bc -l),$(echo "$Failedrequestsl / $line_num" |bc -l),$(echo "$Requestspersecondl / $line_num" |bc -l),$(echo "$Timeperrequestl / $line_num" |bc -l),$(echo "$Timeperrequestacrossl / $line_num" |bc -l),$(echo "$Transferratel / $line_num" |bc -l)>> $result_file
			echo "">> $result_file
			let Concurrencyl=0
			let Timetakenl=0
			let Completerequestsl=0
			let Failedrequestsl=0
			let Requestspersecondl=0
			let Timeperrequestl=0
			let Timeperrequestacrossl=0
			let Transferratel=0
 else 
		   echo $line
		   #s=$line | cut -d ":" -f2 
		   #s=$line
		   OLD_IFS="$IFS"
		   IFS="*"
		   arr=($line)
		   IFS="$OLD_IFS"
		   s=${arr[1]}
		   test_project=${arr[0]}
		   #echo $s
		   #echo $test_project
		   if [ -f $file_name ];then 
				eval '$s'>$file_name    
		   else
				touch $file_name 
				eval '$s'>$file_name    
		   fi	
		   
		    Concurrency=$(grep  "Concurrency Level" $file_name | awk '{print$3}')
			Timetaken=$(grep  "Time taken for tests" $file_name | awk '{print$5}')
			Completerequests=$(grep  "Complete requests" $file_name | awk '{print$3}')
			Failedrequests=$(grep  "Failed requests" $file_name | awk '{print$3}')
			Requestspersecond=$(grep  "Requests per second" $file_name | awk '{print$4}')
			Timeperrequest=$(grep  "Time per request:" $file_name| sed 1q | awk '{print$4}')
			Timeperrequestacross=$(grep  "mean, across all concurrent requests" $file_name | awk '{print$4}')
			Transferrate=$(grep  "Transfer rate" $file_name | awk '{print$3}')
			
			echo $test_project,$s,$Concurrency,$Timetaken,$Completerequests,$Failedrequests,$Requestspersecond,$Timeperrequest,$Timeperrequestacross,$Transferrate >> $result_file
		
			Timetakenl=$(echo "$Timetakenl + $Timetaken" |bc -l)
			Completerequestsl=$(echo "$Completerequestsl + $Completerequests" |bc -l)
			Failedrequestsl=$(echo "$Failedrequestsl + $Failedrequests" |bc -l)
			Requestspersecondl=$(echo "$Requestspersecondl + $Requestspersecond" |bc -l)
			Timeperrequestl=$(echo "$Timeperrequestl + $Timeperrequest" |bc -l)	
			Timeperrequestacrossl=$(echo "$Timeperrequestacrossl + $Timeperrequestacross" |bc -l)
			Transferratel=$(echo "$Transferratel + $Transferrate" |bc -l)
 fi	
done <key.txt
echo "操作完毕"












2 测试文件
firstpage*ab  -c 100 -n 1000  http://192.168.0.219/
firstpage*ab  -c 100 -n 1001  http://192.168.0.219/
firstpage*ab  -c 100 -n 1002  http://192.168.0.219/

firstpage*ab  -c 100 -n 1003  http://192.168.0.219/
firstpage*ab  -c 100 -n 1004  http://192.168.0.219/
firstpage*ab  -c 100 -n 1005  http://192.168.0.219/


执行脚本即可得到你希望的结果
分享到:
评论

相关推荐

    Linux下Shell命令解释步骤程序实现

    Linux Shell 命令解释步骤程序实现 Linux Shell 命令解释是 Linux 操作系统中最基本也是最重要的一部分,它负责处理用户与操作系统之间的交互动作,并且给出相应的操作系统的输出结果。 Shell 基本上是一个命令...

    LINUX SHELL命令练习题

    LINUX SHELL 命令练习题 本次练习题涵盖了 LINUX SHELL commands 的多个方面,包括文件类型的确定、文件权限的修改、目录管理、文件重命名、系统初始化信息、系统启动级别的切换、后台执行程序、vi 编辑器的使用等...

    linuxshell命令 unixshell命令教程

    本教程将深入探讨Linux Shell和Unix Shell命令,帮助你更好地理解和运用这些强大的工具。 一、Shell简介 Shell是操作系统中的一个程序,它为用户提供了一个与内核交互的界面。在Linux和Unix系统中,最常用的Shell有...

    C实现Linux中Shell部分命令.zip

    在Linux操作系统中,Shell是一种命令行解释器,它允许用户通过文本输入来执行系统命令。C语言实现Linux Shell的功能是一项有趣的编程挑战,可以深入理解操作系统的工作原理。本项目旨在用C语言实现一些基本的Shell...

    linuxshell命令unixshell命令教程.rar

    这份"Linux Shell命令Unix Shell命令教程"PDF文件将涵盖上述知识,并可能包括更详细的实例和练习,帮助读者深入理解和掌握Shell命令的使用。通过阅读和实践,你将能够更加熟练地运用这些命令来管理Linux和Unix系统,...

    linux shell的常用命令

    linux,shell的常用命令,课件很不错总结很详细

    Linux shell 及常用命令介绍.txt Linux shell 及常用命令介绍.txt

    ### Linux Shell 及其常用命令详解 #### 一、Shell简介 在Linux系统中,**Shell** 是用户与操作系统交互的主要界面之一。它提供了一种命令行方式来控制计算机的操作,使得用户能够通过输入简单的文本命令来执行复杂...

    linuxshell命令unixshell命令教程

    本教程针对初学者,旨在深入讲解Linux Shell和Unix Shell命令的使用,帮助你快速掌握这两种系统的操作技巧。 首先,Shell是一个命令解释器,它将用户输入的命令解析并执行。在Linux和Unix中,常见的Shell有Bash...

    linux shell命令tr的用法

    linux shell命令tr的用法

    最牛B的 Linux Shell 命令

    最牛B的 Linux Shell 命令,最牛B的 Linux Shell 命令,

    linux shell学习资料

    理解Shell的语法和命令,熟悉其工作原理,对于任何想要深入理解Linux系统的人来说都是必不可少的。通过这三本书的学习,你将能够熟练地运用Shell,实现高效的工作流程,甚至可以创建自己的工具和脚本来简化日常任务...

    linux_shell实例精解

    Linux Shell是Linux操作系统中的一种命令解释器,它提供了一个用户与操作系统内核交互的界面,使得用户可以通过文本命令行执行各种操作。Shell脚本则是一种编程语言,它允许用户编写包含一系列命令的程序,实现自动...

    linuxshell命令unixshell命令教程续

    Linux Shell和Unix Shell是两种广泛使用的命令行解释器,它们为用户提供了一个与操作系统交互的界面。在本教程中,我们将深入探讨这两个环境的基础知识,帮助初学者更好地理解和使用Shell。 首先,让我们了解一下...

    Linux主要shell命令、sed、awk使用详解

    Linux 主要shell命令、sed、awk使用详解 Linux 主要shell命令详解 shell 是用户和 Linux 操作系统之间的接口。Linux 中有多种 shell,其中缺省使用的是 Bash。本章讲述了 shell 的工作原理,shell 的种类,shell ...

    linux Shell编程入门 实例讲解详解

    Linux Shell编程入门实例讲解详解 Linux Shell编程是Linux系统中一种非常灵活的工具,通过shell编程可以自动化大量的任务,especially适合那些易用性、可维护性和便携性比效率更重要的任务。下面是Linux Shell编程...

    Linux Shell编程&常用shell命令

    Linux Shell编程与常用Shell命令是Linux系统管理及自动化工作中的核心技能。Shell是Linux操作系统下的一种命令行解释器,它提供了用户与操作系统内核交互的界面。通过编写Shell脚本,用户可以自动化执行一系列任务,...

    基于Linux Shell命令的用户异常操作检测方法研究.pdf

    本文还讨论了Linux Shell命令在异常操作检测中的应用,并对该方法的优缺点进行了分析。本文提出的基于Linux Shell命令的用户异常操作检测方法可以满足数据中心安全需求,提高数据中心的安全性和可靠性。 Linux ...

    linux shell命令sed的使用方法

    linux shell命令sed的使用方法

    Linux shell命令详解

    简单的说shell程序就是一个包含若干行shell或者linux命令的文件,象编写高级语言的程序一样,编写一个shell程序需要一个文本编辑器.如Ⅵ等.在文本编辑环境下,依据shell的语法规则,输入一些shell/linux命令行,形成...

    Linux通过Shell脚本命令修改密码的两种方式

    使用该命令会有提示,即进入了交互界面,输入密码即可。 使用脚本修改密码 很多时候我们可能需要远程执行服务器上的脚本来修改账号密码,此时就没有办法进行交互了。 此时可以使用如下两种方式修改密码: 方式1: ...

Global site tag (gtag.js) - Google Analytics