Warning: Undefined array key "cperpage" in /www/wwwroot/www.now163.com/wp-content/themes/twentytwentyfive/functions.php on line 255

Warning: Undefined variable $output in /www/wwwroot/www.now163.com/wp-content/themes/twentytwentyfive/functions.php on line 325

Warning: Undefined variable $fixed_tags in /www/wwwroot/www.now163.com/wp-content/themes/twentytwentyfive/functions.php on line 326

Warning: Undefined variable $isshowdots in /www/wwwroot/www.now163.com/wp-content/themes/twentytwentyfive/functions.php on line 327

Warning: Undefined variable $tag_aditional in /www/wwwroot/www.now163.com/wp-content/themes/twentytwentyfive/functions.php on line 330

Warning: Undefined variable $tag_aditional in /www/wwwroot/www.now163.com/wp-content/themes/twentytwentyfive/functions.php on line 333

Warning: Undefined variable $tag_aditional in /www/wwwroot/www.now163.com/wp-content/themes/twentytwentyfive/functions.php on line 336

Warning: Undefined variable $post in /www/wwwroot/www.now163.com/wp-content/themes/twentytwentyfive/functions.php on line 345

Warning: Attempt to read property "ID" on null in /www/wwwroot/www.now163.com/wp-content/themes/twentytwentyfive/functions.php on line 345

Warning: Undefined variable $post in /www/wwwroot/www.now163.com/wp-content/themes/twentytwentyfive/functions.php on line 345

Warning: Attempt to read property "ID" on null in /www/wwwroot/www.now163.com/wp-content/themes/twentytwentyfive/functions.php on line 345

Warning: Undefined variable $more_text_link in /www/wwwroot/www.now163.com/wp-content/themes/twentytwentyfive/functions.php on line 345
网络 – 理想社会

分类: 网络

  • 为Ping记录加一个时间戳

    最近公司网络不稳定,间歇性断流。为了检查网络状况。我们需要用ping来了解网络状况(丢包等等一些问题)。
    ping的输出默认是不带时间戳的,所以很难定位故障时间。
    下面一个脚本很好的解决了此问题。
    代码另存为ping.vbs
    用法为:cscript ping.vbs 192.168.1.2 -t > ping.txt
    如果ping的输出是英文
    那么脚本里的
    re.Pattern=”^请求|^来自”
    替换为:
    re.Pattern=”^Reply|^Request”

    Dim args, flag, unsuccOut
    args=""
    otherout=""
    flag=0
    
    If WScript.Arguments.count = 0 Then
    WScript.Echo "Usage: cscript tping.vbs [-t] [-a] [-n count] [-l size] [-f] [-i TTL] [-v TOS]"
    WScript.Echo "                         [-s count] [[-j host-list] | [-k host-list]]"
    WScript.Echo "                         [-r count] [-w timeout] destination-list"
    wscript.quit
    End if
    
    For i=0 to WScript.Arguments.count - 1
    args=args & " " & WScript.Arguments(i)
    Next
    
    Set shell = WScript.CreateObject("WScript.Shell")
    Set re=New RegExp
    re.Pattern="^请求|^来自"
    Set myping=shell.Exec("ping" & args)
    
    while Not myping.StdOut.AtEndOfStream
       strLine=myping.StdOut.ReadLine()
       r=re.Test(strLine)
       If r Then
    WScript.Echo date & " "& time & chr(9) & strLine
    flag=1
       Else
    unsuccOut=unsuccOut & strLine
       End if
    Wend
    
    if flag = 0 then
    WScript.Echo unsuccOut
    end if

    附上一个linux下的方法:

    ping baidu.com -c 10 | awk '{ print $0"\t" strftime("%H:%M:%S-%D",systime()) } '
  • cisco设备根据ip来找到对应端口

    刚刚发现一个ip流量异常大。想找到它对应的设备端口然后干掉!

    因为对cisco设备不熟。So做个笔记以防以后再次遇到。

    Cisco4506上

    sh arp | in 192.168.1.68

    Internet  192.168.1.68            3   0021.86ef.6a8c  ARPA   Vlan3

    找到ip对应的mac地址 (更多…)