如何写一个统计脚本?
1.刚做完对server的用户登陆退出的压力测试,循环跑了10000次。(在这以2次为例)2.现在测试数据也都放在一个名字为test.out的文件里。
test.out内容大概是这样的:
begin :login
time elapsed: 0.0140 action: login
pass :login
begin :logout
time elapsed: 0.0077 action: logout
pass :logout
begin :login
time elapsed: 0.0563 action: login
pass :login
begin :logout
time elapsed: 0.0077 action: logout
pass :logout
3.从研发那拿到一个脚本count,用来统计的。
#!/bin/bash
grep elapse test.out >elapse
cat elapse |sed -e "s/.*action: //g"|sort -u >actions
for file in $(cat actions ); do grep $file elapse |sed -e "s/.*elapsed: \(.*\) action.*/\1/g" >s.$file; done
for file in $(cat actions ); do cat s.$file|add >x; wc -l s.$file |sed -e "s/ .*//g" >y;echo -n $file " " ; echo $(cat x)/$(cat y)|bc ~/.scale -l ;done >z
cat z|sed -e 's/\(.*\) \(.*\)
在他那里试了一下,结果倒是出来了。如下:
0.03515 login
0.00770 logout
为何我在自己机器上运行后就不行呢?显示如下:
./stress: line 5: add: command not found
./stress: line 5: bc: command not found
./stress: line 5: add: command not found
./stress: line 5: bc: command not found
./stress: line 6: unexpected EOF while looking for matching `''
./stress: line 7: syntax error: unexpected end of file
大家能不能帮我看看到底是咋回事?是不是脚本有错的地方?或者哪位大侠能写的,帮忙重新写一个统计脚本啊。
公司等着我的数据,急用啊! 你的机器也是linux系统吗?
页:
[1]