Parsing /proc/net/dev into key:value pairs (self-answered)
Hi all,
I need some help with using sed/awk/other linux tools to meet the following goal:
I'm trying to take the output of /proc/net/dev:
...grep out an interface (eth0) and turn it into the following data:
I've gotten as far as this snippet:
... but I'm not sure where to proceed from here, or if this is even the right track. Has anyone done something similar before (i.e. turning columns into key:value pairs)?
Your expertise is much appreciated!
Update: I've found how to transpose rows into columns (which is a step closer!):
Now I just need to figure out how to prepend the 'tx' and 'rx' and strip the trailing ':' and I'm all set! This forum is awesome.
Update 2:
I got it! The only way it could be better is with CamelCase (RxBytes, etc):
The multiline format actually works well for my application.
Last edited by otheus; 01-30-2009 at 07:31 AM..
Reason: Woot!
Hello,
/proc/sys/net/ipv4/ip_local_port_range returns 32000 - 61000,
i have a client TCP and a Server TCP. i have used bind() only on the server, the port of socket client is given by the OS that's it ?
it retrieves this port from this range (/proc/sys/net/ipv4/ip_local_port_range) ?
... (5 Replies)
I am extracting a number of key/value pairs in awk using following:
awk '
/xyz_session_id/ {
n=index($0,"xyz_session_id");
id=substr($0,n+15,25);
a=$4;
}
END{
for (ix in a) { print a }
}'
I don't like this Index + substr with manually calculated... (5 Replies)
Hi All,
I have question , How to generate the SSH keys for the two servers in the pair.
So if the server will be replicated , same SSH key pairs will work on each server. No need to generate the SSH keys for the second server.
I have created the SSH keys for the single server. I was... (1 Reply)
HI ,
I have the following type of lines in a file and need to create a csv file that can be bcp'ed into a db
The problem that I have is the delimited of the <name :value> is a space but some of the values in the pairs have space . eg msg_src_time:03/05/13 10:40:17.919
Need sugesstions on... (9 Replies)
Hi experts,
e.g.
i/p data looks like
0000xm7zcNDIkP888vRqGv93xA7:176n00qql||9700005405552747,9700005405717924,9700005405733788|unidentified,unidentified,unidentified||
o/p data should like -
row1: 0000xm7zcNDIkP888vRqGv93xA7:176n00qql||9700005405552747|unidentified
... (1 Reply)
Hello,
I have property file with key value pairs separated by pipe , I am trying to write a script which reads the property file and search and print value of specific key. I tried with Sed, I am successfull.
The file is as follows
... (4 Replies)
Hi,
I am trying to calculate the CPU Usage by getting the difference between the idle time reported by /proc/stat at 2 different intervals. Now the 4th entry in the first line of /proc/stat will give me the 'idle time'. But I also came across /proc/uptime that gives me 2 entries : 1st one as the... (0 Replies)
Discussion started by: coderd
0 Replies
8. Post Here to Contact Site Administrators and Moderators
hi,
this is just a suggestion
at Sun's java forums, the person who asked the original question has the ability to indicate that their question has been "answered". I think that is quite handy, as it lets people who are here to solely answer questions skip that thread. There is a potential... (5 Replies)
Hi, Anyone can help
My solaris 8 system has the following
/dev/null , /dev/tty and /dev/console
All permission are lrwxrwxrwx
Can this be change to a non-world write ??
any impact ?? (12 Replies)
Discussion started by: civic2005
12 Replies
10. Post Here to Contact Site Administrators and Moderators
Dear admins,
i remember, my first thread, it is regarding unix systems and i asked some suggestions...
and i like to know how gollum answered for that thread?..
and is gollum is a program?.. (5 Replies)