腳本統計ab測試數據


建表: php

CREATE TABLE `ab_ceshi` (
  `id` int(11) NOT NULL DEFAULT '0',
  `Server_Software` varchar(50) DEFAULT NULL COMMENT '服務器軟件',
  `Server_Hostname` varchar(50) DEFAULT NULL COMMENT 'host主機名',
  `Server_Port` int(10) DEFAULT NULL COMMENT '訪問端口',
  `Document_Path` varchar(50) DEFAULT NULL COMMENT 'URL訪問路徑',
  `Document_Length` int(10) DEFAULT NULL COMMENT '文件長度',
  `Concurrency_Level` int(20) DEFAULT NULL COMMENT '併發數',
  `Time_taken_for_tests` double(30,0) DEFAULT NULL COMMENT '測試總時間,單位seconds',
  `Complete_requests` int(10) DEFAULT NULL COMMENT '完成的請假',
  `Failed_requests` int(10) DEFAULT NULL COMMENT '失敗的請求',
  `Write_errors` int(10) DEFAULT NULL COMMENT '錯誤寫入',
  `Total_transferred` int(20) DEFAULT NULL COMMENT '總吞吐量大小,單位bytes',
  `HTML_transferred` int(20) DEFAULT NULL COMMENT 'HTML吞吐量,單位bytes',
  `Requests_per_second` double(20,0) DEFAULT NULL COMMENT '每秒請求數,單位[#/sec] (mean)',
  `Time_per_request` double(20,0) DEFAULT NULL COMMENT '每一個請求的時間,[ms] (mean)',
  `Time_per_request2` double(20,0) DEFAULT NULL COMMENT '每一個請求的時間,[ms] (mean, across all concurrent requests)',
  `Transfer_rate` double(20,0) DEFAULT NULL COMMENT '傳輸速率,Kbytes/sec',
  PRIMARY KEY (`id`)
) ENGINE=MyISAM DEFAULT CHARSET=utf8 mysql


腳本: sql

#!/bin/bash
i=100

while [ $i != 1000 ]
#!/bin/bash
i=100

while [ $i != 1000 ]
do

ab -c $i -n 1000 http://127.0.0.1/ddk.php |grep : |grep -v Copyright | grep -v Version > ab.scv

Software=`cat ab.scv | grep "Server Software" | awk '{print $3}'`
Hostname=`cat ab.scv | grep "Server Hostname" | awk '{print $3}'`
Port=`cat ab.scv | grep "Server Port" | awk '{print $3}'`
Path=`cat ab.scv | grep "Document Path" | awk '{print $3}'`
Length=`cat ab.scv | grep "Document Length" | awk '{print $3}'`
Level=`cat ab.scv | grep "Concurrency Level" | awk '{print $3}'`
tests=`cat ab.scv | grep "Time taken for tests" | awk '{print $5}'`
Complete=`cat ab.scv | grep "Complete requests" | awk '{print $3}'`
Failed=`cat ab.scv | grep "Failed requests" | awk '{print $3}'`
Write=`cat ab.scv | grep "Write errors" | awk '{print $3}'`
Total_transferred=`cat ab.scv | grep "Total transferred" | awk '{print $3}'`
HTML_transferred=`cat ab.scv | grep "HTML transferred" | awk '{print $3}'`
Requests_per_second=`cat ab.scv | grep "Requests per second" | awk '{print $4}'`
Time_per_request=`cat ab.scv | grep "Time per request" | grep -v "concurrent requests" | awk '{print $4}'`
Time_per_request2=`cat ab.scv | grep "across all concurrent requests" | awk '{print $4}'`
rate=`cat ab.scv | grep "Transfer rate" | awk '{print $3}'`


echo $Software $Hostname $Port $Path $Length $Level $tests $Complete $Failed $Write $Total_transferred $HTML_transferred $Requests_per_second $Time_per_request $Time_per_request2 $rate

mysql -h192.168.1.22 -uroot -pCCCCCC -e "use BK; INSERT INTO ab_ceshi (Server_Software, Server_Hostname, Server_Port, Document_Path, Document_Length, Concurrency_Level, Time_taken_for_tests, Complete_requests, Failed_requests, Write_errors, Total_transferred, HTML_transferred, Requests_per_second, Time_per_request, Time_per_request2, Transfer_rate) VALUES ('$Software','$Hostname','$Port','$Path','$Length','$Level','$tests','$Complete','$Failed','$Write','$Total_transferred','$HTML_transferred','$Requests_per_second','$Time_per_request','$Time_per_request2','$rate');"

i=`expr $i + 100`
echo "I="$i
sleep 20
done bash

exit 0 服務器

相關文章
相關標籤/搜索