tcping在linux用法,tcping的安装和使用[通俗易懂]

tcping在linux用法,tcping的安装和使用[通俗易懂]Tcping网上比较少资料是关于linux对tcp端口ping测试的方法,我这里简单介绍2种方法:1.yum安装,编译安装方法1-1.wgethttp://linuxco.de/tcping/tcping-1.3.5.tar.gz###下载tcping1-2tarzxvftcping-1.3.5.tar.gz####解压缩tcping-1.3.51-3cdtcping-1….

大家好,又见面了,我是你们的朋友全栈君。

Tcping 网上比较少资料是关于linux对tcp端口ping测试的方法,我这里简单介绍2种方法: 1.yum安装,编译安装方法 1-1.wget http://linuxco.de/tcping/tcping-1.3.5.tar.gz ###下载tcping

ab1b5ad394a75b3b9a4e9dc5e9836561.png

1-2 tar zxvf tcping-1.3.5.tar.gz ####解压缩tcping-1.3.5

1-3 cd tcping-1.3.5 ###进入文件夹

1-4 gcc -o tcping tcping.c ####编译执行文件

866b5b82047b36e23568d5316daf44d8.png

1-5 ./tcping www.baidu.com 80 ####使用方法,后面加tcp端口

26b85c6d538429baf0cf08d34200f431.png

2.通过shell脚本,执行tcping命令(能长ping) 2-1 脚本如下: #!/bin/sh

ver=”v1.7″ format=”%Y%m%d%H%M%S” d=”no” c=”no” C=”no” ttl=255 seq=0 q=1 r=1 w=3 topts=””

usage () { name=basename $0 echo “tcpping $ver Richard van den Berg ” echo echo “Usage: $name [-d] [-c] [-C] [-w sec] [-q num] [-x count] ipaddress [port]” echo echo ” -d print timestamp before every result” echo ” -c print a columned result line” echo ” -C print in the same format as fping’s -C option” echo ” -w wait time in seconds (defaults to 3)” echo ” -r repeat every n seconds (defaults to 1)” echo ” -x repeat n times (defaults to unlimited)” echo echo “See also: man tcptraceroute” echo }

_checksite() { ttr=tcptraceroute -f ${ttl} -m ${ttl} -q ${q} -w ${w} $* 2>&1 if echo “${ttr}” | egrep -i “(bad destination|got roo)” >/dev/null 2>&1; then echo “${ttr}” exit fi }

_testsite() { myseq=”${1}” shift [ “${c}” = “yes” ] && nows=date +${format} [ “${d}” = “yes” ] && nowd=date ttr=tcptraceroute -f ${ttl} -m ${ttl} -q ${q} -w ${w} $* 2>/dev/null host=echo “${ttr}” | awk ‘{print $2 ” ” $3}’ rtt=echo “${ttr}” | sed ‘s/.*] //’ | awk ‘{print $1}’ not=echo “${rtt}” | tr -d “.0123456789” [ “${d}” = “yes” ] && echo “$nowd” if [ “${c}” = “yes” ]; then if [ “x${rtt}” != “x” -a “x${not}” = “x” ]; then echo “$myseq $nows $rtt $host” else echo “$myseq $nows $max $host” fi elif [ “${C}” = “yes” ]; then if [ “$myseq” = “0” ]; then echo -n “$1 :” fi if [ “x${rtt}” != “x” -a “x${not}” = “x” ]; then echo -n ” $rtt” else echo -n ” -” fi if [ “$x” = “1” ]; then echo fi else echo “${ttr}” | sed -e “s/^.*.$/seq $myseq: no response (time out)/” -e “s/^$ttl /seq $myseq: tcp response from/” fi

echo “${ttr}”

}

while getopts dhq:w:cr:nNFSAEi:f:l:m:p:s:x:C opt ; do case “$opt” in d|c|C) eval $opt=”yes” ;; q|w|r|x) eval $opt=”$OPTARG” ;; n|N|F|S|A|E) topt=”$topt -$opt” ;; i|l|p|s) topt=”$topt -$opt $OPTARG” ;; f|m) ttl=”$OPTARG” ;; ?) usage; exit ;; esac done

shift expr $OPTIND – 1

if [ “x$1” = “x” ]; then usage exit fi

#max=echo “${w} * 1000” | bc

if [ date +%s != “%s” ]; then format=”%s” fi

_checksite ${topt} $*

