# 簡介
一個 PowerShell 腳本,用於測試 Oracle Cloud 在不同地區的延遲情況。
# 如何使用
- 將腳本保存到一個文件中,例如
oci-ping-test.ps1
。 - 在 PowerShell 中運行該腳本:
.\oci-ping-test.ps1
$hostData = @{ | |
"Chuncheon, Korea" = "objectstorage.ap-chuncheon-1.oraclecloud.com" | |
"Hyderabad, India" = "objectstorage.ap-hyderabad-1.oraclecloud.com" | |
"Osaka, Japan" = "objectstorage.ap-osaka-1.oraclecloud.com" | |
"Seoul, Korea" = "objectstorage.ap-seoul-1.oraclecloud.com" | |
"Sydney, Australia" = "objectstorage.ap-sydney-1.oraclecloud.com" | |
"Tokyo, Japan" = "objectstorage.ap-tokyo-1.oraclecloud.com" | |
"Melbourne, Australia" = "objectstorage.ap-melbourne-1.oraclecloud.com" | |
"Mumbai, India" = "objectstorage.ap-mumbai-1.oraclecloud.com" | |
"Ashburn, VA" = "objectstorage.us-ashburn-1.oraclecloud.com" | |
"Phoenix, AZ" = "objectstorage.us-phoenix-1.oraclecloud.com" | |
"San Jose, CA" = "objectstorage.us-sanjose-1.oraclecloud.com" | |
"Montréal, Canada" = "objectstorage.ca-montreal-1.oraclecloud.com" | |
"Toronto, Canada" = "objectstorage.ca-toronto-1.oraclecloud.com" | |
"Cardiff, UK" = "objectstorage.uk-cardiff-1.oraclecloud.com" | |
"London, UK" = "objectstorage.uk-london-1.oraclecloud.com" | |
"Amsterdam, Netherlands" = "objectstorage.eu-amsterdam-1.oraclecloud.com" | |
"Frankfurt, Germany" = "objectstorage.eu-frankfurt-1.oraclecloud.com" | |
"Zurich, Switzerland" = "objectstorage.eu-zurich-1.oraclecloud.com" | |
"Dubai, UAE" = "objectstorage.me-dubai-1.oraclecloud.com" | |
"Jeddah, Saudi Arabia" = "objectstorage.me-jeddah-1.oraclecloud.com" | |
"Santiago, Chile" = "objectstorage.sa-santiago-1.oraclecloud.com" | |
"Sao Paulo, Brazil" = "objectstorage.sa-saopaulo-1.oraclecloud.com" | |
} | |
$results = foreach ($location in $hostData.Keys) { | |
$hostName = $hostData[$location] | |
$pingResult = Test-Connection -ComputerName $hostName -Count 1 -Quiet | |
if ($pingResult) { | |
$pingTime = (Measure-Command { Test-Connection -ComputerName $hostName -Count 1 }).TotalMilliseconds | |
[PSCustomObject]@{ | |
Location = $location | |
HostName = $hostName | |
PingTime = [Math]::Round($pingTime, 2) | |
} | |
} else { | |
[PSCustomObject]@{ | |
Location = $location | |
HostName = $hostName | |
PingTime = "Unreachable" | |
} | |
} | |
} | |
$results | Sort-Object -Property PingTime | Format-Table |
# 地區列表
Region | Endpoint | Chinese Region |
---|---|---|
Chuncheon, Korea | objectstorage.ap-chuncheon-1.oraclecloud.com | 春川,韓國 |
Hyderabad, India | objectstorage.ap-hyderabad-1.oraclecloud.com | 海德拉巴,印度 |
Osaka, Japan | objectstorage.ap-osaka-1.oraclecloud.com | 大阪,日本 |
Seoul, Korea | objectstorage.ap-seoul-1.oraclecloud.com | 首爾,韓國 |
Sydney, Australia | objectstorage.ap-sydney-1.oraclecloud.com | 悉尼,澳大利亞 |
Tokyo, Japan | objectstorage.ap-tokyo-1.oraclecloud.com | 東京,日本 |
Melbourne, Australia | objectstorage.ap-melbourne-1.oraclecloud.com | 墨爾本,澳大利亞 |
Mumbai, India | objectstorage.ap-mumbai-1.oraclecloud.com | 孟買,印度 |
Ashburn, VA | objectstorage.us-ashburn-1.oraclecloud.com | 阿什本,弗吉尼亞州 |
Phoenix, AZ | objectstorage.us-phoenix-1.oraclecloud.com | 鳳凰城,亞利桑那州 |
San Jose, CA | objectstorage.us-sanjose-1.oraclecloud.com | 聖何塞,加利福尼亞州 |
Montréal, Canada | objectstorage.ca-montreal-1.oraclecloud.com | 蒙特利爾,加拿大 |
Toronto, Canada | objectstorage.ca-toronto-1.oraclecloud.com | 多倫多,加拿大 |
Cardiff, UK | objectstorage.uk-cardiff-1.oraclecloud.com | 卡地夫,英國 |
London, UK | objectstorage.uk-london-1.oraclecloud.com | 倫敦,英國 |
Amsterdam, Netherlands | objectstorage.eu-amsterdam-1.oraclecloud.com | 阿姆斯特丹,荷蘭 |
Frankfurt, Germany | objectstorage.eu-frankfurt-1.oraclecloud.com | 法蘭克福,德國 |
Zurich, Switzerland | objectstorage.eu-zurich-1.oraclecloud.com | 蘇黎世,瑞士 |
Dubai, UAE | objectstorage.me-dubai-1.oraclecloud.com | 杜拜,阿聯酋 |
Jeddah, Saudi Arabia | objectstorage.me-jeddah-1.oraclecloud.com | 吉達,沙特阿拉伯 |
Santiago, Chile | objectstorage.sa-santiago-1.oraclecloud.com | 聖地亞哥,智利 |
Sao Paulo, Brazil | objectstorage.sa-saopaulo-1.oraclecloud.com | 聖保羅,巴西 |
# 腳本
這個 PowerShell 腳本會測試連接到 Oracle Cloud 基礎設施對象存儲服務在世界各地不同地區的延遲情況。它使用 Test-Connection
Cmdlet 來測試每個地區的可達性和 ping 時間。
腳本首先將主機信息存儲在一個關聯數組中,該數組將位置映射到相應的主機名。然後,它遍歷這個數組,對每個位置執行 ping 測試,並將結果存儲在另一個數組中。
最後,腳本將結果按 ping 時間升序排序,並以格式化的表格形式輸出到控制台,顯示位置、主機名和 ping 時間 (如果主機不可達,則顯示 "Unreachable")。
腳本將在控制台中顯示測試結果。您可以根據需要修改 $hostData
哈希表中的主機信息,以測試其他 Oracle Cloud 基礎設施對象存儲端點。