LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Programming (https://www.linuxquestions.org/questions/programming-9/)
-   -   Parsing /proc/net/tcp (https://www.linuxquestions.org/questions/programming-9/parsing-proc-net-tcp-4175639946/)

slipstreamed 10-08-2018 07:00 AM

Parsing /proc/net/tcp
 
I'm writing a small script to parse /proc/net/tcp. It works properly for most part except for entries with inode values set to 0. My question is, how do you map such inodes to their respective pids?

For example, this gets processed just fine, I take the inode number, search through /proc/pid/fd/* to see which fd is a symlink to 'socket:[inode]' and split that path to return the pid
Code:

sl  local_address rem_address  st tx_queue rx_queue tr tm->when retrnsmt  uid  timeout inode
00000000:1AE1 00000000:0000 0A 00000000:00000000 00:00000000 00000000  1000        0 112028 1 0000000000000000 100 0 0 10 0

But I'm unsure of how to process entries like this:
Code:

sl  local_address rem_address  st tx_queue rx_queue tr tm->when retrnsmt  uid  timeout inode
2: 0301A8C0:A07C FA1D1F5E:01BB 06 00000000:00000000 03:00000979 00000000    0        0 0 3 0000000000000000
5: 0301A8C0:B9FC CDA27E4B:01BB 06 00000000:00000000 03:0000097E 00000000    0        0 0 3 0000000000000000

Any help is appreciated

NevemTeve 10-08-2018 08:44 AM

Maybe comparing this with the output of lsof -nPi TCP might help.


All times are GMT -5. The time now is 12:27 AM.