Archive for the ‘程式設計’ Category
Boomerang 中的 Bandwidth & Latency 測試方式..
- First download a 32 byte gif 10 times serially. This is used to measure latency
We discard the first measurement because that pays the price for the TCP handshake (3 packets) and TCP slow-start (4 more packets). All other image requests take two TCP packets (one for the request and one for the response). This gives us a good idea of how much time it takes to make an HTTP request from the browser to our server.
Once done, we calculate the arithmetic mean, standard deviation and standard error at 95% confidence for the 9 download times that we have. This is the latency number that we beacon back to our server.
- Next download images of increasing size until one of the times out
We choose image sizes so that we can narrow down on a bandwidth range as soon as possible. See the code comments in boomerang.js for full details.
Image timeouts are set at between 1.2 and 1.5seconds. If an image times out, we stop downloading larger images, and retry the largest image 4 more times[3]. We then calculate the bandwidth for the largest 3 images that we downloaded. This should result in 7 readings unless the test timed out before that [4]. We calculate the median, standard deviation and standard error from these values and this is the bandwidth that we beacon back to our server.
全国网路连线品质监控..
现在机房除了做 smokeping 侦对外面几个主要的程式做监控,希望能够更进一步有其他资讯可以参考。在网路上看到了大陆有个叫监控X的网站,里面有一个用户体验(访问速度)跟踪,只是因为是公司使用,不便把资料放在别人的主机或依附他人的服务,所以就参考了他的网页,配合 Y! 的 Boomerang 自己弄了一个。
除了在统计上 Boomerang 的测试会准一点外,借用了监控X的 UI,并稍做修改。在时段选择上加上了最近一小时,跟踪历史部份也改以 Ajax 方式做即时的更新,另外也把一些 js lib 都换新版的用。虽然还有三个是已知的缺陷,不过暂时不想去改动了,等之后再说吧。
这东西算是最近玩比较好玩的东西了….
Y! Boomerang 只測 latency 不測 bandwidth…
最近用了 Y! 的 Boomerang 要來做全國連線品質監測,不過他有個問題是 latency 和 bandwidth 是同一個模組的功能,並沒有參數直接可以設定只跑 latency 不做 bandwidth 測試,但即使設 1 次測試,以現在的來訪數,流量大概會上升 5~10M。在現在是固定頻寬的狀況下,並不是很好。
所以只好在 js 中直接把他處理掉,抓沒壓過的來,把其中 1063 行這段改掉,就會在做完 latency 後直接回傳給統計主機了。
1 2 3 | if (!this.runs_left) { this.finish(); } |
改成
1 2 3 | if (!this.latency_runs) { this.finish(); } |
Smokeping Alexa World Top 100 Web Sites 監控…
最近 NI 同仁提出了一個需求,需要能監控公司對 Alexa 上世界排名前 100 的網站的連線品質,因此用 Perl 寫了這支 Scripts,使用非常簡單,只要先在 smokeping 的 config 裡加上 @include /usr/local/smokeping/alexaworld,然後再把下面這支程式放到 Crontab 去跑,這樣就能夠動態的產生 World Top 100 的列表並由 Smokeping 監控了。
#!/usr/bin/perl # Smokeping Alexa World Top 100 Web Sites Configuration Generater # Jasont(AT)batlab.net 2009/11/17 use strict; use Encode; use LWP::Simple; use URI::URL; my $worldtop_url = "http://www.alexa.com/topsites/global;"; # Get WorldTop my $topid = 1; my @worldtops_name; my @worldtops_link; for ( my $i = 0; $i < 5; $i++ ) { my $url = url($worldtop_url.$i); my $page = get($url); if ( $page ) { Encode::from_to($page, "utf-8", "Big5"); my @lines = split('\n', $page); foreach ( @lines ) { if ( / \>\<strong\>(.*)\<\/strong\>\<\/a\> \<br\/>/ ) { $worldtops_name[$topid] = $1; next; } if ( /class=\"offsite\"\>(.*)\<\/a\>/ ) { $worldtops_link[$topid] = $1; $topid++; next; } } } } # Create Smokeping Config - WorldTop 100 `/bin/echo "+ WorldTop100\n\nmenu = WorldTop100\ntitle = Alexa World Top 100 Sites\n" > /tmp/alexaworld`; foreach my $index ( 1..$#worldtops_name ) { #print "$index: $worldtops_name[$index]\t$worldtops_link[$index]\n"; if ( $index%20 == 1 ) { my $indexdif = $index+19; `/bin/echo "++ Top\"$index\"-\"$indexdif\"\n\nmenu = WorldTop\"$index\"~\"$indexdif\"\ntitle = WorldTop\"$index\"~\"$indexdif\"\n" >> /tmp/alexaworld`; } `/bin/echo "+++ Top\"$index\"\n\nmenu = Top\"$index\"_$worldtops_link[$index]\ntitle = Top\"$index\"_$worldtops_link[$index]\nhost = $worldtops_link[$index]\n" >> /tmp/alexaworld`; } `/bin/cp -f /tmp/alexaworld /usr/local/smokeping/etc/`; `/bin/ps -ef|/bin/grep smokeping | /bin/grep FPing | /bin/awk '{ print "kill -1 "$2}' | /bin/sh`; exit;
Flashget Url 編碼…
也最近在搞個東西,為了增加使用的便利性但又要避免太明目張膽,所以採用了 Flashget,除了可以快速下載,也能將網址編碼後顯示,不會直接看出位址。
Flashget 要在網頁直接支援關聯性,以 flashget:// 方式寫就好。
而網址的部份,把 Link 寫成 [FLASHGET]檔案路徑[FLASHGET],再以 bash64 編碼就好。
非常簡單。只是雖然網上有找到說可以 .lst 方式做下載列表檔,不過我試過繁體 2.0 版沒反應,只好還是委屈用戶一個個下載囉!