if [ “$x” = “” ]; then while [ 1 ] ; do _testsite ${seq} ${topt} $* & pid=$! if [ “${C}” = “yes” ]; then wait $pid fi seq=expr $seq + 1 sleep ${r} done else while [ “$x” -gt 0 ] ; do _testsite ${seq} ${topt} $* & pid=$! if [ “${C}” = “yes” ]; then wait $pid fi seq=expr $seq + 1 x=expr $x – 1 if [ “$x” -gt 0 ]; then sleep ${r} fi done fi

exit

2-2 vi一个文件,这里命名为tcping

fc01ee91065aa226ce6243c1fc131dbb.png

2-3 chmod 777 tcping ###赋予tcping执行权限

1bbc5744858919fcc9da386280061497.png

2-4 安装脚本执行内容所需软件支持

1.wget

2.rpm -ih tcptraceroute-1.5-0.beta7.el6.rf.x86_64.rpm

4c0386e724e7d9bfd50654acf53ec288.png

2-6 ./tcping www.baidu.com 80 ####执行shell脚本

e2c7a1c48e0ab2a04a6a81cac0e54845.png

由睿江云运维人员提供,想了解更多,请登陆www.eflycloud.com

版权声明:本文内容由互联网用户自发贡献,该文观点仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请联系我们举报,一经查实,本站将立刻删除。

发布者:全栈程序员-站长,转载请注明出处:https://javaforall.net/152495.html原文链接:https://javaforall.net

(0)
全栈程序员-站长的头像全栈程序员-站长


相关推荐

  • 如何将ofd文件转成pdf格式?

    如何将ofd文件转成pdf格式?自电子发票改为ofd格式文件后,很多通知、办公文档也逐步开始用ofd替代,但毕竟使用还不算普及,我们也都更习惯PDF格式。那么如何将OFD文件转成PDF呢?对于不熟悉和不知如何打开OFD文件的人来说,最简单的方法当然是直接转成PDF后再打开查看或修改,这里我们需要用到专门的转换工具。不需要安装软件,只需要搜索speedpdf打开这个在线工具页面就能转换,首页就能找到我们需要的OFD转PDF功能。(除此之外还有XPS和CAD这些很难找到转换工具的格式转换哦)转换过程也非常简单,添加需要转换的文档后,点击

    2022年5月27日
    36
  • Matlab调用excel数据绘制折线图「建议收藏」

    Matlab调用excel数据绘制折线图「建议收藏」如题,matlab之前没接触过,但是电脑上一直有安装,有些老师需要做几张图放论文里,所以尝试了一下(excel其实效果也行,但matlab感觉更专业)x=2:2:778;%x轴上的数据,第一个值代表数据开始,第二个值代表间隔,第三个值代表终止a=xlsread(‘d:/RVA-zlx.xls’,1,’D2:D390′);%a数据y值b=xlsread(‘d:/RVA-zlx.xls…

    2022年6月3日
    41
  • python学习—— IPy 强大的IP地址解析模块

    python学习—— IPy 强大的IP地址解析模块       最近在忙着做计算机网络的课程设计,打算写一个可以扫描内网主机的扫描工具。学习过程中安利到了许多python新姿势,IPy模块就是其中一个。1.IPy模块。       在IP地址规划中,涉及到计算大量的IP地址,包括网段、网络掩码、广播地址、…

    2025年6月23日
    1
  • Oracle NUMBER类型细讲

    Oracle NUMBER类型细讲1>.NUMBER类型细讲:Oraclenumberdatatype语法:NUMBER[(precision[,scale])]简称:precision–>p     scale    –>sNUMBER(p,s)范围:1保存数据范围:-1.0e-130保存在机器内部的范围:1~22bytes有效为:从左边第一个不为0的数算起的位数。s的情况:s>0  

    2022年7月24日
    8
  • idea删除项目「建议收藏」

    idea删除项目「建议收藏」1.使用IDEA打开需要删除的项目,在项目文件上右击选择RemoveModule或者按Delete键2.之后会弹出删除提示,“RemoveModule‘xxx’fromtheproject?Nofileswillbedeleted.” 意思是移除指定模块,但没有文件被删除,就是说,模块移除了,磁盘上的文件还在点击“OK”之后,可以看到列表中还是存在些文件,这些文件是模…

    2025年6月12日
    17
  • oraclejobschedulerorcl禁用_oracledbconsoleorcl找不到

    oraclejobschedulerorcl禁用_oracledbconsoleorcl找不到AboutThisdocumentcoversinformationabouttheSBCSetup.ClickheretoexpandTableofContentsIntroductionBelowyou’llfindastepbystepsetupforinstallingFSasaSBC.TheLCRengineisprovide…

    2022年9月12日
    0

发表回复

您的邮箱地址不会被公开。 必填项已用 * 标注

关注全栈程序员社区公众号