├── LICENSE ├── README.md ├── speedtest.sh └── tools.py /LICENSE: -------------------------------------------------------------------------------- 1 | MIT License 2 | 3 | Copyright (c) 2019 laset-com 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. 22 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # Speedtest 2 | 3 | https://bench.monster 4 | 5 | `curl -sL bench.monster | bash` 6 | 7 | # Credits 8 | 9 | Thanks to @MasonR @sayem314 for the code 10 | -------------------------------------------------------------------------------- /speedtest.sh: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | 3 | bench_v="v1.7.4" 4 | bench_d="2023-12-15" 5 | about() { 6 | echo "" 7 | echo " ========================================================= " 8 | echo " \ Speedtest https://bench.monster / " 9 | echo " \ System info, Geekbench, I/O test and speedtest / " 10 | echo " \ $bench_v $bench_d / " 11 | echo " ========================================================= " 12 | echo "" 13 | } 14 | 15 | cancel() { 16 | echo "" 17 | next; 18 | echo " Abort ..." 19 | echo " Cleanup ..." 20 | cleanup; 21 | echo " Done" 22 | exit 23 | } 24 | 25 | trap cancel SIGINT 26 | 27 | benchram="$HOME/tmpbenchram" 28 | NULL="/dev/null" 29 | 30 | # determine architecture of host 31 | ARCH=$(uname -m) 32 | if [[ $ARCH = *x86_64* ]]; then 33 | # host is running a 64-bit kernel 34 | ARCH="x64" 35 | elif [[ $ARCH = *i?86* ]]; then 36 | # host is running a 32-bit kernel 37 | ARCH="x86" 38 | else 39 | # host is running a non-supported kernel 40 | echo -e "Architecture not supported." 41 | exit 1 42 | fi 43 | 44 | echostyle(){ 45 | if hash tput 2>$NULL; then 46 | echo " $(tput setaf 6)$1$(tput sgr0)" 47 | echo " $1" >> $log 48 | else 49 | echo " $1" | tee -a $log 50 | fi 51 | } 52 | 53 | benchinit() { 54 | # check release 55 | if [ -f /etc/redhat-release ]; then 56 | release="centos" 57 | elif cat /etc/issue | grep -Eqi "debian"; then 58 | release="debian" 59 | elif cat /etc/issue | grep -Eqi "ubuntu"; then 60 | release="ubuntu" 61 | elif cat /etc/issue | grep -Eqi "centos|red hat|redhat"; then 62 | release="centos" 63 | elif cat /proc/version | grep -Eqi "debian"; then 64 | release="debian" 65 | elif cat /proc/version | grep -Eqi "ubuntu"; then 66 | release="ubuntu" 67 | elif cat /proc/version | grep -Eqi "centos|red hat|redhat"; then 68 | release="centos" 69 | fi 70 | 71 | # check OS 72 | #if [ "${release}" == "centos" ]; then 73 | # echo "Checking OS ... [ok]" 74 | #else 75 | # echo "Error: This script must be run on CentOS!" 76 | # exit 1 77 | #fi 78 | #echo -ne "\e[1A"; echo -ne "\e[0K\r" 79 | 80 | # check root 81 | [[ $EUID -ne 0 ]] && echo -e "Error: This script must be run as root!" && exit 1 82 | 83 | 84 | # check python 85 | if [ ! -e '/usr/bin/python3' ]; then 86 | echo " Installing Python3 ..." 87 | if [ "${release}" == "centos" ]; then 88 | yum -y install python3 > /dev/null 2>&1 89 | alternatives --set python3 /usr/bin/python3 > /dev/null 2>&1 90 | else 91 | apt-get -y install python3 > /dev/null 2>&1 92 | fi 93 | echo -ne "\e[1A"; echo -ne "\e[0K\r" 94 | fi 95 | 96 | # check curl 97 | if [ ! -e '/usr/bin/curl' ]; then 98 | echo " Installing Curl ..." 99 | if [ "${release}" == "centos" ]; then 100 | yum -y install curl > /dev/null 2>&1 101 | else 102 | apt-get -y install curl > /dev/null 2>&1 103 | fi 104 | echo -ne "\e[1A"; echo -ne "\e[0K\r" 105 | fi 106 | 107 | # check wget 108 | if [ ! -e '/usr/bin/wget' ]; then 109 | echo " Installing Wget ..." 110 | if [ "${release}" == "centos" ]; then 111 | yum -y install wget > /dev/null 2>&1 112 | else 113 | apt-get -y install wget > /dev/null 2>&1 114 | fi 115 | echo -ne "\e[1A"; echo -ne "\e[0K\r" 116 | fi 117 | 118 | # check bzip2 119 | if [ ! -e '/usr/bin/bzip2' ]; then 120 | echo " Installing bzip2 ..." 121 | if [ "${release}" == "centos" ]; then 122 | yum -y install bzip2 > /dev/null 2>&1 123 | else 124 | apt-get -y install bzip2 > /dev/null 2>&1 125 | fi 126 | echo -ne "\e[1A"; echo -ne "\e[0K\r" 127 | fi 128 | 129 | # check tar 130 | if [ ! -e '/usr/bin/tar' ]; then 131 | echo " Installing tar ..." 132 | if [ "${release}" == "centos" ]; then 133 | yum -y install tar > /dev/null 2>&1 134 | else 135 | apt-get -y install tar > /dev/null 2>&1 136 | fi 137 | echo -ne "\e[1A"; echo -ne "\e[0K\r" 138 | fi 139 | 140 | # install speedtest-cli 141 | if [ ! -e 'speedtest.py' ]; then 142 | echo " Installing Speedtest-cli ..." 143 | wget --no-check-certificate https://raw.githubusercontent.com/laset-com/speedtest-cli/master/speedtest.py > /dev/null 2>&1 144 | echo -ne "\e[1A"; echo -ne "\e[0K\r" 145 | fi 146 | chmod a+rx speedtest.py 147 | 148 | 149 | # install tools.py 150 | if [ ! -e 'tools.py' ]; then 151 | echo " Installing tools.py ..." 152 | wget --no-check-certificate https://raw.githubusercontent.com/laset-com/speedtest/master/tools.py > /dev/null 2>&1 153 | echo -ne "\e[1A"; echo -ne "\e[0K\r" 154 | fi 155 | chmod a+rx tools.py 156 | 157 | sleep 5 158 | 159 | # start 160 | start=$(date +%s) 161 | } 162 | 163 | get_opsy() { 164 | [ -f /etc/redhat-release ] && awk '{print ($1,$3~/^[0-9]/?$3:$4)}' /etc/redhat-release && return 165 | [ -f /etc/os-release ] && awk -F'[= "]' '/PRETTY_NAME/{print $3,$4,$5}' /etc/os-release && return 166 | [ -f /etc/lsb-release ] && awk -F'[="]+' '/DESCRIPTION/{print $2}' /etc/lsb-release && return 167 | } 168 | 169 | next() { 170 | printf "%-75s\n" "-" | sed 's/\s/-/g' | tee -a $log 171 | } 172 | next2() { 173 | printf "%-57s\n" "-" | sed 's/\s/-/g' 174 | } 175 | 176 | delete() { 177 | echo -ne "\e[1A"; echo -ne "\e[0K\r" 178 | } 179 | 180 | speed_test(){ 181 | if [[ $1 == '' ]]; then 182 | temp=$(python3 speedtest.py --secure --share 2>&1) 183 | is_down=$(echo "$temp" | grep 'Download') 184 | result_speed=$(echo "$temp" | awk -F ' ' '/results/{print $3}') 185 | if [[ ${is_down} ]]; then 186 | local REDownload=$(echo "$temp" | awk -F ':' '/Download/{print $2}') 187 | local reupload=$(echo "$temp" | awk -F ':' '/Upload/{print $2}') 188 | local relatency=$(echo "$temp" | awk -F ':' '/Hosted/{print $2}') 189 | 190 | temp=$(echo "$relatency" | awk -F '.' '{print $1}') 191 | if [[ ${temp} -gt 50 ]]; then 192 | relatency="*"${relatency} 193 | fi 194 | local nodeName=$2 195 | 196 | temp=$(echo "${REDownload}" | awk -F ' ' '{print $1}') 197 | if [[ $(awk -v num1=${temp} -v num2=0 'BEGIN{print(num1>num2)?"1":"0"}') -eq 1 ]]; then 198 | printf "%-17s%-17s%-17s%-7s\n" " ${nodeName}" "${reupload}" "${REDownload}" "${relatency}" | tee -a $log 199 | fi 200 | else 201 | local cerror="ERROR" 202 | fi 203 | else 204 | temp=$(python3 speedtest.py --secure --server $1 --share 2>&1) 205 | is_down=$(echo "$temp" | grep 'Download') 206 | if [[ ${is_down} ]]; then 207 | local REDownload=$(echo "$temp" | awk -F ':' '/Download/{print $2}') 208 | local reupload=$(echo "$temp" | awk -F ':' '/Upload/{print $2}') 209 | #local relatency=$(echo "$temp" | awk -F ':' '/Hosted/{print $2}') 210 | local relatency=$(pingtest $3) 211 | #temp=$(echo "$relatency" | awk -F '.' '{print $1}') 212 | #if [[ ${temp} -gt 1000 ]]; then 213 | #relatency=" - " 214 | #fi 215 | local nodeName=$2 216 | 217 | temp=$(echo "${REDownload}" | awk -F ' ' '{print $1}') 218 | if [[ $(awk -v num1=${temp} -v num2=0 'BEGIN{print(num1>num2)?"1":"0"}') -eq 1 ]]; then 219 | printf "%-17s%-17s%-17s%-7s\n" " ${nodeName}" "${reupload}" "${REDownload}" "${relatency}" | tee -a $log 220 | fi 221 | else 222 | local cerror="ERROR" 223 | fi 224 | fi 225 | } 226 | 227 | 228 | print_speedtest() { 229 | echo "" | tee -a $log 230 | echostyle "## Global Speedtest.net" 231 | echo "" | tee -a $log 232 | printf "%-32s%-17s%-17s%-7s\n" " Location" "Upload" "Download" "Ping" | tee -a $log 233 | printf "%-75s\n" "-" | sed 's/\s/-/g' | tee -a $log 234 | speed_test '' 'Nearby ' 235 | printf "%-75s\n" "-" | sed 's/\s/-/g' | tee -a $log 236 | speed_test '21016' 'USA, New York (Starry) ' 'http://speedtest-server-nyc.starry.com' 237 | speed_test '17384' 'USA, Chicago (Windstream) ' 'http://chicago02.speedtest.windstream.net' 238 | speed_test '1763' 'USA, Houston (Comcast) ' 'http://po-1-xar01.greenspoint.tx.houston.comcast.net' 239 | speed_test '1779' 'USA, Miami (Comcast) ' 'http://50.208.232.125' 240 | speed_test '18401' 'USA, Los Angeles (Windstream) ' 'http://la02.speedtest.windstream.net' 241 | speed_test '26922' 'UK, London (toob Ltd) ' 'http://185.82.8.1' 242 | speed_test '24215' 'France, Paris (Orange) ' 'http://178.21.176.100' 243 | speed_test '20507' 'Germany, Berlin (DNS:NET) ' 'http://speedtest01.dns-net.de' 244 | speed_test '21378' 'Spain, Madrid (MasMovil) ' 'http://speedtest-mad.masmovil.com' 245 | speed_test '395' 'Italy, Rome (Unidata) ' 'http://speedtest2.unidata.it' 246 | speed_test '23647' 'India, Mumbai (Tatasky) ' 'http://speedtestmum.tataskybroadband.com' 247 | speed_test '51914' 'Singapore (StarHub) ' 'http://co2dsvr03.speedtest.starhub.com' 248 | speed_test '7139' 'Japan, Tsukuba (SoftEther) ' 'http://speedtest2.softether.co.jp' 249 | speed_test '1267' 'Australia, Sydney (Optus) ' 'http://s1.speedtest.syd.optusnet.com.au' 250 | speed_test '6591' 'RSA, Randburg (Cool Ideas) ' 'http://sp2.cisp.co.za' 251 | speed_test '11488' 'Brazil, Sao Paulo (Criare) ' 'http://ookla.spcom.net.br' 252 | 253 | rm -rf speedtest.py 254 | } 255 | 256 | print_speedtest_usa() { 257 | echo "" | tee -a $log 258 | echostyle "## USA Speedtest.net" 259 | echo "" | tee -a $log 260 | printf "%-33s%-17s%-17s%-7s\n" " Location" "Upload" "Download" "Ping" | tee -a $log 261 | printf "%-76s\n" "-" | sed 's/\s/-/g' | tee -a $log 262 | speed_test '' 'Nearby ' 263 | printf "%-76s\n" "-" | sed 's/\s/-/g' | tee -a $log 264 | speed_test '21016' 'USA, New York (Starry) ' 'http://speedtest-server-nyc.starry.com' 265 | speed_test '1774' 'USA, Boston (Comcast) ' 'http://po-2-rur102.needham.ma.boston.comcast.net' 266 | speed_test '1775' 'USA, Baltimore, MD (Comcast) ' 'http://po-1-rur101.capitolhghts.md.bad.comcast.net' 267 | speed_test '17387' 'USA, Atlanta (Windstream) ' 'http://atlanta02.speedtest.windstream.net' 268 | speed_test '14237' 'USA, Miami (Frontier) ' 'http://miami.fl.speedtest.frontier.com' 269 | speed_test '1764' 'USA, Nashville (Comcast) ' 'http://be-304-cr23.nashville.tn.ibone.comcast.net' 270 | speed_test '10152' 'USA, Indianapolis (CenturyLink)' 'http://indianapolis.speedtest.centurylink.net' 271 | speed_test '10138' 'USA, Cleveland (CenturyLink) ' 'http://cleveland.speedtest.centurylink.net' 272 | speed_test '1778' 'USA, Detroit, MI (Comcast) ' 'http://ae-97-rur101.taylor.mi.michigan.comcast.net' 273 | speed_test '17384' 'USA, Chicago (Windstream) ' 'http://chicago02.speedtest.windstream.net' 274 | speed_test '4557' 'USA, St. Louis (Elite Fiber) ' 'http://speed.elitesystemsllc.com' 275 | speed_test '2917' 'USA, Minneapolis (US Internet) ' 'http://speedtest.usiwireless.com' 276 | speed_test '13628' 'USA, Kansas City (Nocix) ' 'http://speedtest.nocix.net' 277 | speed_test '1763' 'USA, Houston (Comcast) ' 'http://po-1-xar01.greenspoint.tx.houston.comcast.net' 278 | speed_test '8862' 'USA, Denver (CenturyLink) ' 'http://denver.speedtest.centurylink.net' 279 | speed_test '16869' 'USA, Albuquerque (Plateau Tel) ' 'http://speedtest4.plateautel.net' 280 | speed_test '28800' 'USA, Phoenix (PhoenixNAP) ' 'http://speedtest.phoenixnap.com' 281 | speed_test '1781' 'USA, Salt Lake City (Comcast) ' 'http://be-36711-ar01.saltlakecity.ut.utah.comcast.net' 282 | speed_test '1782' 'USA, Seattle (Comcast) ' 'http://po-1-xar02.seattle.wa.seattle.comcast.net' 283 | speed_test '1783' 'USA, San Francisco (Comcast) ' 'http://be-232-rur01.santaclara.ca.sfba.comcast.net' 284 | speed_test '18401' 'USA, Los Angeles (Windstream) ' 'http://la02.speedtest.windstream.net' 285 | speed_test '980' 'USA, Anchorage (Alaska Com) ' 'http://speedtest.anc.acsalaska.net' 286 | speed_test '24031' 'USA, Honolulu (Hawaiian Telcom)' 'http://htspeed.hawaiiantel.net' 287 | 288 | rm -rf speedtest.py 289 | } 290 | 291 | print_speedtest_in() { 292 | echo "" | tee -a $log 293 | echostyle "## India Speedtest.net" 294 | echo "" | tee -a $log 295 | printf "%-33s%-17s%-17s%-7s\n" " Location" "Upload" "Download" "Ping" | tee -a $log 296 | printf "%-75s\n" "-" | sed 's/\s/-/g' | tee -a $log 297 | speed_test '' 'Nearby ' 298 | printf "%-75s\n" "-" | sed 's/\s/-/g' | tee -a $log 299 | speed_test '7236' 'India, New Delhi (iForce) ' 'http://speed.iforcenetworks.co.in' 300 | speed_test '23647' 'India, Mumbai (Tatasky) ' 'http://speedtestmum.tataskybroadband.com' 301 | speed_test '16086' 'India, Nagpur (optbb) ' 'http://speedtest.optbb.in' 302 | speed_test '23244' 'India, Patna (Airtel) ' 'http://speedtestbhr1.airtel.in' 303 | speed_test '15697' 'India, Kolkata (RailTel) ' 'http://kol.speedtest.rcil.gov.in' 304 | speed_test '27524' 'India, Visakhapatnam (Alliance)' 'http://speedtestvtz.alliancebroadband.in' 305 | speed_test '13785' 'India, Hyderabad (I-ON) ' 'http://testspeed.vainavi.net' 306 | speed_test '10024' 'India, Madurai (Niss Broadband)' 'http://madurai.nissbroadband.com' 307 | rm -rf speedtest.py 308 | } 309 | 310 | print_speedtest_europe() { 311 | echo "" | tee -a $log 312 | echostyle "## Europe Speedtest.net" 313 | echo "" | tee -a $log 314 | printf "%-34s%-17s%-17s%-7s\n" " Location" "Upload" "Download" "Ping" | tee -a $log 315 | printf "%-75s\n" "-" | sed 's/\s/-/g' | tee -a $log 316 | speed_test '' 'Nearby ' 317 | printf "%-75s\n" "-" | sed 's/\s/-/g' | tee -a $log 318 | speed_test '26922' 'UK, London (toob Ltd) ' 'http://185.82.8.1' 319 | speed_test '29076' 'Netherlands, Amsterdam (XS News)' 'http://speedtest.xsnews.nl' 320 | speed_test '20507' 'Germany, Berlin (DNS:NET) ' 'http://speedtest01.dns-net.de' 321 | speed_test '27345' 'Germany, Munich (InterNetX) ' 'http://speedtest.internetx.de' 322 | speed_test '26852' 'Sweden, Stockholm (SUNET) ' 'http://fd.sunet.se' 323 | speed_test '8018' 'Norway, Oslo (NextGenTel) ' 'http://sp2.nextgentel.no' 324 | speed_test '24215' 'France, Paris (Orange) ' 'http://178.21.176.100' 325 | speed_test '21378' 'Spain, Madrid (MasMovil) ' 'http://speedtest-mad.masmovil.com' 326 | speed_test '395' 'Italy, Rome (Unidata) ' 'http://speedtest2.unidata.it' 327 | speed_test '21975' 'Czechia, Prague (Nordic Telecom)' 'http://ookla.nordictelecom.cz' 328 | speed_test '12390' 'Austria, Vienna (A1) ' 'http://speedtest.a1.net' 329 | speed_test '7103' 'Poland, Warsaw (ISP Emitel) ' 'http://speedtest.emitel.pl' 330 | speed_test '30813' 'Ukraine, Kyiv (KyivStar) ' 'http://srv01-okl-kv.kyivstar.ua' 331 | speed_test '5834' 'Latvia, Riga (Bite) ' 'http://213.226.139.90' 332 | speed_test '4290' 'Romania, Bucharest (iNES) ' 'http://speed.ines.ro' 333 | speed_test '1727' 'Greece, Athens (GRNET) ' 'http://speed-test.gr-ix.gr' 334 | speed_test '32575' 'Turkey, Urfa (Firatnet) ' 'http://firatspeedtest.com' 335 | 336 | rm -rf speedtest.py 337 | } 338 | 339 | print_speedtest_asia() { 340 | echo "" | tee -a $log 341 | echostyle "## Asia Speedtest.net" 342 | echo "" | tee -a $log 343 | printf "%-34s%-17s%-17s%-7s\n" " Location" "Upload" "Download" "Ping" | tee -a $log 344 | printf "%-75s\n" "-" | sed 's/\s/-/g' | tee -a $log 345 | speed_test '' 'Nearby ' 346 | printf "%-75s\n" "-" | sed 's/\s/-/g' | tee -a $log 347 | speed_test '16475' 'India, New Delhi (Weebo) ' 'http://sp1.weebo.in' 348 | speed_test '23647' 'India, Mumbai (Tatasky) ' 'http://speedtestmum.tataskybroadband.com' 349 | speed_test '1131' 'Sri Lanka, Colombo (Telecom PLC)' 'http://speedtest2.sltnet.lk' 350 | speed_test '7147' 'Bangladesh, Dhaka (Skytel) ' 'http://sp1.cosmocom.net' 351 | speed_test '14062' 'Myanmar, Yangon (5BB Broadband) ' 'http://5bbbroadband.com' 352 | speed_test '26845' 'Laos, Vientaine (Mangkone) ' 'http://speedtest.mangkone.com' 353 | speed_test '13871' 'Thailand, Bangkok (CAT Telecom) ' 'http://catspeedtest.net' 354 | speed_test '10798' 'Cambodia, Phnom Penh (Today) ' 'http://100ge0-36.core1.pnh1.he.net' 355 | speed_test '9174' 'Vietnam, Hanoi (MOBIFONE) ' 'http://st1.mobifone.vn' 356 | speed_test '27261' 'Malaysia, Kuala Lumpur (Extreme)' 'http://kl-speedtest.ebb.my' 357 | speed_test '51914' 'Singapore (StarHub) ' 'http://co2dsvr03.speedtest.starhub.com' 358 | speed_test '11118' 'Indonesia, Jakarta (My Republic)' 'http://158.140.187.5' 359 | speed_test '7167' 'Philippines, Manila (PLDT) ' 'http://119.92.238.50' 360 | speed_test '16176' 'Hong Kong (HGC Global) ' 'http://ookla-speedtest.hgconair.hgc.com.hk' 361 | speed_test '13506' 'Taiwan, Taipei (TAIFO) ' 'http://speedtest.taifo.com.tw' 362 | speed_test '7139' 'Japan, Tsukuba (SoftEther) ' 'http://speedtest2.softether.co.jp' 363 | 364 | rm -rf speedtest.py 365 | } 366 | 367 | print_speedtest_sa() { 368 | echo "" | tee -a $log 369 | echostyle "## South America Speedtest.net" 370 | echo "" | tee -a $log 371 | printf "%-37s%-17s%-17s%-7s\n" " Location" "Upload" "Download" "Ping" | tee -a $log 372 | printf "%-80s\n" "-" | sed 's/\s/-/g' | tee -a $log 373 | speed_test '' 'Nearby ' 374 | printf "%-80s\n" "-" | sed 's/\s/-/g' | tee -a $log 375 | speed_test '11488' 'Brazil, Sao Paulo (Criare) ' 'http://ookla.spcom.net.br' 376 | speed_test '11435' 'Brazil, Fortaleza (Netonda) ' 'http://speedtest.netonda.com.br' 377 | speed_test '18126' 'Brazil, Manaus (Claro) ' 'http://spd7.claro.com.br' 378 | speed_test '11683' 'Colombia, Bogota (Level 3) ' 'http://speedtest.globalcrossing.com.co' 379 | speed_test '31043' 'Ecuador, Ambato (EXTREME) ' 'http://speed.extreme.net.ec' 380 | speed_test '5272' 'Peru, Lima (Fiberluxperu) ' 'http://medidor.fiberluxperu.com' 381 | speed_test '1053' 'Bolivia, La Paz (Nuevatel) ' 'http://speedtest.nuevatel.com' 382 | speed_test '6776' 'Paraguay, Asuncion (TEISA) ' 'http://sp1.teisa.com.py' 383 | speed_test '21436' 'Chile, Santiago (Movistar) ' 'http://speedtest-h5-10g.movistarplay.cl' 384 | speed_test '5181' 'Argentina, Buenos Aires (Claro) ' 'http://speedtest.claro.com.ar' 385 | speed_test '10315' 'Argentina, Cordoba (Personal) ' 'http://st1res.personal.com.ar' 386 | speed_test '1546' 'Uruguay, Montevideo (Antel) ' 'http://speedtest.movistar.com.uy' 387 | 388 | rm -rf speedtest.py 389 | } 390 | 391 | print_speedtest_au() { 392 | echo "" | tee -a $log 393 | echostyle "## Australia & New Zealand Speedtest.net" 394 | echo "" | tee -a $log 395 | printf "%-32s%-17s%-17s%-7s\n" " Location" "Upload" "Download" "Ping" | tee -a $log 396 | printf "%-75s\n" "-" | sed 's/\s/-/g' | tee -a $log 397 | speed_test '' 'Nearby ' 398 | printf "%-75s\n" "-" | sed 's/\s/-/g' | tee -a $log 399 | speed_test '1267' 'Australia, Sydney (Optus) ' 'http://s1.speedtest.syd.optusnet.com.au' 400 | speed_test '2225' 'Australia, Melbourne (Telstra)' 'http://mel1.speedtest.telstra.net' 401 | speed_test '2604' 'Australia, Brisbane (Telstra) ' 'http://brs1.speedtest.telstra.net' 402 | speed_test '18247' 'Australia, Adelaide (Vocus) ' 'http://speedtest-ade.vocus.net' 403 | speed_test '8976' 'Australia, Hobart (Optus) ' 'http://speedtest.tas.optusnet.com.au' 404 | speed_test '22036' 'Australia, Darwin (Telstra) ' 'http://drw1.speedtest.telstra.net' 405 | speed_test '2627' 'Australia, Perth (Telstra) ' 'http://per1.speedtest.telstra.net' 406 | speed_test '5539' 'NZ, Auckland (2degrees) ' 'http://speed2.snap.net.nz' 407 | speed_test '11326' 'NZ, Wellington (Spark) ' 'http://speedtest-wellington.spark.co.nz' 408 | speed_test '4934' 'NZ, Christchurch (Vodafone) ' 'http://christchurch.speedtest.vodafone.co.nz' 409 | 410 | rm -rf speedtest.py 411 | } 412 | 413 | print_speedtest_ukraine() { 414 | echo "" | tee -a $log 415 | echostyle "## Ukraine Speedtest.net" 416 | echo "" | tee -a $log 417 | printf "%-32s%-17s%-17s%-7s\n" " Location" "Upload" "Download" "Ping" | tee -a $log 418 | printf "%-75s\n" "-" | sed 's/\s/-/g' | tee -a $log 419 | speed_test '' 'Nearby ' 420 | printf "%-75s\n" "-" | sed 's/\s/-/g' | tee -a $log 421 | speed_test '29112' 'Ukraine, Kyiv (Datagroup) ' 'http://speedtest.datagroup.ua' 422 | speed_test '30813' 'Ukraine, Kyiv (KyivStar) ' 'http://srv01-okl-kv.kyivstar.ua' 423 | speed_test '2518' 'Ukraine, Kyiv (Volia) ' 'http://speedtest2.volia.com' 424 | speed_test '14887' 'Ukraine, Lviv (UARNet) ' 'http://speedtest.uar.net' 425 | speed_test '29259' 'Ukraine, Lviv (KyivStar) ' 'http://srv01-okl-lvv.kyivstar.ua' 426 | speed_test '2445' 'Ukraine, Lviv (KOMiTEX) ' 'http://speedtest.komitex.net' 427 | speed_test '3022' 'Ukraine, Uzhgorod (TransCom) ' 'http://speedtest.tcom.uz.ua' 428 | speed_test '19332' 'Ukraine, Chernivtsi (C.T.Net) ' 'http://speedtest.ctn.cv.ua' 429 | speed_test '3861' 'Ukraine, Zhytomyr (DKS) ' 'http://speedtest1.dks.com.ua' 430 | speed_test '8633' 'Ukraine, Cherkasy (McLaut) ' 'http://speedtest2.mclaut.com' 431 | speed_test '20285' 'Ukraine, Kharkiv (Maxnet) ' 'http://speedtest.maxnet.ua' 432 | speed_test '20953' 'Ukraine, Dnipro (Trifle) ' 'http://speedtest.trifle.net' 433 | speed_test '2796' 'Ukraine, Odesa (Black Sea) ' 'http://speedtest.blacksea.net.ua' 434 | speed_test '26725' 'Ukraine, Mariupol (CityLine) ' 'http://speedtest.cl.dn.ua' 435 | speed_test '2581' 'Ukraine, Yalta (KNET) ' 'http://speedtest.knet-tele.com' 436 | 437 | rm -rf speedtest.py 438 | } 439 | 440 | print_speedtest_lviv() { 441 | echo "" | tee -a $log 442 | echostyle "## Lviv Speedtest.net" 443 | echo "" | tee -a $log 444 | printf "%-26s%-17s%-17s%-7s\n" " Location" "Upload" "Download" "Ping" | tee -a $log 445 | printf "%-75s\n" "-" | sed 's/\s/-/g' | tee -a $log 446 | speed_test '' 'Nearby ' 447 | printf "%-75s\n" "-" | sed 's/\s/-/g' | tee -a $log 448 | speed_test '14887' 'Ukraine, Lviv (UARNet) ' 'http://speedtest.uar.net' 449 | speed_test '29259' 'Ukraine, Lviv (KyivStar)' 'http://srv01-okl-lvv.kyivstar.ua' 450 | speed_test '2445' 'Ukraine, Lviv (KOMiTEX) ' 'http://speedtest.komitex.net' 451 | speed_test '12786' 'Ukraine, Lviv (ASTRA) ' 'http://speedtest.astra.in.ua' 452 | speed_test '1204' 'Ukraine, Lviv (Network) ' 'http://speedtest.network.lviv.ua' 453 | speed_test '34751' 'Ukraine, Lviv (Wenet) ' 'http://vds.wenet.lviv.ua' 454 | 455 | rm -rf speedtest.py 456 | } 457 | 458 | print_speedtest_meast() { 459 | echo "" | tee -a $log 460 | echostyle "## Middle East Speedtest.net" 461 | echo "" | tee -a $log 462 | printf "%-30s%-17s%-17s%-7s\n" " Location" "Upload" "Download" "Ping" | tee -a $log 463 | printf "%-75s\n" "-" | sed 's/\s/-/g' | tee -a $log 464 | speed_test '' 'Nearby ' 465 | printf "%-75s\n" "-" | sed 's/\s/-/g' | tee -a $log 466 | speed_test '610' 'Cyprus, Limassol (PrimeTel) ' 'http://speedtest-node.prime-tel.com' 467 | speed_test '2434' 'Israel, Haifa (013Netvision)' 'http://speed2.013.net' 468 | speed_test '16139' 'Egypt, Cairo (Telecom Egypt)' 'http://speedtestob.orange.eg' 469 | speed_test '12498' 'Lebanon, Tripoli (BItarNet) ' 'http://speedtest1.wavenet-lb.net' 470 | speed_test '22129' 'UAE, Dubai (i3D) ' 'http://ae.ap.speedtest.i3d.net' 471 | speed_test '24742' 'Qatar, Doha (Ooredoo) ' 'http://37.186.62.40' 472 | speed_test '13610' 'SA, Riyadh (ITC) ' 'http://87.101.181.146' 473 | speed_test '1912' 'Bahrain, Manama (Zain) ' 'http://62.209.25.182' 474 | speed_test '18512' 'Iran, Tehran (MCI) ' 'http://rhaspd2.mci.ir' 475 | 476 | rm -rf speedtest.py 477 | } 478 | 479 | print_speedtest_china() { 480 | echo "" | tee -a $log 481 | echostyle "## China Speedtest.net" 482 | echo "" | tee -a $log 483 | printf "%-32s%-17s%-17s%-7s\n" " Location" "Upload" "Download" "Ping" | tee -a $log 484 | printf "%-75s\n" "-" | sed 's/\s/-/g' | tee -a $log 485 | speed_test '' 'Nearby ' 486 | printf "%-75s\n" "-" | sed 's/\s/-/g' | tee -a $log 487 | speed_test '5396' 'Suzhou (China Telecom 5G) ' 'http://4gsuzhou1.speedtest.jsinfo.net' 488 | speed_test '24447' 'ShangHai (China Unicom 5G) ' 'http://5g.shunicomtest.com' 489 | speed_test '26331' 'Zhengzhou (Henan CMCC 5G) ' 'http://5ghenan.ha.chinamobile.com' 490 | speed_test '29105' 'Xi"an (China Mobile 5G) ' 'http://122.77.240.140' 491 | speed_test '4870' 'Changsha (China Unicom 5G) ' 'http://220.202.152.178' 492 | speed_test '3633' 'Shanghai (China Telecom) ' 'http://speedtest1.online.sh.cn' 493 | 494 | rm -rf speedtest.py 495 | } 496 | 497 | geekbench4() { 498 | if [[ $ARCH = *x86* ]]; then # 32-bit 499 | echo -e "\nGeekbench 4 cannot run on 32-bit architectures. Skipping the test" 500 | else 501 | echo "" | tee -a $log 502 | echo -e " Performing Geekbench v4 CPU Benchmark test. Please wait..." 503 | 504 | GEEKBENCH_PATH=$HOME/geekbench 505 | mkdir -p $GEEKBENCH_PATH 506 | curl -s https://cdn.geekbench.com/Geekbench-4.4.4-Linux.tar.gz | tar xz --strip-components=1 -C $GEEKBENCH_PATH &>/dev/null 507 | GEEKBENCH_TEST=$($GEEKBENCH_PATH/geekbench4 2>/dev/null | grep "https://browser") 508 | GEEKBENCH_URL=$(echo -e $GEEKBENCH_TEST | head -1) 509 | GEEKBENCH_URL_CLAIM=$(echo $GEEKBENCH_URL | awk '{ print $2 }') 510 | GEEKBENCH_URL=$(echo $GEEKBENCH_URL | awk '{ print $1 }') 511 | sleep 20 512 | GEEKBENCH_SCORES=$(curl -s $GEEKBENCH_URL | grep "span class='score'") 513 | GEEKBENCH_SCORES_SINGLE=$(echo $GEEKBENCH_SCORES | awk -v FS="(>|<)" '{ print $3 }') 514 | GEEKBENCH_SCORES_MULTI=$(echo $GEEKBENCH_SCORES | awk -v FS="(>|<)" '{ print $7 }') 515 | 516 | if [[ $GEEKBENCH_SCORES_SINGLE -le 1700 ]]; then 517 | grank="(POOR)" 518 | elif [[ $GEEKBENCH_SCORES_SINGLE -ge 1700 && $GEEKBENCH_SCORES_SINGLE -le 2500 ]]; then 519 | grank="(FAIR)" 520 | elif [[ $GEEKBENCH_SCORES_SINGLE -ge 2500 && $GEEKBENCH_SCORES_SINGLE -le 3500 ]]; then 521 | grank="(GOOD)" 522 | elif [[ $GEEKBENCH_SCORES_SINGLE -ge 3500 && $GEEKBENCH_SCORES_SINGLE -le 4500 ]]; then 523 | grank="(VERY GOOD)" 524 | elif [[ $GEEKBENCH_SCORES_SINGLE -ge 4500 && $GEEKBENCH_SCORES_SINGLE -le 6000 ]]; then 525 | grank="(EXCELLENT)" 526 | elif [[ $GEEKBENCH_SCORES_SINGLE -ge 6000 && $GEEKBENCH_SCORES_SINGLE -le 7000 ]]; then 527 | grank="(THE BEAST)" 528 | else 529 | grank="(MONSTER)" 530 | fi 531 | 532 | echo -ne "\e[1A"; echo -ne "\033[0K\r" 533 | echostyle "## Geekbench v4 CPU Benchmark:" 534 | echo "" | tee -a $log 535 | echo -e " Single Core : $GEEKBENCH_SCORES_SINGLE $grank" | tee -a $log 536 | echo -e " Multi Core : $GEEKBENCH_SCORES_MULTI" | tee -a $log 537 | [ ! -z "$GEEKBENCH_URL_CLAIM" ] && echo -e "$GEEKBENCH_URL_CLAIM" >> geekbench_claim.url 2> /dev/null 538 | echo "" | tee -a $log 539 | echo -e " Cooling down..." 540 | sleep 9 541 | echo -ne "\e[1A"; echo -ne "\033[0K\r" 542 | echo -e " Ready to continue..." 543 | sleep 3 544 | echo -ne "\e[1A"; echo -ne "\033[0K\r" 545 | fi 546 | } 547 | 548 | geekbench5() { 549 | if [[ $ARCH = *x86* ]]; then # 32-bit 550 | echo -e "\nGeekbench 5 cannot run on 32-bit architectures. Skipping the test" 551 | else 552 | echo "" | tee -a $log 553 | echo -e " Performing Geekbench v5 CPU Benchmark test. Please wait..." 554 | 555 | GEEKBENCH_PATH=$HOME/geekbench 556 | mkdir -p $GEEKBENCH_PATH 557 | curl -s https://cdn.geekbench.com/Geekbench-5.5.1-Linux.tar.gz | tar xz --strip-components=1 -C $GEEKBENCH_PATH &>/dev/null 558 | GEEKBENCH_TEST=$($GEEKBENCH_PATH/geekbench5 2>/dev/null | grep "https://browser") 559 | GEEKBENCH_URL=$(echo -e $GEEKBENCH_TEST | head -1) 560 | GEEKBENCH_URL_CLAIM=$(echo $GEEKBENCH_URL | awk '{ print $2 }') 561 | GEEKBENCH_URL=$(echo $GEEKBENCH_URL | awk '{ print $1 }') 562 | sleep 20 563 | GEEKBENCH_SCORES=$(curl -s $GEEKBENCH_URL | grep "div class='score'") 564 | GEEKBENCH_SCORES_SINGLE=$(echo $GEEKBENCH_SCORES | awk -v FS="(>|<)" '{ print $3 }') 565 | GEEKBENCH_SCORES_MULTI=$(echo $GEEKBENCH_SCORES | awk -v FS="(<|>)" '{ print $7 }') 566 | 567 | if [[ $GEEKBENCH_SCORES_SINGLE -le 300 ]]; then 568 | grank="(POOR)" 569 | elif [[ $GEEKBENCH_SCORES_SINGLE -ge 300 && $GEEKBENCH_SCORES_SINGLE -le 500 ]]; then 570 | grank="(FAIR)" 571 | elif [[ $GEEKBENCH_SCORES_SINGLE -ge 500 && $GEEKBENCH_SCORES_SINGLE -le 700 ]]; then 572 | grank="(GOOD)" 573 | elif [[ $GEEKBENCH_SCORES_SINGLE -ge 700 && $GEEKBENCH_SCORES_SINGLE -le 1000 ]]; then 574 | grank="(VERY GOOD)" 575 | elif [[ $GEEKBENCH_SCORES_SINGLE -ge 1000 && $GEEKBENCH_SCORES_SINGLE -le 1500 ]]; then 576 | grank="(EXCELLENT)" 577 | elif [[ $GEEKBENCH_SCORES_SINGLE -ge 1500 && $GEEKBENCH_SCORES_SINGLE -le 2000 ]]; then 578 | grank="(THE BEAST)" 579 | else 580 | grank="(MONSTER)" 581 | fi 582 | 583 | echo -ne "\e[1A"; echo -ne "\033[0K\r" 584 | echostyle "## Geekbench v5 CPU Benchmark:" 585 | echo "" | tee -a $log 586 | echo -e " Single Core : $GEEKBENCH_SCORES_SINGLE $grank" | tee -a $log 587 | echo -e " Multi Core : $GEEKBENCH_SCORES_MULTI" | tee -a $log 588 | [ ! -z "$GEEKBENCH_URL_CLAIM" ] && echo -e "$GEEKBENCH_URL_CLAIM" >> geekbench_claim.url 2> /dev/null 589 | echo "" | tee -a $log 590 | echo -e " Cooling down..." 591 | sleep 9 592 | echo -ne "\e[1A"; echo -ne "\033[0K\r" 593 | echo -e " Ready to continue..." 594 | sleep 3 595 | echo -ne "\e[1A"; echo -ne "\033[0K\r" 596 | fi 597 | } 598 | 599 | geekbench6() { 600 | if [[ $ARCH = *x86* ]]; then # 32-bit 601 | echo -e "\nGeekbench 6 cannot run on 32-bit architectures. Skipping the test" 602 | else 603 | echo "" | tee -a $log 604 | echo -e " Performing Geekbench v6 CPU Benchmark test. Please wait..." 605 | 606 | GEEKBENCH_PATH=$HOME/geekbench 607 | mkdir -p $GEEKBENCH_PATH 608 | curl -s https://cdn.geekbench.com/Geekbench-6.2.1-Linux.tar.gz | tar xz --strip-components=1 -C $GEEKBENCH_PATH &>/dev/null 609 | GEEKBENCH_TEST=$($GEEKBENCH_PATH/geekbench6 2>/dev/null | grep "https://browser") 610 | GEEKBENCH_URL=$(echo -e $GEEKBENCH_TEST | head -1) 611 | GEEKBENCH_URL_CLAIM=$(echo $GEEKBENCH_URL | awk '{ print $2 }') 612 | GEEKBENCH_URL=$(echo $GEEKBENCH_URL | awk '{ print $1 }') 613 | sleep 15 614 | GEEKBENCH_SCORES=$(curl -s $GEEKBENCH_URL | grep "div class='score'") 615 | GEEKBENCH_SCORES_SINGLE=$(echo $GEEKBENCH_SCORES | awk -v FS="(>|<)" '{ print $3 }') 616 | GEEKBENCH_SCORES_MULTI=$(echo $GEEKBENCH_SCORES | awk -v FS="(<|>)" '{ print $7 }') 617 | 618 | if [[ $GEEKBENCH_SCORES_SINGLE -le 400 ]]; then 619 | grank="(POOR)" 620 | elif [[ $GEEKBENCH_SCORES_SINGLE -ge 400 && $GEEKBENCH_SCORES_SINGLE -le 660 ]]; then 621 | grank="(FAIR)" 622 | elif [[ $GEEKBENCH_SCORES_SINGLE -ge 660 && $GEEKBENCH_SCORES_SINGLE -le 925 ]]; then 623 | grank="(GOOD)" 624 | elif [[ $GEEKBENCH_SCORES_SINGLE -ge 925 && $GEEKBENCH_SCORES_SINGLE -le 1350 ]]; then 625 | grank="(VERY GOOD)" 626 | elif [[ $GEEKBENCH_SCORES_SINGLE -ge 1350 && $GEEKBENCH_SCORES_SINGLE -le 2000 ]]; then 627 | grank="(EXCELLENT)" 628 | elif [[ $GEEKBENCH_SCORES_SINGLE -ge 2000 && $GEEKBENCH_SCORES_SINGLE -le 2600 ]]; then 629 | grank="(THE BEAST)" 630 | else 631 | grank="(MONSTER)" 632 | fi 633 | 634 | echo -ne "\e[1A"; echo -ne "\033[0K\r" 635 | echostyle "## Geekbench v6 CPU Benchmark:" 636 | echo "" | tee -a $log 637 | echo -e " Single Core : $GEEKBENCH_SCORES_SINGLE $grank" | tee -a $log 638 | echo -e " Multi Core : $GEEKBENCH_SCORES_MULTI" | tee -a $log 639 | [ ! -z "$GEEKBENCH_URL_CLAIM" ] && echo -e "$GEEKBENCH_URL_CLAIM" >> geekbench_claim.url 2> /dev/null 640 | echo "" | tee -a $log 641 | echo -e " Cooling down..." 642 | sleep 9 643 | echo -ne "\e[1A"; echo -ne "\033[0K\r" 644 | echo -e " Ready to continue..." 645 | sleep 3 646 | echo -ne "\e[1A"; echo -ne "\033[0K\r" 647 | fi 648 | } 649 | 650 | geekbench() { 651 | totalram="$( free -m | grep Mem | awk 'NR=1 {print $2}' )" 652 | if [[ $totalram -le 1000 ]]; then 653 | geekbench4 654 | elif [[ $totalram -ge 1000 && $totalram -le 2000 ]]; then 655 | geekbench5 656 | else 657 | geekbench6 658 | fi 659 | } 660 | 661 | calc_disk() { 662 | local total_size=0 663 | local array=$@ 664 | for size in ${array[@]} 665 | do 666 | [ "${size}" == "0" ] && size_t=0 || size_t=`echo ${size:0:${#size}-1}` 667 | [ "`echo ${size:(-1)}`" == "K" ] && size=0 668 | [ "`echo ${size:(-1)}`" == "M" ] && size=$( awk 'BEGIN{printf "%.1f", '$size_t' / 1024}' ) 669 | [ "`echo ${size:(-1)}`" == "T" ] && size=$( awk 'BEGIN{printf "%.1f", '$size_t' * 1024}' ) 670 | [ "`echo ${size:(-1)}`" == "G" ] && size=${size_t} 671 | total_size=$( awk 'BEGIN{printf "%.1f", '$total_size' + '$size'}' ) 672 | done 673 | echo ${total_size} 674 | } 675 | 676 | power_time() { 677 | 678 | result=$(smartctl -a $(result=$(cat /proc/mounts) && echo $(echo "$result" | awk '/data=ordered/{print $1}') | awk '{print $1}') 2>&1) && power_time=$(echo "$result" | awk '/Power_On/{print $10}') && echo "$power_time" 679 | } 680 | 681 | install_smart() { 682 | # install smartctl 683 | if [ ! -e '/usr/sbin/smartctl' ]; then 684 | echo "Installing Smartctl ..." 685 | if [ "${release}" == "centos" ]; then 686 | yum update > /dev/null 2>&1 687 | yum -y install smartmontools > /dev/null 2>&1 688 | else 689 | apt-get update > /dev/null 2>&1 690 | apt-get -y install smartmontools > /dev/null 2>&1 691 | fi 692 | fi 693 | } 694 | 695 | # test if the host has IPv4/IPv6 connectivity 696 | [[ ! -z $LOCAL_CURL ]] && IP_CHECK_CMD="curl -s -m 4" || IP_CHECK_CMD="wget -qO- -T 4" 697 | IPV4_CHECK=$((ping -4 -c 1 -W 4 ipv4.google.com >/dev/null 2>&1 && echo true) || $IP_CHECK_CMD -4 icanhazip.com 2> /dev/null) 698 | IPV6_CHECK=$((ping -6 -c 1 -W 4 ipv6.google.com >/dev/null 2>&1 && echo true) || $IP_CHECK_CMD -6 icanhazip.com 2> /dev/null) 699 | if [[ -z "$IPV4_CHECK" && -z "$IPV6_CHECK" ]]; then 700 | echo -e 701 | echo -e "Warning: Both IPv4 AND IPv6 connectivity were not detected. Check for DNS issues..." 702 | fi 703 | 704 | ip_info(){ 705 | # no jq 706 | country=$(curl -s https://ipapi.co/country_name/) 707 | city=$(curl -s https://ipapi.co/city/) 708 | asn=$(curl -s https://ipapi.co/asn/) 709 | org=$(curl -s https://ipapi.co/org/) 710 | countryCode=$(curl -s https://ipapi.co/country/) 711 | region=$(curl -s https://ipapi.co/region/) 712 | 713 | echo -e " ASN & ISP : $asn" | tee -a $log 714 | echo -e " Organization : $org" | tee -a $log 715 | echo -e " Location : $city, $country ($countryCode)" | tee -a $log 716 | echo -e " Region : $region" | tee -a $log 717 | } 718 | 719 | ip_info4(){ 720 | isp=$(python3 tools.py geoip isp) 721 | as_tmp=$(python3 tools.py geoip as) 722 | asn=$(echo $as_tmp | awk -F ' ' '{print $1}') 723 | org=$(python3 tools.py geoip org) 724 | country=$(python3 tools.py geoip country) 725 | city=$(python3 tools.py geoip city) 726 | #countryCode=$(python3 tools.py geoip countryCode) 727 | region=$(python3 tools.py geoip regionName) 728 | 729 | echo -e " Location : $country, $city ($region)" | tee -a $log 730 | #echo -e " Region : $region" | tee -a $log 731 | echo -e " ASN & ISP : $asn, $isp / $org" | tee -a $log 732 | #echo -e " Organization : $org" | tee -a $log 733 | 734 | rm -rf tools.py 735 | } 736 | 737 | machine_location(){ 738 | isp=$(python3 tools.py geoip isp) 739 | as_tmp=$(python3 tools.py geoip as) 740 | asn=$(echo $as_tmp | awk -F ' ' '{print $1}') 741 | org=$(python3 tools.py geoip org) 742 | country=$(python3 tools.py geoip country) 743 | city=$(python3 tools.py geoip city) 744 | #countryCode=$(python3 tools.py geoip countryCode) 745 | region=$(python3 tools.py geoip regionName) 746 | 747 | echo -e " Machine location: $country, $city ($region)" 748 | echo -e " ISP & ORG: $asn, $isp / $org" 749 | 750 | rm -rf tools.py 751 | } 752 | 753 | virt_check(){ 754 | if hash ifconfig 2>/dev/null; then 755 | eth=$(ifconfig) 756 | fi 757 | 758 | virtualx=$(dmesg) 2>/dev/null 759 | 760 | if grep docker /proc/1/cgroup -qa; then 761 | virtual="Docker" 762 | elif grep lxc /proc/1/cgroup -qa; then 763 | virtual="Lxc" 764 | elif grep -qa container=lxc /proc/1/environ; then 765 | virtual="Lxc" 766 | elif [[ -f /proc/user_beancounters ]]; then 767 | virtual="OpenVZ" 768 | elif [[ "$virtualx" == *kvm-clock* ]]; then 769 | virtual="KVM" 770 | elif [[ "$cname" == *KVM* ]]; then 771 | virtual="KVM" 772 | elif [[ "$virtualx" == *"VMware Virtual Platform"* ]]; then 773 | virtual="VMware" 774 | elif [[ "$virtualx" == *"Parallels Software International"* ]]; then 775 | virtual="Parallels" 776 | elif [[ "$virtualx" == *VirtualBox* ]]; then 777 | virtual="VirtualBox" 778 | elif [[ -e /proc/xen ]]; then 779 | virtual="Xen" 780 | elif [[ "$sys_manu" == *"Microsoft Corporation"* ]]; then 781 | if [[ "$sys_product" == *"Virtual Machine"* ]]; then 782 | if [[ "$sys_ver" == *"7.0"* || "$sys_ver" == *"Hyper-V" ]]; then 783 | virtual="Hyper-V" 784 | else 785 | virtual="Microsoft Virtual Machine" 786 | fi 787 | fi 788 | else 789 | virtual="Dedicated" 790 | fi 791 | } 792 | 793 | power_time_check(){ 794 | echo -ne " Power time of disk : " 795 | install_smart 796 | ptime=$(power_time) 797 | echo -e "$ptime Hours" 798 | } 799 | 800 | freedisk() { 801 | # check free space 802 | #spacename=$( df -m . | awk 'NR==2 {print $1}' ) 803 | #spacenamelength=$(echo ${spacename} | awk '{print length($0)}') 804 | #if [[ $spacenamelength -gt 20 ]]; then 805 | # freespace=$( df -m . | awk 'NR==3 {print $3}' ) 806 | #else 807 | # freespace=$( df -m . | awk 'NR==2 {print $4}' ) 808 | #fi 809 | freespace=$( df -m . | awk 'NR==2 {print $4}' ) 810 | if [[ $freespace == "" ]]; then 811 | $freespace=$( df -m . | awk 'NR==3 {print $3}' ) 812 | fi 813 | if [[ $freespace -gt 1024 ]]; then 814 | printf "%s" $((1024*2)) 815 | elif [[ $freespace -gt 512 ]]; then 816 | printf "%s" $((512*2)) 817 | elif [[ $freespace -gt 256 ]]; then 818 | printf "%s" $((256*2)) 819 | elif [[ $freespace -gt 128 ]]; then 820 | printf "%s" $((128*2)) 821 | else 822 | printf "1" 823 | fi 824 | } 825 | 826 | print_system_info() { 827 | echo -e " OS : $opsy ($lbit Bit)" | tee -a $log 828 | echo -e " Virt/Kernel : $virtual / $kern" | tee -a $log 829 | echo -e " CPU Model : $cname" | tee -a $log 830 | echo -e " CPU Cores : $cores @ $freq MHz $arch $corescache Cache" | tee -a $log 831 | echo -e " CPU Flags : $cpu_aes & $cpu_virt" | tee -a $log 832 | echo -e " Load Average : $load" | tee -a $log 833 | echo -e " Total Space : $hdd ($hddused ~$hddfree used)" | tee -a $log 834 | echo -e " Total RAM : $tram MB ($uram MB + $bram MB Buff in use)" | tee -a $log 835 | echo -e " Total SWAP : $swap MB ($uswap MB in use)" | tee -a $log 836 | [[ -z "$IPV4_CHECK" ]] && ONLINE="\xE2\x9D\x8C Offline / " || ONLINE="\xE2\x9C\x94 Online / " 837 | [[ -z "$IPV6_CHECK" ]] && ONLINE+="\xE2\x9D\x8C Offline" || ONLINE+="\xE2\x9C\x94 Online" 838 | echo -e " IPv4/IPv6 : $ONLINE" | tee -a $log 839 | echo -e " Uptime : $up" | tee -a $log 840 | printf "%-75s\n" "-" | sed 's/\s/-/g' | tee -a $log 841 | } 842 | 843 | get_system_info() { 844 | cname=$( awk -F: '/model name/ {name=$2} END {print name}' /proc/cpuinfo | sed 's/^[ \t]*//;s/[ \t]*$//' ) 845 | cores=$( awk -F: '/model name/ {core++} END {print core}' /proc/cpuinfo ) 846 | freq=$( awk -F: '/cpu MHz/ {freq=$2} END {print freq}' /proc/cpuinfo | sed 's/^[ \t]*//;s/[ \t]*$//' ) 847 | corescache=$( awk -F: '/cache size/ {cache=$2} END {print cache}' /proc/cpuinfo | sed 's/^[ \t]*//;s/[ \t]*$//' ) 848 | cpu_aes=$(cat /proc/cpuinfo | grep aes) 849 | [[ -z "$cpu_aes" ]] && cpu_aes="AES-NI Disabled" || cpu_aes="AES-NI Enabled" 850 | cpu_virt=$(cat /proc/cpuinfo | grep 'vmx\|svm') 851 | [[ -z "$cpu_virt" ]] && cpu_virt="VM-x/AMD-V Disabled" || cpu_virt="VM-x/AMD-V Enabled" 852 | tram=$( free -m | awk '/Mem/ {print $2}' ) 853 | uram=$( free -m | awk '/Mem/ {print $3}' ) 854 | bram=$( free -m | awk '/Mem/ {print $6}' ) 855 | swap=$( free -m | awk '/Swap/ {print $2}' ) 856 | uswap=$( free -m | awk '/Swap/ {print $3}' ) 857 | up=$( awk '{a=$1/86400;b=($1%86400)/3600;c=($1%3600)/60} {printf("%d days %d:%d\n",a,b,c)}' /proc/uptime ) 858 | load=$( w | head -1 | awk -F'load average:' '{print $2}' | sed 's/^[ \t]*//;s/[ \t]*$//' ) 859 | opsy=$( get_opsy ) 860 | arch=$( uname -m ) 861 | lbit=$( getconf LONG_BIT ) 862 | kern=$( uname -r ) 863 | #ipv6=$( wget -qO- -t1 -T2 ipv6.icanhazip.com ) 864 | #disk_size1=($( LANG=C df -hPl | grep -wvE '\-|none|tmpfs|overlay|shm|udev|devtmpfs|by-uuid|chroot|Filesystem' | awk '{print $2}' )) 865 | #disk_size2=($( LANG=C df -hPl | grep -wvE '\-|none|tmpfs|overlay|shm|udev|devtmpfs|by-uuid|chroot|Filesystem' | awk '{print $3}' )) 866 | #disk_total_size=$( calc_disk ${disk_size1[@]} ) 867 | #disk_used_size=$( calc_disk ${disk_size2[@]} ) 868 | hdd=$(df -t simfs -t ext2 -t ext3 -t ext4 -t btrfs -t xfs -t vfat -t ntfs -t swap --total -h | grep total | awk '{ print $2 }') 869 | hddused=$(df -t simfs -t ext2 -t ext3 -t ext4 -t btrfs -t xfs -t vfat -t ntfs -t swap --total -h | grep total | awk '{ print $3 }') 870 | hddfree=$(df -t simfs -t ext2 -t ext3 -t ext4 -t btrfs -t xfs -t vfat -t ntfs -t swap --total -h | grep total | awk '{ print $5 }') 871 | #tcp congestion control 872 | #tcpctrl=$( sysctl net.ipv4.tcp_congestion_control | awk -F ' ' '{print $3}' ) 873 | 874 | #tmp=$(python3 tools.py disk 0) 875 | #disk_total_size=$(echo $tmp | sed s/G//) 876 | #tmp=$(python3 tools.py disk 1) 877 | #disk_used_size=$(echo $tmp | sed s/G//) 878 | 879 | virt_check 880 | } 881 | 882 | write_test() { 883 | (LANG=C dd if=/dev/zero of=test_file_$$ bs=512K count=$1 conv=fdatasync && rm -f test_file_$$ ) 2>&1 | awk -F, '{io=$NF} END { print io}' | sed 's/^[ \t]*//;s/[ \t]*$//' 884 | } 885 | 886 | averageio() { 887 | ioraw1=$( echo $1 | awk 'NR==1 {print $1}' ) 888 | [ "$(echo $1 | awk 'NR==1 {print $2}')" == "GB/s" ] && ioraw1=$( awk 'BEGIN{print '$ioraw1' * 1024}' ) 889 | ioraw2=$( echo $2 | awk 'NR==1 {print $1}' ) 890 | [ "$(echo $2 | awk 'NR==1 {print $2}')" == "GB/s" ] && ioraw2=$( awk 'BEGIN{print '$ioraw2' * 1024}' ) 891 | ioraw3=$( echo $3 | awk 'NR==1 {print $1}' ) 892 | [ "$(echo $3 | awk 'NR==1 {print $2}')" == "GB/s" ] && ioraw3=$( awk 'BEGIN{print '$ioraw3' * 1024}' ) 893 | ioall=$( awk 'BEGIN{print '$ioraw1' + '$ioraw2' + '$ioraw3'}' ) 894 | ioavg=$( awk 'BEGIN{printf "%.1f", '$ioall' / 3}' ) 895 | printf "%s" "$ioavg" 896 | } 897 | 898 | cpubench() { 899 | if hash $1 2>$NULL; then 900 | io=$( ( dd if=/dev/zero bs=512K count=$2 | $1 ) 2>&1 | grep 'copied' | awk -F, '{io=$NF} END {print io}' ) 901 | if [[ $io != *"."* ]]; then 902 | printf "%4i %s" "${io% *}" "${io##* }" 903 | else 904 | printf "%4i.%s" "${io%.*}" "${io#*.}" 905 | fi 906 | else 907 | printf " %s not found on system." "$1" 908 | fi 909 | } 910 | 911 | iotest() { 912 | echostyle "## IO Test" 913 | echo "" | tee -a $log 914 | 915 | # start testing 916 | writemb=$(freedisk) 917 | if [[ $writemb -gt 512 ]]; then 918 | writemb_size="$(( writemb / 2 / 2 ))MB" 919 | writemb_cpu="$(( writemb / 2 ))" 920 | else 921 | writemb_size="$writemb"MB 922 | writemb_cpu=$writemb 923 | fi 924 | 925 | # CPU Speed test 926 | echostyle "CPU Speed:" 927 | echo " bzip2 :$( cpubench bzip2 $writemb_cpu )" | tee -a $log 928 | echo " sha256 :$( cpubench sha256sum $writemb_cpu )" | tee -a $log 929 | echo " md5sum :$( cpubench md5sum $writemb_cpu )" | tee -a $log 930 | echo "" | tee -a $log 931 | 932 | # RAM Speed test 933 | # set ram allocation for mount 934 | tram_mb="$( free -m | grep Mem | awk 'NR=1 {print $2}' )" 935 | if [[ tram_mb -gt 1900 ]]; then 936 | sbram=1024M 937 | sbcount=2048 938 | else 939 | sbram=$(( tram_mb / 2 ))M 940 | sbcount=$tram_mb 941 | fi 942 | [[ -d $benchram ]] || mkdir $benchram 943 | mount -t tmpfs -o size=$sbram tmpfs $benchram/ 944 | echostyle "RAM Speed:" 945 | iow1=$( ( dd if=/dev/zero of=$benchram/zero bs=512K count=$sbcount ) 2>&1 | awk -F, '{io=$NF} END { print io}' ) 946 | ior1=$( ( dd if=$benchram/zero of=$NULL bs=512K count=$sbcount; rm -f test ) 2>&1 | awk -F, '{io=$NF} END { print io}' ) 947 | iow2=$( ( dd if=/dev/zero of=$benchram/zero bs=512K count=$sbcount ) 2>&1 | awk -F, '{io=$NF} END { print io}' ) 948 | ior2=$( ( dd if=$benchram/zero of=$NULL bs=512K count=$sbcount; rm -f test ) 2>&1 | awk -F, '{io=$NF} END { print io}' ) 949 | iow3=$( ( dd if=/dev/zero of=$benchram/zero bs=512K count=$sbcount ) 2>&1 | awk -F, '{io=$NF} END { print io}' ) 950 | ior3=$( ( dd if=$benchram/zero of=$NULL bs=512K count=$sbcount; rm -f test ) 2>&1 | awk -F, '{io=$NF} END { print io}' ) 951 | echo " Avg. write : $(averageio "$iow1" "$iow2" "$iow3") MB/s" | tee -a $log 952 | echo " Avg. read : $(averageio "$ior1" "$ior2" "$ior3") MB/s" | tee -a $log 953 | rm $benchram/zero 954 | umount $benchram 955 | rm -rf $benchram 956 | echo "" | tee -a $log 957 | 958 | # Disk test 959 | #echostyle "Disk Speed:" 960 | #if [[ $writemb != "1" ]]; then 961 | # io=$( ( dd bs=512K count=$writemb if=/dev/zero of=test; rm -f test ) 2>&1 | awk -F, '{io=$NF} END { print io}' ) 962 | # echo " I/O Speed :$io" | tee -a $log 963 | 964 | # io=$( ( dd bs=512K count=$writemb if=/dev/zero of=test oflag=direct; rm -f test ) 2>&1 | awk -F, '{io=$NF} END { print io}' ) 965 | # echo " I/O Direct :$io" | tee -a $log 966 | #else 967 | # echo " Not enough space to test." | tee -a $log 968 | #fi 969 | #echo "" | tee -a $log 970 | } 971 | 972 | 973 | write_io() { 974 | writemb=$(freedisk) 975 | writemb_size="$(( writemb / 2 ))MB" 976 | if [[ $writemb_size == "1024MB" ]]; then 977 | writemb_size="1.0GB" 978 | fi 979 | 980 | if [[ $writemb != "1" ]]; then 981 | echostyle "Disk Speed:" 982 | echo -n " 1st run : " | tee -a $log 983 | io1=$( write_test $writemb ) 984 | echo -e "$io1" | tee -a $log 985 | echo -n " 2nd run : " | tee -a $log 986 | io2=$( write_test $writemb ) 987 | echo -e "$io2" | tee -a $log 988 | echo -n " 3rd run : " | tee -a $log 989 | io3=$( write_test $writemb ) 990 | echo -e "$io3" | tee -a $log 991 | ioraw1=$( echo $io1 | awk 'NR==1 {print $1}' ) 992 | [ "`echo $io1 | awk 'NR==1 {print $2}'`" == "GB/s" ] && ioraw1=$( awk 'BEGIN{print '$ioraw1' * 1024}' ) 993 | ioraw2=$( echo $io2 | awk 'NR==1 {print $1}' ) 994 | [ "`echo $io2 | awk 'NR==1 {print $2}'`" == "GB/s" ] && ioraw2=$( awk 'BEGIN{print '$ioraw2' * 1024}' ) 995 | ioraw3=$( echo $io3 | awk 'NR==1 {print $1}' ) 996 | [ "`echo $io3 | awk 'NR==1 {print $2}'`" == "GB/s" ] && ioraw3=$( awk 'BEGIN{print '$ioraw3' * 1024}' ) 997 | ioall=$( awk 'BEGIN{print '$ioraw1' + '$ioraw2' + '$ioraw3'}' ) 998 | ioavg=$( awk 'BEGIN{printf "%.1f", '$ioall' / 3}' ) 999 | echo -e " -----------------------" | tee -a $log 1000 | echo -e " Average : $ioavg MB/s" | tee -a $log 1001 | else 1002 | echo -e " Not enough space!" 1003 | fi 1004 | } 1005 | 1006 | print_end_time() { 1007 | echo "" | tee -a $log 1008 | end=$(date +%s) 1009 | time=$(( $end - $start )) 1010 | if [[ $time -gt 60 ]]; then 1011 | min=$(expr $time / 60) 1012 | sec=$(expr $time % 60) 1013 | echo -ne " Finished in : ${min} min ${sec} sec" 1014 | else 1015 | echo -ne " Finished in : ${time} sec" 1016 | fi 1017 | #echo -ne "\n Current time : " 1018 | #echo $(date +%Y-%m-%d" "%H:%M:%S) 1019 | printf '\n' 1020 | utc_time=$(date -u '+%F %T') 1021 | echo " Timestamp : $utc_time GMT" | tee -a $log 1022 | #echo " Finished!" 1023 | echo " Saved in : $log" 1024 | echo "" | tee -a $log 1025 | } 1026 | 1027 | print_intro() { 1028 | printf "%-75s\n" "-" | sed 's/\s/-/g' 1029 | printf ' Region: %s https://bench.monster '$bench_v' '$bench_d' \n' $region_name | tee -a $log 1030 | printf " Usage : curl -sL bench.monster | bash -s -- -%s\n" $region_name | tee -a $log 1031 | } 1032 | 1033 | sharetest() { 1034 | echo " Share results:" 1035 | echo " - $result_speed" | tee -a $log 1036 | log_preupload 1037 | case $1 in 1038 | #'ubuntu') 1039 | # share_link=$( curl -v --data-urlencode "content@$log_up" -d "poster=speedtest.sh" -d "syntax=text" "https://paste.ubuntu.com" 2>&1 | \ 1040 | # grep "Location" | awk '{print "https://paste.ubuntu.com"$3}' );; 1041 | #'haste' ) 1042 | # share_link=$( curl -X POST -s -d "$(cat $log)" https://hastebin.com/documents | awk -F '"' '{print "https://hastebin.com/"$4}' );; 1043 | #'clbin' ) 1044 | # share_link=$( curl -sF 'clbin=<-' https://clbin.com < $log );; 1045 | #sprunge_link=$(curl -sF 'sprunge=<-' https://sprunge.us < $log);; 1046 | esac 1047 | 1048 | # Replace "http://" with "https://" 1049 | #share_link=$(echo "$sprunge_link" | sed 's/http:/https:/') 1050 | 1051 | # print result info 1052 | echo " - $GEEKBENCH_URL" | tee -a $log 1053 | #echo " - $share_link" 1054 | echo "" 1055 | rm -f $log_up 1056 | 1057 | } 1058 | 1059 | log_preupload() { 1060 | log_up="$HOME/speedtest_upload.log" 1061 | true > $log_up 1062 | $(cat speedtest.log 2>&1 | sed -r "s/\x1B\[([0-9]{1,2}(;[0-9]{1,2})?)?[m|K]//g" > $log_up) 1063 | } 1064 | 1065 | get_ip_whois_org_name(){ 1066 | #ip=$(curl -s ip.sb) 1067 | result=$(curl -s https://rest.db.ripe.net/search.json?query-string=$(curl -s ip.sb)) 1068 | #org_name=$(echo $result | jq '.objects.object.[1].attributes.attribute.[1].value' | sed 's/\"//g') 1069 | org_name=$(echo $result | jq '.objects.object[1].attributes.attribute[1]' | sed 's/\"//g') 1070 | echo $org_name; 1071 | } 1072 | 1073 | pingtest() { 1074 | local ping_link=$( echo ${1#*//} | cut -d"/" -f1 ) 1075 | local ping_ms=$( ping -w 1 -c 1 -q $ping_link | grep 'rtt' | cut -d"/" -f5 ) 1076 | 1077 | # get download speed and print 1078 | if [[ $ping_ms == "" ]]; then 1079 | printf "ping error!" 1080 | else 1081 | printf "%3i.%s ms" "${ping_ms%.*}" "${ping_ms#*.}" 1082 | fi 1083 | } 1084 | 1085 | pingtest() { 1086 | local ping_link=$(echo ${1#*//} | cut -d"/" -f1) 1087 | 1088 | # Send three pings and capture the output 1089 | local ping_output=$(ping -w 1 -c 3 -q $ping_link | grep 'rtt') 1090 | 1091 | # Extract the avg value from the output 1092 | local ping_avg=$(echo "$ping_output" | awk -F'/' '{print $6}') 1093 | 1094 | # get download speed and print 1095 | if [[ $ping_avg == "" ]]; then 1096 | printf "ping error!" 1097 | else 1098 | printf "%d.%s ms" "${ping_avg%.*}" "${ping_avg#*.}" 1099 | fi 1100 | } 1101 | 1102 | cleanup() { 1103 | rm -f test_file_*; 1104 | rm -f speedtest.py; 1105 | rm -f speedtest.sh; 1106 | rm -f tools.py; 1107 | rm -f ip_json.json; 1108 | rm -f geekbench_claim.url; 1109 | rm -rf geekbench; 1110 | } 1111 | 1112 | bench_all(){ 1113 | region_name="Global" 1114 | print_intro; 1115 | benchinit; 1116 | next; 1117 | get_system_info; 1118 | print_system_info; 1119 | ip_info4; 1120 | next; 1121 | geekbench; 1122 | iotest; 1123 | write_io; 1124 | print_speedtest; 1125 | next; 1126 | print_end_time; 1127 | cleanup; 1128 | sharetest clbin; 1129 | } 1130 | 1131 | usa_bench(){ 1132 | region_name="USA" 1133 | print_intro; 1134 | benchinit; 1135 | next; 1136 | get_system_info; 1137 | print_system_info; 1138 | ip_info4; 1139 | next; 1140 | geekbench; 1141 | iotest; 1142 | write_io; 1143 | print_speedtest_usa; 1144 | next; 1145 | print_end_time; 1146 | cleanup; 1147 | sharetest clbin; 1148 | } 1149 | 1150 | in_bench(){ 1151 | region_name="India" 1152 | print_intro; 1153 | benchinit; 1154 | next; 1155 | get_system_info; 1156 | print_system_info; 1157 | ip_info4; 1158 | next; 1159 | geekbench; 1160 | iotest; 1161 | write_io; 1162 | print_speedtest_in; 1163 | next; 1164 | print_end_time; 1165 | cleanup; 1166 | sharetest clbin; 1167 | } 1168 | 1169 | europe_bench(){ 1170 | region_name="Europe" 1171 | print_intro; 1172 | benchinit; 1173 | next; 1174 | get_system_info; 1175 | print_system_info; 1176 | ip_info4; 1177 | next; 1178 | geekbench; 1179 | iotest; 1180 | write_io; 1181 | print_speedtest_europe; 1182 | next; 1183 | print_end_time; 1184 | cleanup; 1185 | sharetest clbin; 1186 | } 1187 | 1188 | asia_bench(){ 1189 | region_name="Asia" 1190 | print_intro; 1191 | benchinit; 1192 | next; 1193 | get_system_info; 1194 | print_system_info; 1195 | ip_info4; 1196 | next; 1197 | geekbench; 1198 | iotest; 1199 | write_io; 1200 | print_speedtest_asia; 1201 | next; 1202 | print_end_time; 1203 | cleanup; 1204 | sharetest clbin; 1205 | } 1206 | 1207 | china_bench(){ 1208 | region_name="China" 1209 | print_intro; 1210 | benchinit; 1211 | next; 1212 | get_system_info; 1213 | print_system_info; 1214 | ip_info4; 1215 | next; 1216 | geekbench; 1217 | iotest; 1218 | write_io; 1219 | print_speedtest_china; 1220 | next; 1221 | print_end_time; 1222 | cleanup; 1223 | sharetest clbin; 1224 | } 1225 | 1226 | sa_bench(){ 1227 | region_name="South-America" 1228 | print_intro; 1229 | benchinit; 1230 | next; 1231 | get_system_info; 1232 | print_system_info; 1233 | ip_info4; 1234 | next; 1235 | geekbench; 1236 | iotest; 1237 | write_io; 1238 | print_speedtest_sa; 1239 | next; 1240 | print_end_time; 1241 | cleanup; 1242 | sharetest clbin; 1243 | } 1244 | 1245 | au_bench(){ 1246 | region_name="AU-NZ" 1247 | print_intro; 1248 | benchinit; 1249 | next; 1250 | get_system_info; 1251 | print_system_info; 1252 | ip_info4; 1253 | next; 1254 | geekbench; 1255 | iotest; 1256 | write_io; 1257 | print_speedtest_au; 1258 | next; 1259 | print_end_time; 1260 | cleanup; 1261 | sharetest clbin; 1262 | } 1263 | 1264 | ukraine_bench(){ 1265 | region_name="Ukraine" 1266 | print_intro; 1267 | benchinit; 1268 | next; 1269 | get_system_info; 1270 | print_system_info; 1271 | ip_info4; 1272 | next; 1273 | geekbench; 1274 | iotest; 1275 | write_io; 1276 | print_speedtest_ukraine; 1277 | next; 1278 | print_end_time; 1279 | cleanup; 1280 | sharetest clbin; 1281 | } 1282 | lviv_bench(){ 1283 | region_name="Lviv" 1284 | print_intro; 1285 | benchinit; 1286 | next; 1287 | get_system_info; 1288 | print_system_info; 1289 | ip_info4; 1290 | next; 1291 | geekbench; 1292 | iotest; 1293 | write_io; 1294 | print_speedtest_lviv; 1295 | next; 1296 | print_end_time; 1297 | cleanup; 1298 | sharetest clbin; 1299 | } 1300 | meast_bench(){ 1301 | region_name="Middle-East" 1302 | print_intro; 1303 | benchinit; 1304 | next; 1305 | get_system_info; 1306 | print_system_info; 1307 | ip_info4; 1308 | next; 1309 | geekbench; 1310 | iotest; 1311 | write_io; 1312 | print_speedtest_meast; 1313 | next; 1314 | print_end_time; 1315 | cleanup; 1316 | sharetest clbin; 1317 | } 1318 | 1319 | log="$HOME/speedtest.log" 1320 | true > $log 1321 | 1322 | case $1 in 1323 | 'info'|'i'|'-i'|'--i'|'-info'|'--info' ) 1324 | about;sleep 3;next;get_system_info;print_system_info;next;cleanup;; 1325 | 'version'|'v'|'-v'|'--v'|'-version'|'--version') 1326 | next;about;next;cleanup;; 1327 | 'gb4'|'-gb4'|'--gb4'|'geek4'|'-geek4'|'--geek4' ) 1328 | next;geekbench4;next;cleanup;; 1329 | 'gb5'|'-gb5'|'--gb5'|'geek5'|'-geek5'|'--geek5' ) 1330 | next;geekbench5;next;cleanup;; 1331 | 'gb6'|'-gb6'|'--gb6'|'geek6'|'-geek6'|'--geek6' ) 1332 | next;geekbench6;next;cleanup;; 1333 | 'gb'|'-gb'|'--gb'|'geek'|'-geek'|'--geek' ) 1334 | next;geekbench;next;cleanup;; 1335 | 'io'|'-io'|'--io'|'ioping'|'-ioping'|'--ioping' ) 1336 | next;iotest;write_io;next;cleanup;; 1337 | 'speed'|'-speed'|'--speed'|'-speedtest'|'--speedtest'|'-speedcheck'|'--speedcheck' ) 1338 | about;benchinit;machine_location;print_speedtest;next;cleanup;; 1339 | 'usas'|'-usas'|'uss'|'-uss'|'uspeed'|'-uspeed' ) 1340 | about;benchinit;machine_location;print_speedtest_usa;next;cleanup;; 1341 | 'eus'|'-eus'|'es'|'-es'|'espeed'|'-espeed' ) 1342 | about;benchinit;machine_location;print_speedtest_europe;next;cleanup;; 1343 | 'as'|'-as'|'aspeed'|'-aspeed' ) 1344 | about;benchinit;machine_location;print_speedtest_asia;next;cleanup;; 1345 | 'aus'|'-aus'|'auspeed'|'-auspeed' ) 1346 | about;benchinit;machine_location;print_speedtest_au;next;cleanup;; 1347 | 'sas'|'-sas'|'saspeed'|'-saspeed' ) 1348 | about;benchinit;machine_location;print_speedtest_sa;next;cleanup;; 1349 | 'mes'|'-mes'|'mespeed'|'-mespeed' ) 1350 | about;benchinit;machine_location;print_speedtest_meast;next;cleanup;; 1351 | 'ins'|'-ins'|'inspeed'|'-inspeed' ) 1352 | about;benchinit;machine_location;print_speedtest_in;next;cleanup;; 1353 | 'cns'|'-cns'|'cnspeed'|'-cnspeed' ) 1354 | about;benchinit;machine_location;print_speedtest_china;next;cleanup;; 1355 | 'uas'|'-uas'|'uaspeed'|'-uaspeed' ) 1356 | about;benchinit;machine_location;print_speedtest_ukraine;next;cleanup;; 1357 | 'lvivs'|'-lvivs' ) 1358 | about;benchinit;machine_location;print_speedtest_lviv;next;cleanup;; 1359 | 'ip'|'-ip'|'--ip'|'geoip'|'-geoip'|'--geoip' ) 1360 | about;benchinit;next;ip_info4;next;cleanup;; 1361 | 'a'|'-a'|'about'|'-about'|'--about' ) 1362 | about;next;cleanup;; 1363 | 'all'|'-all'|'bench'|'-bench'|'--bench'|'-Global' ) 1364 | bench_all;; 1365 | 'usa'|'-usa'|'--usa'|'us'|'-us'|'--us'|'USA'|'-USA'|'--USA' ) 1366 | usa_bench;; 1367 | 'in'|'-india'|'--in'|'in'|'-in'|'IN'|'-IN'|'--IN' ) 1368 | in_bench;; 1369 | 'europe'|'-europe'|'--europe'|'eu'|'-eu'|'--eu'|'Europe'|'-Europe'|'--Europe' ) 1370 | europe_bench;; 1371 | 'asia'|'-asia'|'--asia'|'Asia'|'-Asia'|'--Asia' ) 1372 | asia_bench;; 1373 | 'china'|'-china'|'--china'|'mjj'|'-mjj'|'cn'|'-cn'|'--cn'|'China'|'-China'|'--China' ) 1374 | china_bench;; 1375 | 'au'|'-au'|'nz'|'-nz'|'AU'|'-AU'|'NZ'|'-NZ'|'-AU-NZ' ) 1376 | au_bench;; 1377 | 'sa'|'-sa'|'--sa'|'-South-America' ) 1378 | sa_bench;; 1379 | 'ukraine'|'-ukraine'|'--ukraine'|'ua'|'-ua'|'--ua'|'ukr'|'-ukr'|'--ukr'|'Ukraine'|'-Ukraine'|'--Ukraine' ) 1380 | ukraine_bench;; 1381 | 'lviv'|'-lviv'|'--lviv'|'-Lviv'|'--Lviv' ) 1382 | lviv_bench;; 1383 | 'M-East'|'-M-East'|'--M-East'|'-m-east'|'--m-east'|'-meast'|'--meast'|'-Middle-East'|'-me' ) 1384 | meast_bench;; 1385 | '-s'|'--s'|'share'|'-share'|'--share' ) 1386 | bench_all; 1387 | is_share="share" 1388 | if [[ $2 == "" ]]; then 1389 | sharetest ubuntu; 1390 | else 1391 | sharetest $2; 1392 | fi 1393 | ;; 1394 | 'debug'|'-d'|'--d'|'-debug'|'--debug' ) 1395 | get_ip_whois_org_name;; 1396 | *) 1397 | bench_all;; 1398 | esac 1399 | 1400 | 1401 | 1402 | if [[ ! $is_share == "share" ]]; then 1403 | case $2 in 1404 | 'share'|'-s'|'--s'|'-share'|'--share' ) 1405 | if [[ $3 == '' ]]; then 1406 | sharetest ubuntu; 1407 | else 1408 | sharetest $3; 1409 | fi 1410 | ;; 1411 | esac 1412 | fi 1413 | -------------------------------------------------------------------------------- /tools.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env python 2 | # -*- coding: UTF-8 -*- 3 | 4 | import time 5 | import urllib.request 6 | import json 7 | import sys 8 | import shlex 9 | import datetime 10 | import subprocess 11 | 12 | def GetIpipInfo(para): 13 | with open("ip_json.json", 'r') as f: 14 | ijson = json.load(f) 15 | jjson = ijson['location'] 16 | print(jjson[para]) 17 | 18 | def GetGeoioInfo(para): 19 | with urllib.request.urlopen('http://ip-api.com/json') as ip_api: 20 | ijson = json.loads(ip_api.read().decode('utf-8')) 21 | print(ijson[para]) 22 | 23 | def GetDiskInfo(para): 24 | temp = ExecShell("df -h -P|grep '/'|grep -v tmpfs")[0] 25 | temp1 = temp.split('\n') 26 | diskInfo = [] 27 | n = 0 28 | cuts = ['/mnt/cdrom', '/boot', '/boot/efi', '/dev', '/dev/shm', '/run/lock', '/run', '/run/shm', '/run/user'] 29 | for tmp in temp1: 30 | n += 1 31 | disk = tmp.split() 32 | if len(disk) < 5: 33 | continue 34 | if 'M' in disk[1]: 35 | continue 36 | if 'K' in disk[1]: 37 | continue 38 | if len(disk[5].split('/')) > 4: 39 | continue 40 | if disk[5] in cuts: 41 | continue 42 | arr = {} 43 | diskInfo = [disk[1], disk[2], disk[3], disk[4], disk[5]] 44 | 45 | print(diskInfo[int(para)]) 46 | 47 | def ExecShell(cmdstring, cwd=None, timeout=None, shell=True): 48 | if shell: 49 | cmdstring_list = cmdstring 50 | else: 51 | cmdstring_list = shlex.split(cmdstring) 52 | if timeout: 53 | end_time = datetime.datetime.now() + datetime.timedelta(seconds=timeout) 54 | 55 | sub = subprocess.Popen(cmdstring_list, cwd=cwd, stdin=subprocess.PIPE, shell=shell, bufsize=4096, 56 | stdout=subprocess.PIPE, stderr=subprocess.PIPE) 57 | 58 | while sub.poll() is None: 59 | time.sleep(0.1) 60 | if timeout: 61 | if end_time <= datetime.datetime.now(): 62 | raise Exception("Timeout:%s" % cmdstring) 63 | 64 | return sub.communicate() 65 | 66 | if __name__ == "__main__": 67 | _type = sys.argv[1] 68 | if _type == 'disk': 69 | GetDiskInfo(sys.argv[2]) 70 | elif _type == 'geoip': 71 | GetGeoioInfo(sys.argv[2]) 72 | elif _type == 'ipip': 73 | GetIpipInfo(sys.argv[2]) 74 | else: 75 | print('ERROR: Parameter error') 76 | --------------------------------------------------------------------------------