网站怎么更新内容,wordpress调整语言,哪家外贸网站做的好,无锡新区做网站公司前言#xff1a;以上脚本为今年8月1号发布的#xff0c;当时是没有任何问题#xff0c;但现在脚本里网络速度测试py文件获取不了了#xff0c;测速这块功能目前无法实现#xff0c;后面我会抽时间来研究#xff0c;大家如果有建议也可以分享下。 脚本内容#xff1a;
#…前言以上脚本为今年8月1号发布的当时是没有任何问题但现在脚本里网络速度测试py文件获取不了了测速这块功能目前无法实现后面我会抽时间来研究大家如果有建议也可以分享下。 脚本内容
#!/usr/bin/env bash
#
#
#
#RED\033[0;31m
GREEN\033[0;32m
YELLOW\033[0;33m
SKYBLUE\033[0;36m
PLAIN\033[0mabout() {echo echo echo \ Superbench.sh Script / echo \ Basic system info, I/O test and speedtest / echo \ v1.1.7 (7 Apr 2024) / echo \ Created by Oldking / echo echo echo Intro: https://www.oldking.net/350.htmlecho Copyright (C) 2024 Oldking oooldkinggmail.comecho
}cancel() {echo next;echo Abort ...echo Cleanup ...cleanup;echo Doneexit
}trap cancel SIGINTbenchinit() {if [ -f /etc/redhat-release ]; thenreleasecentoselif cat /etc/issue | grep -Eqi debian; thenreleasedebianelif cat /etc/issue | grep -Eqi ubuntu; thenreleaseubuntuelif cat /etc/issue | grep -Eqi centos|red hat|redhat; thenreleasecentoselif cat /proc/version | grep -Eqi debian; thenreleasedebianelif cat /proc/version | grep -Eqi ubuntu; thenreleaseubuntuelif cat /proc/version | grep -Eqi centos|red hat|redhat; thenreleasecentosfi[[ $EUID -ne 0 ]] echo -e ${RED}Error:${PLAIN} This script must be run as root! exit 1if [ ! -e /usr/bin/python ]; thenecho Installing Python ...if [ ${release} centos ]; thenyum update /dev/null 21yum -y install python /dev/null 21elseapt-get update /dev/null 21apt-get -y install python /dev/null 21fifiif [ ! -e /usr/bin/curl ]; thenecho Installing Curl ...if [ ${release} centos ]; thenyum update /dev/null 21yum -y install curl /dev/null 21elseapt-get update /dev/null 21apt-get -y install curl /dev/null 21fifiif [ ! -e /usr/bin/wget ]; thenecho Installing Wget ...if [ ${release} centos ]; thenyum update /dev/null 21yum -y install wget /dev/null 21elseapt-get update /dev/null 21apt-get -y install wget /dev/null 21fifiif [ ! -e ./speedtest-cli/speedtest ]; thenecho Installing Speedtest-cli ...wget --no-check-certificate -qO speedtest.tgz https://cdn.jsdelivr.net/gh/oooldking/script1.1.7/speedtest_cli/ookla-speedtest-1.0.0-$(uname -m)-linux.tgz /dev/null 21fimkdir -p speedtest-cli tar zxvf speedtest.tgz -C ./speedtest-cli/ /dev/null 21 chmod arx ./speedtest-cli/speedtestif [ ! -e tools.py ]; thenecho Installing tools.py ...wget --no-check-certificate https://cdn.jsdelivr.net/gh/oooldking/script1.1.7/tools.py /dev/null 21fichmod arx tools.pyif [ ! -e fast_com.py ]; thenecho Installing Fast.com-cli ...wget --no-check-certificate https://cdn.jsdelivr.net/gh/sanderjo/fast.commaster/fast_com.py /dev/null 21wget --no-check-certificate https://cdn.jsdelivr.net/gh/sanderjo/fast.commaster/fast_com_example_usage.py /dev/null 21fichmod arx fast_com.pychmod arx fast_com_example_usage.pysleep 5start$(date %s)
}get_opsy() {[ -f /etc/redhat-release ] awk {print ($1,$3~/^[0-9]/?$3:$4)} /etc/redhat-release return[ -f /etc/os-release ] awk -F[ ] /PRETTY_NAME/{print $3,$4,$5} /etc/os-release return[ -f /etc/lsb-release ] awk -F[] /DESCRIPTION/{print $2} /etc/lsb-release return
}next() {printf %-70s\n - | sed s/\s/-/g | tee -a $log
}speed_test(){if [[ $1 ]]; thenspeedtest-cli/speedtest -p no --accept-license $speedLog 21is_upload$(cat $speedLog | grep Upload)result_speed$(cat $speedLog | awk -F /Result/{print $3})if [[ ${is_upload} ]]; thenlocal REDownload$(cat $speedLog | awk -F /Download/{print $3})local reupload$(cat $speedLog | awk -F /Upload/{print $3})local relatency$(cat $speedLog | awk -F /Latency/{print $2})temp$(echo $relatency | awk -F . {print $1})if [[ ${temp} -gt 50 ]]; thenrelatency(*)${relatency}filocal nodeName$2temp$(echo ${REDownload} | awk -F {print $1})if [[ $(awk -v num1${temp} -v num20 BEGIN{print(num1num2)?1:0}) -eq 1 ]]; thenprintf ${YELLOW}%-18s${GREEN}%-18s${RED}%-20s${SKYBLUE}%-12s${PLAIN}\n ${nodeName} ${reupload} Mbit/s ${REDownload} Mbit/s ${relatency} ms | tee -a $logfielselocal cerrorERRORfielsespeedtest-cli/speedtest -p no -s $1 --accept-license $speedLog 21is_upload$(cat $speedLog | grep Upload)if [[ ${is_upload} ]]; thenlocal REDownload$(cat $speedLog | awk -F /Download/{print $3})local reupload$(cat $speedLog | awk -F /Upload/{print $3})local relatency$(cat $speedLog | awk -F /Latency/{print $2})local nodeName$2temp$(echo ${REDownload} | awk -F {print $1})if [[ $(awk -v num1${temp} -v num20 BEGIN{print(num1num2)?1:0}) -eq 1 ]]; thenprintf ${YELLOW}%-18s${GREEN}%-18s${RED}%-20s${SKYBLUE}%-12s${PLAIN}\n ${nodeName} ${reupload} Mbit/s ${REDownload} Mbit/s ${relatency} ms | tee -a $logfielselocal cerrorERRORfifi
}print_speedtest() {printf %-18s%-18s%-20s%-12s\n Node Name Upload Speed Download Speed Latency | tee -a $logspeed_test Speedtest.netspeed_fast_comspeed_test 27377 Beijing 5G CTspeed_test 26352 Nanjing 5G CTspeed_test 17145 Hefei 5G CTspeed_test 27594 Guangzhou 5G CTspeed_test 27154 TianJin 5G CUspeed_test 24447 Shanghai 5G CUspeed_test 26678 Guangzhou 5G CUspeed_test 17184 Tianjin 5G CMspeed_test 26850 Wuxi 5G CMspeed_test 27249 Nanjing 5G CMspeed_test 26404 Hefei 5G CMspeed_test 28491 Changsha 5G CMrm -rf speedtest*
}print_speedtest_fast() {printf %-18s%-18s%-20s%-12s\n Node Name Upload Speed Download Speed Latency | tee -a $logspeed_test Speedtest.netspeed_fast_comspeed_test 27377 Beijing 5G CTspeed_test 24447 ShangHai 5G CUspeed_test 27249 Nanjing 5G CMrm -rf speedtest*
}speed_fast_com() {temp$(python fast_com_example_usage.py 21)is_down$(echo $temp | grep Result) if [[ ${is_down} ]]; thentemp1$(echo $temp | awk -F : /Result/{print $2})temp2$(echo $temp1 | awk -F /Mbps/{print $1})local REDownload$temp2 Mbit/slocal reupload0.00 Mbit/slocal relatency-local nodeNameFast.comprintf ${YELLOW}%-18s${GREEN}%-18s${RED}%-20s${SKYBLUE}%-12s${PLAIN}\n ${nodeName} ${reupload} ${REDownload} ${relatency} | tee -a $logelselocal cerrorERRORfirm -rf fast_com_example_usage.pyrm -rf fast_com.py}io_test() {(LANGC dd if/dev/zero oftest_file_$$ bs512K count$1 convfdatasync rm -f test_file_$$ ) 21 | awk -F, {io$NF} END { print io} | sed s/^[ \t]*//;s/[ \t]*$//
}calc_disk() {local total_size0local array$for size in ${array[]}do[ ${size} 0 ] size_t0 || size_techo ${size:0:${#size}-1}[ echo ${size:(-1)} K ] size0[ echo ${size:(-1)} M ] size$( awk BEGIN{printf %.1f, $size_t / 1024} )[ echo ${size:(-1)} T ] size$( awk BEGIN{printf %.1f, $size_t * 1024} )[ echo ${size:(-1)} G ] size${size_t}total_size$( awk BEGIN{printf %.1f, $total_size $size} )doneecho ${total_size}
}power_time() {result$(smartctl -a $(result$(cat /proc/mounts) echo $(echo $result | awk /dataordered/{print $1}) | awk {print $1}) 21) power_time$(echo $result | awk /Power_On/{print $10}) echo $power_time
}install_smart() {if [ ! -e /usr/sbin/smartctl ]; thenecho Installing Smartctl ...if [ ${release} centos ]; thenyum update /dev/null 21yum -y install smartmontools /dev/null 21elseapt-get update /dev/null 21apt-get -y install smartmontools /dev/null 21fi fi
}ip_info4(){ip_date$(curl -4 -s http://api.ip.la/en?json)echo $ip_date ip_json.jsonisp$(python tools.py geoip isp)as_tmp$(python tools.py geoip as)asn$(echo $as_tmp | awk -F {print $1})org$(python tools.py geoip org)if [ -z ip_date ]; thenecho $ip_dateecho halacountry$(python tools.py ipip country_name)city$(python tools.py ipip city)countryCode$(python tools.py ipip country_code)region$(python tools.py ipip province)elsecountry$(python tools.py geoip country)city$(python tools.py geoip city)countryCode$(python tools.py geoip countryCode)region$(python tools.py geoip regionName) fiif [ -z $city ]; thencity${region}fiecho -e ASN ISP : ${SKYBLUE}$asn, $isp${PLAIN} | tee -a $logecho -e Organization : ${YELLOW}$org${PLAIN} | tee -a $logecho -e Location : ${SKYBLUE}$city, ${YELLOW}$country / $countryCode${PLAIN} | tee -a $logecho -e Region : ${SKYBLUE}$region${PLAIN} | tee -a $logrm -rf tools.pyrm -rf ip_json.json
}virt_check(){if hash ifconfig 2/dev/null; theneth$(ifconfig)fivirtualx$(dmesg) 2/dev/nullif [ $(which dmidecode) ]; thensys_manu$(dmidecode -s system-manufacturer) 2/dev/nullsys_product$(dmidecode -s system-product-name) 2/dev/nullsys_ver$(dmidecode -s system-version) 2/dev/nullelsesys_manusys_productsys_verfiif grep docker /proc/1/cgroup -qa; thenvirtualDockerelif grep lxc /proc/1/cgroup -qa; thenvirtualLxcelif grep -qa containerlxc /proc/1/environ; thenvirtualLxcelif [[ -f /proc/user_beancounters ]]; thenvirtualOpenVZelif [[ $virtualx *kvm-clock* ]]; thenvirtualKVMelif [[ $cname *KVM* ]]; thenvirtualKVMelif [[ $cname *QEMU* ]]; thenvirtualKVMelif [[ $virtualx *VMware Virtual Platform* ]]; thenvirtualVMwareelif [[ $virtualx *Parallels Software International* ]]; thenvirtualParallelselif [[ $virtualx *VirtualBox* ]]; thenvirtualVirtualBoxelif [[ -e /proc/xen ]]; thenvirtualXenelif [[ $sys_manu *Microsoft Corporation* ]]; thenif [[ $sys_product *Virtual Machine* ]]; thenif [[ $sys_ver *7.0* || $sys_ver *Hyper-V ]]; thenvirtualHyper-VelsevirtualMicrosoft Virtual MachinefifielsevirtualDedicatedfi
}power_time_check(){echo -ne Power time of disk : install_smartptime$(power_time)echo -e ${SKYBLUE}$ptime Hours${PLAIN}
}freedisk() {freespace$( df -m . | awk NR2 {print $4} )if [[ $freespace ]]; then$freespace$( df -m . | awk NR3 {print $3} )fiif [[ $freespace -gt 1024 ]]; thenprintf %s $((1024*2))elif [[ $freespace -gt 512 ]]; thenprintf %s $((512*2))elif [[ $freespace -gt 256 ]]; thenprintf %s $((256*2))elif [[ $freespace -gt 128 ]]; thenprintf %s $((128*2))elseprintf 1fi
}print_io() {if [[ $1 fast ]]; thenwritemb$((128*2))elsewritemb$(freedisk)fiwritemb_size$(( writemb / 2 ))MBif [[ $writemb_size 1024MB ]]; thenwritemb_size1.0GBfiif [[ $writemb ! 1 ]]; thenecho -n I/O Speed( $writemb_size ) : | tee -a $logio1$( io_test $writemb )echo -e ${YELLOW}$io1${PLAIN} | tee -a $logecho -n I/O Speed( $writemb_size ) : | tee -a $logio2$( io_test $writemb )echo -e ${YELLOW}$io2${PLAIN} | tee -a $logecho -n I/O Speed( $writemb_size ) : | tee -a $logio3$( io_test $writemb )echo -e ${YELLOW}$io3${PLAIN} | tee -a $logioraw1$( echo $io1 | awk NR1 {print $1} )[ echo $io1 | awk NR1 {print $2} GB/s ] ioraw1$( awk BEGIN{print $ioraw1 * 1024} )ioraw2$( echo $io2 | awk NR1 {print $1} )[ echo $io2 | awk NR1 {print $2} GB/s ] ioraw2$( awk BEGIN{print $ioraw2 * 1024} )ioraw3$( echo $io3 | awk NR1 {print $1} )[ echo $io3 | awk NR1 {print $2} GB/s ] ioraw3$( awk BEGIN{print $ioraw3 * 1024} )ioall$( awk BEGIN{print $ioraw1 $ioraw2 $ioraw3} )ioavg$( awk BEGIN{printf %.1f, $ioall / 3} )echo -e Average I/O Speed : ${YELLOW}$ioavg MB/s${PLAIN} | tee -a $logelseecho -e ${RED}Not enough space!${PLAIN}fi
}print_system_info() {echo -e CPU Model : ${SKYBLUE}$cname${PLAIN} | tee -a $logecho -e CPU Cores : ${YELLOW}$cores Cores ${SKYBLUE}$freq MHz $arch${PLAIN} | tee -a $logecho -e CPU Cache : ${SKYBLUE}$corescache ${PLAIN} | tee -a $logecho -e OS : ${SKYBLUE}$opsy ($lbit Bit) ${YELLOW}$virtual${PLAIN} | tee -a $logecho -e Kernel : ${SKYBLUE}$kern${PLAIN} | tee -a $logecho -e Total Space : ${SKYBLUE}$disk_used_size GB / ${YELLOW}$disk_total_size GB ${PLAIN} | tee -a $logecho -e Total RAM : ${SKYBLUE}$uram MB / ${YELLOW}$tram MB ${SKYBLUE}($bram MB Buff)${PLAIN} | tee -a $logecho -e Total SWAP : ${SKYBLUE}$uswap MB / $swap MB${PLAIN} | tee -a $logecho -e Uptime : ${SKYBLUE}$up${PLAIN} | tee -a $logecho -e Load Average : ${SKYBLUE}$load${PLAIN} | tee -a $logecho -e TCP CC : ${YELLOW}$tcpctrl${PLAIN} | tee -a $log
}print_end_time() {end$(date %s) time$(( $end - $start ))if [[ $time -gt 60 ]]; thenmin$(expr $time / 60)sec$(expr $time % 60)echo -ne Finished in : ${min} min ${sec} sec | tee -a $logelseecho -ne Finished in : ${time} sec | tee -a $logfiprintf \n | tee -a $logbj_time$(curl -s http://cgi.im.qq.com/cgi-bin/cgi_svrtime)if [[ $(echo $bj_time | grep html) ]]; thenbj_time$(date -u %Y-%m-%d %H:%M:%S -d 8 hours)fiecho Timestamp : $bj_time GMT8 | tee -a $logecho Results : $log
}get_system_info() {cname$( awk -F: /model name/ {name$2} END {print name} /proc/cpuinfo | sed s/^[ \t]*//;s/[ \t]*$// )cores$( awk -F: /model name/ {core} END {print core} /proc/cpuinfo )freq$( awk -F: /cpu MHz/ {freq$2} END {print freq} /proc/cpuinfo | sed s/^[ \t]*//;s/[ \t]*$// )corescache$( awk -F: /cache size/ {cache$2} END {print cache} /proc/cpuinfo | sed s/^[ \t]*//;s/[ \t]*$// )tram$( free -m | awk /Mem/ {print $2} )uram$( free -m | awk /Mem/ {print $3} )bram$( free -m | awk /Mem/ {print $6} )swap$( free -m | awk /Swap/ {print $2} )uswap$( free -m | awk /Swap/ {print $3} )up$( awk {a$1/86400;b($1%86400)/3600;c($1%3600)/60} {printf(%d days %d hour %d min\n,a,b,c)} /proc/uptime )load$( w | head -1 | awk -Fload average: {print $2} | sed s/^[ \t]*//;s/[ \t]*$// )opsy$( get_opsy )arch$( uname -m )lbit$( getconf LONG_BIT )kern$( uname -r )disk_size1$( LANGC df -hPl | grep -wvE \-|none|tmpfs|overlay|shm|udev|devtmpfs|by-uuid|chroot|Filesystem | awk {print $2} )disk_size2$( LANGC df -hPl | grep -wvE \-|none|tmpfs|overlay|shm|udev|devtmpfs|by-uuid|chroot|Filesystem | awk {print $3} )disk_total_size$( calc_disk ${disk_size1[]} )disk_used_size$( calc_disk ${disk_size2[]} )tcpctrl$( sysctl net.ipv4.tcp_congestion_control | awk -F {print $3} )virt_check
}print_intro() {printf Superbench.sh -- https://www.oldking.net/350.html\n | tee -a $logprintf Mode : \e${GREEN}%s\e${PLAIN} Version : \e${GREEN}%s${PLAIN}\n $mode_name 1.1.7 | tee -a $logprintf Usage : wget -qO- sb.oldking.net | bash\n | tee -a $log
}sharetest() {echo Share result: | tee -a $logecho · $result_speed | tee -a $loglog_preuploadcase $1 inubuntu)share_linkhttps://paste.ubuntu.com$( curl -v --data-urlencode content$log_up -d postersuperbench.sh -d syntaxtext https://paste.ubuntu.com 21 | \grep Location | awk {print $3} );;haste )share_link$( curl -X POST -s -d $(cat $log) https://hastebin.com/documents | awk -F {print https://hastebin.com/$4} );;clbin )share_link$( curl -sF clbin- https://clbin.com $log );;ptpb )share_link$( curl -sF c- https://ptpb.pw/?u1 $log );;esacecho · $share_link | tee -a $lognextecho rm -f $log_up}log_preupload() {log_up$HOME/superbench_upload.logtrue $log_up$(cat superbench.log 21 | sed -r s/\x1B\[([0-9]{1,2}(;[0-9]{1,2})?)?[m|K]//g $log_up)
}cleanup() {rm -f test_file_*rm -rf speedtest*rm -f fast_com*rm -f tools.pyrm -f ip_json.json
}bench_all(){mode_nameStandardabout;benchinit;clearnext;print_intro;next;get_system_info;print_system_info;ip_info4;next;print_io;next;print_speedtest;next;print_end_time;next;cleanup;sharetest ubuntu;
}fast_bench(){mode_nameFastabout;benchinit;clearnext;print_intro;next;get_system_info;print_system_info;ip_info4;next;print_io fast;next;print_speedtest_fast;next;print_end_time;next;cleanup;
}log./superbench.log
true $log
speedLog./speedtest.log
true $speedLogcase $1 ininfo|-i|--i|-info|--info )about;sleep 3;next;get_system_info;print_system_info;next;;version|-v|--v|-version|--version)next;about;next;;io|-io|--io|-drivespeed|--drivespeed )next;print_io;next;;speed|-speed|--speed|-speedtest|--speedtest|-speedcheck|--speedcheck )about;benchinit;next;print_speedtest;next;cleanup;;ip|-ip|--ip|geoip|-geoip|--geoip )about;benchinit;next;ip_info4;next;cleanup;;bench|-a|--a|-all|--all|-bench|--bench )bench_all;;about|-about|--about )about;;fast|-f|--f|-fast|--fast )fast_bench;;share|-s|--s|-share|--share )bench_all;is_shareshareif [[ $2 ]]; thensharetest ubuntu;elsesharetest $2;fi;;debug|-d|--d|-debug|--debug )get_ip_whois_org_name;;
*)bench_all;;
esacif [[ ! $is_share share ]]; thencase $2 inshare|-s|--s|-share|--share )if [[ $3 ]]; thensharetest ubuntu;elsesharetest $3;fi;;esac
fi脚本执行结果