找回密码
 立即注册
搜索
热搜: 活动 交友 discuz
查看: 38|回复: 4

测试服务器网络性能脚本

[复制链接]

55

主题

591

回帖

1379

积分

金牌会员

积分
1379
发表于 2012-9-5 10:42:47 | 显示全部楼层 |阅读模式
代码如下,另外附件也有个压缩包,内容一样的.这个脚本实际上就是利用常见的几个测试点进行下载文件测试,有爱的可以自己额外添加其他下载点.附图为我某台san jose的linode VPS,性能一般吧,网卡是G口,磁盘确实不咋滴,可能是因为linode都是大母鸡,至少16G内存,磁盘性能普遍很低.[ol]
  • #!/bin/bash
  • cname=$( awk -F: '/model name/ {name=$2} END {print name}' /proc/cpuinfo )
  • cores=$( awk -F: '/model name/ {core++} END {print core}' /proc/cpuinfo )
  • freq=$( awk -F: ' /cpu MHz/ {freq=$2} END {print freq}' /proc/cpuinfo )
  • tram=$( free -m | awk 'NR==2 {print $2}' )
  • swap=$( free -m | awk 'NR==4 {print $2}' )
  • up=$(uptime|awk '{ $1=$2=$(NF-6)=$(NF-5)=$(NF-4)=$(NF-3)=$(NF-2)=$(NF-1)=$NF=""; print }')
  • echo "CPU model : $cname"
  • echo "Number of cores : $cores"
  • echo "CPU frequency : $freq MHz"
  • echo "Total amount of ram : $tram MB"
  • echo "Total amount of swap : $swap MB"
  • echo "System uptime : $up"
  • cachefly=$( wget -O /dev/null http://cachefly.cachefly.net/100mb.test 2>&1 | awk '/\/dev\/null/ {speed=$3 $4} END {gsub(/\(|\)/,"",speed); print speed}' )
  • echo "Download speed from CacheFly: $cachefly "
  • linodeatl=$( wget -O /dev/null http://atlanta1.linode.com/100MB-atlanta.bin 2>&1 | awk '/\/dev\/null/ {speed=$3 $4} END {gsub(/\(|\)/,"",speed); print speed}' )
  • echo "Download speed from Linode, Atlanta GA: $linodeatl "
  • linodedltx=$( wget -O /dev/null http://dallas1.linode.com/100MB-dallas.bin 2>&1 | awk '/\/dev\/null/ {speed=$3 $4} END {gsub(/\(|\)/,"",speed); print speed}' )
  • echo "Download speed from Linode, Dallas, TX: $linodedltx "
  • linodejp=$( wget -O /dev/null http://tokyo1.linode.com/100MB-tokyo.bin 2>&1 | awk '/\/dev\/null/ {speed=$3 $4} END {gsub(/\(|\)/,"",speed); print speed}' )
  • echo "Download speed from Linode, Tokyo, JP: $linodejp "
  • linodeuk=$( wget -O /dev/null http://london1.linode.com/100MB-london.bin 2>&1 | awk '/\/dev\/null/ {speed=$3 $4} END {gsub(/\(|\)/,"",speed); print speed}' )
  • echo "Download speed from Linode, London, UK: $linodeuk "
  • leaseweb=$( wget -O /dev/null http://mirror.leaseweb.com/speedtest/100mb.bin 2>&1 | awk '/\/dev\/null/ {speed=$3 $4} END {gsub(/\(|\)/,"",speed); print speed}' )
  • echo "Download speed from Leaseweb, Haarlem, NL: $leaseweb "
  • slsg=$( wget -O /dev/null http://speedtest.sng01.softlayer.com/downloads/test100.zip 2>&1 | awk '/\/dev\/null/ {speed=$3 $4} END {gsub(/\(|\)/,"",speed); print speed}' )
  • echo "Download speed from Softlayer, Singapore: $slsg "
  • slwa=$( wget -O /dev/null http://speedtest.sea01.softlayer.com/downloads/test100.zip 2>&1 | awk '/\/dev\/null/ {speed=$3 $4} END {gsub(/\(|\)/,"",speed); print speed}' )
  • echo "Download speed from Softlayer, Seattle, WA: $slwa "
  • slsjc=$( wget -O /dev/null http://speedtest.sjc01.softlayer.com/downloads/test100.zip 2>&1 | awk '/\/dev\/null/ {speed=$3 $4} END {gsub(/\(|\)/,"",speed); print speed}' )
  • echo "Download speed from Softlayer, San Jose, CA: $slsjc "
  • slwdc=$( wget -O /dev/null http://speedtest.wdc01.softlayer.com/downloads/test100.zip 2>&1 | awk '/\/dev\/null/ {speed=$3 $4} END {gsub(/\(|\)/,"",speed); print speed}' )
  • echo "Download speed from Softlayer, Washington, DC: $slwdc "
  • io=$( ( dd if=/dev/zero of=test_$ bs=64k count=16k conv=fdatasync && rm -f test_$ ) 2>&1 | awk -F, '{io=$NF} END { print io}' )
  • echo "I/O speed : $io"
  • [/ol]复制代码保存为 test.sh 文件,给755权限,也就是chmod 755  test.sh,然后执行 ./test.sh




  • 本帖子中包含更多资源

    您需要 登录 才可以下载或查看,没有账号?立即注册

    ×
    回复

    使用道具 举报

    75

    主题

    724

    回帖

    1687

    积分

    金牌会员

    积分
    1687
    发表于 2012-9-5 10:43:31 | 显示全部楼层
    技术贴
    回复

    使用道具 举报

    501

    主题

    9654

    回帖

    2万

    积分

    论坛元老

    积分
    20847
    发表于 2012-9-5 10:59:26 | 显示全部楼层
    [ol]
  • wget freevps.us/downloads/bench.sh -O - -o /dev/null|bash[/ol]复制代码
  • 回复

    使用道具 举报

    395

    主题

    4126

    回帖

    9455

    积分

    论坛元老

    积分
    9455
    发表于 2012-9-5 11:01:51 | 显示全部楼层
    月经帖
    回复

    使用道具 举报

    362

    主题

    5052

    回帖

    1万

    积分

    论坛元老

    积分
    11222
    发表于 2012-9-5 20:33:47 | 显示全部楼层
    不错拿走。
    回复

    使用道具 举报

    您需要登录后才可以回帖 登录 | 立即注册

    本版积分规则

    Archiver|手机版|小黑屋|Discuz! X

    GMT+8, 2025-1-11 17:56 , Processed in 0.017296 second(s), 4 queries , Gzip On, Redis On.

    Powered by Discuz! X3.5

    © 2001-2024 Discuz! Team.

    快速回复 返回顶部 返回列表