LinuxQuestions.org
Review your favorite Linux distribution.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Non-*NIX Forums > Programming
User Name
Password
Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.

Notices


Reply
  Search this Thread
Old 10-08-2018, 07:00 AM   #1
slipstreamed
Member
 
Registered: Nov 2010
Posts: 60

Rep: Reputation: 24
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
 
Old 10-08-2018, 08:44 AM   #2
NevemTeve
Senior Member
 
Registered: Oct 2011
Location: Budapest
Distribution: Debian/GNU/Linux, AIX
Posts: 4,873
Blog Entries: 1

Rep: Reputation: 1871Reputation: 1871Reputation: 1871Reputation: 1871Reputation: 1871Reputation: 1871Reputation: 1871Reputation: 1871Reputation: 1871Reputation: 1871Reputation: 1871
Maybe comparing this with the output of lsof -nPi TCP might help.
 
  


Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
Is there a /proc/net/... file for IPv6 similar to /proc/net/arp for mac addresses? systemlordanubis Linux - Networking 1 03-02-2012 06:36 PM
What is TCP orphan in in /proc/net/sockstat cabrilo Linux - Networking 1 12-14-2010 08:49 AM
/proc/net/tcp - retransmit vlyamtse Linux - Networking 0 02-26-2010 10:48 AM
/proc/dev/net and /proc/net/dev problem ! Linux.tar.gz Slackware 1 05-23-2007 05:24 AM
parsing proc shukla_chanchal Linux - General 2 11-01-2005 12:29 PM

LinuxQuestions.org > Forums > Non-*NIX Forums > Programming

All times are GMT -5. The time now is 02:55 PM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration