Server Benchmark 工具
Friday, August 23, 2013 » Benchmark, OpenSource, Authored by Lucemia
Python寫的網路測速程式
為了能夠比較不同hosting的對特定區域的網路速度而寫的簡單程式,透過speedtest-cli的服務+能夠指定國家測試, 測試結果以 csv 的方式記錄下來. 並且提供將結果匯入到 sqlite 裡面方便計算的工具
Requirement
需要先安裝 speedtest-cli 與 clime
1 | pip install speedtest-cli
|
1 | pip install clime
|
Install
1 | git clone https://github.com/lucemia/GCEvsAWS.git
|
Usage
執行國別測試
1 | python test.py speed-test --country=[測試國家] [server_name]
|
範例:
1 | python test.py speed-test --country=Taiwan localhost
|
結果會存在 [server_name].csv
中
1 2 3 | mac,2013-08-21 21:52:30.608635,True,2133,Taiwan Fixed Network,Taipei,Taiwan,9592.46,Telus Communications,154.5.56.215,112.772,9.23,0.64
mac,2013-08-21 21:52:30.608635,True,2181,kbro CO.LTD,Taipei,Taiwan,9592.46,Telus Communications,154.5.56.215,68.347,8.80,0.65
mac,2013-08-21 21:52:30.608635,True,2182,kbro CO.LTD,Hsinchu,Taiwan,9644.62,Telus Communications,154.5.56.215,111.341,7.39,0.59
|
對特定server測試
1 | python test.py test-server [server_id] [log_path]
|
範例:
1 | python test.py test-server 999 999.log
|
回傳結果:
1 2 3 4 5 6 7 8 9 10 | {
'distance': '8468.27',
'host_name': 'InternetONE',
'download': '2.49',
'ip': '216.232.96.61',
'test_from': 'Telus Communications',
'ping': '104.666',
'upload': '0.62',
'location': 'Varese'
}
|
將測試結果匯入 sqlite
1 | python test.py import-csv [csv_path]
|
範例:
1 | python test.py import-csv localhost.csv
|
結果會匯入到 speeddata.db
中
計算結果
1 2 3 | select host, avg(server_upload), avg(server_download)
from speeddata
group by host
|