LinuxQuestions.org
Latest LQ Deal: Latest LQ Deals
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 02-16-2009, 09:01 PM   #1
m4rtin
Member
 
Registered: Sep 2007
Posts: 261

Rep: Reputation: 16
Question script for formating /proc/net files?


when I view for example /proc/net/tcp or /proc/net/dev files with cat or tail utility, colums are not aligned and the layout of the file is a mess. Is there some other utility which is capable of viewing those files correctly? Or should I write some kind of script for that? If yes, can it be made using shell commands or should I use perl(I am not very familiar with perl)?
 
Old 02-16-2009, 09:55 PM   #2
wje_lq
Member
 
Registered: Sep 2007
Location: Mariposa
Distribution: FreeBSD,Debian wheezy
Posts: 811

Rep: Reputation: 179Reputation: 179
Are you looking at these files with a monospace font, with an environment that's wide enough to keep the data from wrapping around?

Here's what I get on my system when I take care of those details, with no special handling or scripts or anything:
Code:
wally:~/monday/2$ cat /proc/net/tcp
  sl  local_address rem_address   st tx_queue rx_queue tr tm->when retrnsmt   uid  timeout inode                                                     
   0: 00000000:1770 00000000:0000 0A 00000000:00000000 00:00000000 00000000     0        0 9356 1 f6276d80 750 0 0 2 -1                              
   1: 00000000:0071 00000000:0000 0A 00000000:00000000 00:00000000 00000000     0        0 7763 1 f6276900 750 0 0 2 -1                              
   2: 0101000A:0035 00000000:0000 0A 00000000:00000000 00:00000000 00000000     0        0 11258 1 f688e000 750 0 0 2 -1                             
   3: 6506A8C0:0035 00000000:0000 0A 00000000:00000000 00:00000000 00000000     0        0 11256 1 f688e480 750 0 0 2 -1                             
   4: 0100000A:0035 00000000:0000 0A 00000000:00000000 00:00000000 00000000     0        0 11254 1 f688f680 750 0 0 2 -1                             
   5: 0100007F:0035 00000000:0000 0A 00000000:00000000 00:00000000 00000000     0        0 7795 1 f751e000 750 0 0 2 -1                              
   6: 00000000:0015 00000000:0000 0A 00000000:00000000 00:00000000 00000000     0        0 7761 1 f6276000 750 0 0 2 -1                              
   7: 0100007F:0277 00000000:0000 0A 00000000:00000000 00:00000000 00000000     0        0 8809 1 f751e900 750 0 0 2 -1                              
   8: 00000000:0017 00000000:0000 0A 00000000:00000000 00:00000000 00000000     0        0 7762 1 f6276480 750 0 0 2 -1                              
   9: 0100007F:03B9 00000000:0000 0A 00000000:00000000 00:00000000 00000000     0        0 7798 1 f751e480 750 0 0 2 -1                              
  10: 6506A8C0:B499 E2079642:0050 01 00000000:00000000 00:00000000 00000000  4000        0 17689 1 c8912000 74 10 32 2 -1                            
  11: 6506A8C0:DC81 164534D8:0050 01 00000000:00000000 00:00000000 00000000  4000        0 17668 1 c8912900 103 10 0 2 -1                            
  12: 0100000A:DF6E 0200000A:0017 01 00000000:00000000 00:00000000 00000000  6000        0 17311 1 e89e5200 52 10 28 2 -1                            
  13: 6506A8C0:B498 E2079642:0050 01 00000000:00000000 00:00000000 00000000  4000        0 17688 1 c8912480 73 10 28 2 -1                            
  14: 0100000A:DF6D 0200000A:0017 01 00000000:00000000 00:00000000 00000000  6000        0 17270 1 e89e4d80 51 10 2 2 -1                             
  15: 6506A8C0:DC80 164534D8:0050 01 00000000:00000000 00:00000000 00000000  4000        0 17667 1 c8913200 90 10 0 2 -1                             
wally:~/monday/2$ cat /proc/net/dev
Inter-|   Receive                                                |  Transmit
 face |bytes    packets errs drop fifo frame compressed multicast|bytes    packets errs drop fifo colls carrier compressed
    lo:   61700    1234    0    0    0     0          0         0    61700    1234    0    0    0     0       0          0
  eth0:46359757   44488    0    0    0     0          0       272  6231385   43501    0    0    0     0       0          0
  eth1:       0       0    0    0    0     0          0         0        0       0    0    0    0     0       0          0
wally:~/monday/2$
Everything lines up nicely, except for the stuff beyond the inodes.
 
  


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
Increasing /proc/net/ip_conntrack_max imagize Linux - Server 2 09-22-2008 11:24 PM
/proc/net/dev_mcast vprakash Linux - Networking 1 09-21-2007 01:03 PM
/proc/net/dev format vlyamtse Linux - General 1 06-08-2007 10:34 AM
/proc/dev/net and /proc/net/dev problem ! Linux.tar.gz Slackware 1 05-23-2007 05:24 AM
/proc/net/wireless MarkusMan Linux - Wireless Networking 2 01-26-2004 09:56 PM

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

All times are GMT -5. The time now is 10:53 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