zoukankan      html  css  js  c++  java
  • How to determine the socket connection up time on Linux

    PEEID=$(sudo pgrep -u root ) && for device in `sudo lsof -anP -i -u root | grep ':9814' | awk '{print $6}'` ; do echo "${device} time" ; sudo find /proc/1/fd -lname "socket:[${device}]" -printf %T+\n 2> /dev/null  ; echo  ;  done 

    This questions was helpful to me, but I found using lsof instead of netstat let me avoid all the HEX stuff:

    For a process ${APP} run by user ${USER}, the following returns all the open sockets to the IP address ${IP}:

    PEEID=$(sudo pgrep -u ${USER} ${APP}) && for i in `sudo lsof -anP -i -u logstash | grep ${IP} | awk '{print $6}'` ; do echo "${device} time" ; sudo find /proc/${PEEID}/fd -lname "socket:[${device}]" -printf %t 2> /dev/null  ; echo  ;  done
    

    The lsof contains the PID too, but I am not sure how to get it and the device number.

    This was tested on Amazon Linux.

    -- Scott, Programmer in Beijing [If you can’t explain it to a six year old, you don’t understand it yourself. —Albert Einstein ]
  • 相关阅读:
    POJ:2431-Expedition
    poj:3253-Fence Repair
    POJ:3617-Best Cow Line(贪心)
    IOS各种传值方式
    imageDownloader
    Android放大镜的实现
    Delphi 串口通信(1)
    UVA 10131
    Skew Join与Left Semi Join相关
    Android动画 fillAfter和fillBefore
  • 原文地址:https://www.cnblogs.com/scottgu/p/15429674.html
Copyright © 2011-2022 走看看