`
shangtang004
  • 浏览: 32359 次
  • 性别: Icon_minigender_1
  • 来自: 杭州
社区版块
存档分类
最新评论

lean how to use awk, and find process which is listening port

 
阅读更多
听说AWK功能很强,一直不敢去学,感觉复杂,为了找出系统中一个耗时最长的操作,我学习去使用AWK,拼拼也终于能找出,如果各位有更好的方法,欢迎指正。

A03B-fm-1# for i in 0 1 2 3 4  5 6 7 8
> do
> grep 'Upload takes (ms)' PmServer$i.log |awk -F: 'BEGIN{time=0;cont="t"; print "Begin"}{if($3 > time){time = $3;cont=$0}}END{print time "\t" cont  "\nEND"}'
> done
Begin
15910  INFO: LTENESIM001-60001-ENodeB322 - Upload Stats CNEOMI NE END. Upload takes (ms): 15910
END

solaris find process which is listening specific port:

#!/bin/bash

pids=$(/usr/bin/ps -ef | sed 1d | awk '{print $2}')

if [ $# -eq 0 ]; then
   echo "Enter port you would like to know pid for: "
   read ans
else
   ans=$1
fi

for f in $pids
do
/usr/proc/bin/pfiles $f 2>/dev/null | /usr/xpg4/bin/grep  "port: $ans"
if [ $? -eq 0 ]
then echo $f
fi
done
exit 0
分享到:
评论

相关推荐

Global site tag (gtag.js) - Google Analytics