Finding the source of latency in an RPC system - rpc

As the name suggests, I am using a simple RPC system between a PC (windows x64) and an embedded linux PC running ubuntu. The embedded linux pc is the RPC server and the PC is the RPC client. The RPC framework is: erpc.
I have noticed that the transaction rate I am getting is particularly low - on the order of 20 transactions/sec.
The issue is definitely not hardware related as I have an alternate RPC system (which I'm trying to replace with the contentious one) which can easily get over 1000 transactions/sec using the exact same hardware configuration.
To further prove this,I also wrote a simple python script which acts as a simple socket client or server depending on a switch. I run it on the embedded machine as a server and as a client on the pc. The script simply has the client send some random data to the server which in turn sends the data back. The client does this a few hundred times and determines the transaction rate based on this. The amount of data transmitted is of the same order as what erpc uses. Using this setup I can get 3000+ transactions/sec.
The RPC system in question is half duplex. Only a single thread is used. Server recvs, processes the request and sends the response in a loop.
Only a single socket is used for the duration of the test. I.e. no close and accepts occur during the loop. No other IO occurs. Or at least, I have refactored it for the purposes of these tests to not do any other IO.
On the Windows client side, I have a python unit test which I have run with profiling on. The results don't seem to indicate that the problem is on the client.
ncalls tottime percall cumtime percall filename:lineno(function)
1 0.000 0.000 23.998 23.998 runner.py:105(pytest_runtest_call)
1 0.000 0.000 23.998 23.998 python.py:1313(runtest)
1 0.000 0.000 23.998 23.998 __init__.py:603(__call__)
1 0.000 0.000 23.998 23.998 __init__.py:219(_hookexec)
1 0.000 0.000 23.998 23.998 __init__.py:213(<lambda>)
1 0.000 0.000 23.998 23.998 callers.py:151(_multicall)
1 0.000 0.000 23.998 23.998 python.py:183(pytest_pyfunc_call)
1 0.003 0.003 23.998 23.998 test_static_if.py:4(test_read_version)
400 0.014 0.000 23.993 0.060 client.py:16(get_version)
400 0.017 0.000 23.942 0.060 client.py:79(perform_request)
400 0.006 0.000 23.828 0.060 transport.py:75(receive)
800 0.016 0.000 23.820 0.030 transport.py:139(_base_receive)
800 23.803 0.030 23.803 0.030 {method 'recv' of '_socket.socket' objects}
400 0.007 0.000 0.061 0.000 transport.py:65(send)
400 0.002 0.000 0.053 0.000 transport.py:135(_base_send)
400 0.050 0.000 0.050 0.000 {method 'sendall' of '_socket.socket' objects}
400 0.012 0.000 0.032 0.000 basic_codec.py:113(start_read_message)
400 0.006 0.000 0.015 0.000 basic_codec.py:39(start_write_message)
1600 0.007 0.000 0.015 0.000 basic_codec.py:130(_read)
800 0.002 0.000 0.012 0.000 basic_codec.py:156(read_uint32)
The server is a C++ application. I have tried profiling it with gprof but the results of that show practically no time consumed by the application at all. After reading up a bit more about how gprof works and how gprof doesn't accumulate time spent in system calls, this indicates that the program is (obviously) IO bound and that the vast majority of time is spent in blocking system calls.
I won't add the entire output here for brevity but below is an exerpt:
Flat profile:
Each sample counts as 0.01 seconds.
no time accumulated
% cumulative self self total
time seconds seconds calls Ts/call Ts/call name
0.00 0.00 0.00 2407 0.00 0.00 erpc::MessageBuffer::get()
0.00 0.00 0.00 2400 0.00 0.00 erpc::MessageBuffer::setUsed(unsigned short)
0.00 0.00 0.00 2000 0.00 0.00 erpc::MessageBuffer::getUsed() const
0.00 0.00 0.00 1600 0.00 0.00 erpc::MessageBuffer::Cursor::write(void const*, unsigned int)
0.00 0.00 0.00 1201 0.00 0.00 erpc::Codec::getBuffer()
0.00 0.00 0.00 803 0.00 0.00 erpc::MessageBuffer::Cursor::set(erpc::MessageBuffer*)
0.00 0.00 0.00 803 0.00 0.00 erpc::MessageBuffer::getLength() const
0.00 0.00 0.00 802 0.00 0.00 erpc::Codec::reset()
0.00 0.00 0.00 801 0.00 0.00 erpc::TCPTransport::underlyingReceive(unsigned char*, unsigned int)
0.00 0.00 0.00 800 0.00 0.00 erpc::TCPTransport::underlyingSend(unsigned char const*, unsigned int)
0.00 0.00 0.00 800 0.00 0.00 erpc::BasicCodec::read(unsigned int*)
0.00 0.00 0.00 800 0.00 0.00 erpc::BasicCodec::write(int)
0.00 0.00 0.00 800 0.00 0.00 erpc::BasicCodec::write(unsigned int)
0.00 0.00 0.00 800 0.00 0.00 erpc::MessageBuffer::Cursor::read(void*, unsigned int)
0.00 0.00 0.00 800 0.00 0.00 erpc::Service::getServiceId() const
0.00 0.00 0.00 403 0.00 0.00 erpc::Service::getNext()
0.00 0.00 0.00 401 0.00 0.00 erpc::SimpleServer::runInternal(erpc::Codec*)
0.00 0.00 0.00 401 0.00 0.00 erpc::TCPTransport::accept()
0.00 0.00 0.00 401 0.00 0.00 erpc::TCPTransport::receive(erpc::MessageBuffer*)
0.00 0.00 0.00 401 0.00 0.00 erpc::FramedTransport::receive(erpc::MessageBuffer*)
0.00 0.00 0.00 400 0.00 0.00 write_p_version_t_struct(erpc::Codec*, p_version_t const*)
0.00 0.00 0.00 400 0.00 0.00 StaticIF_service::handleInvocation(unsigned int, unsigned int, erpc::Codec*, erpc::MessageBufferFactory*)
0.00 0.00 0.00 400 0.00 0.00 StaticIF_service::get_version_shim(erpc::Codec*, erpc::MessageBufferFactory*, unsigned int)
0.00 0.00 0.00 400 0.00 0.00 erpc::BasicCodec::endReadMessage()
0.00 0.00 0.00 400 0.00 0.00 erpc::BasicCodec::endWriteStruct()
0.00 0.00 0.00 400 0.00 0.00 erpc::BasicCodec::endWriteMessage()
0.00 0.00 0.00 400 0.00 0.00 erpc::BasicCodec::startReadMessage(erpc::_message_type*, unsigned int*, unsigned int*, unsigned int*)
0.00 0.00 0.00 400 0.00 0.00 erpc::BasicCodec::startWriteStruct()
0.00 0.00 0.00 400 0.00 0.00 erpc::BasicCodec::startWriteMessage(erpc::_message_type, unsigned int, unsigned int, unsigned int)
0.00 0.00 0.00 400 0.00 0.00 erpc::FramedTransport::send(erpc::MessageBuffer*)
0.00 0.00 0.00 400 0.00 0.00 erpc::MessageBufferFactory::prepareServerBufferForSend(erpc::MessageBuffer*)
0.00 0.00 0.00 400 0.00 0.00 erpc::Server::processMessage(erpc::Codec*, erpc::_message_type&)
0.00 0.00 0.00 400 0.00 0.00 erpc::Server::findServiceWithId(unsigned int)
0.00 0.00 0.00 400 0.00 0.00 get_version
0.00 0.00 0.00 5 0.00 0.00 erpc::ManuallyConstructed<erpc::SimpleServer>::get()
0.00 0.00 0.00 4 0.00 0.00 operator new(unsigned int, void*)
0.00 0.00 0.00 3 0.00 0.00 erpc::ManuallyConstructed<erpc::SimpleServer>::operator->()
0.00 0.00 0.00 2 0.00 0.00 erpc::ManuallyConstructed<erpc::TCPTransport>::get()
0.00 0.00 0.00 2 0.00 0.00 erpc::ManuallyConstructed<erpc::BasicCodecFactory>::get()
0.00 0.00 0.00 2 0.00 0.00 erpc::Server::addService(erpc::Service*)
0.00 0.00 0.00 2 0.00 0.00 erpc::Service::Service(unsigned int)
0.00 0.00 0.00 2 0.00 0.00 erpc::Service::~Service()
0.00 0.00 0.00 2 0.00 0.00 erpc_add_service_to_server
0.00 0.00 0.00 1 0.00 0.00 _GLOBAL__sub_I__Z5usagev
Using strace, the problem becomes apparent in the first recv of every request. For context, an initial header is transmitted first which indicates the amount of data the request proper contains.
Here's a couple of excerpts from the output (the full output is 2000 lines).
I used the -r, -T and -C switches which show a relative timestamp for each call, prints the time spent in each call and also shows the summary respectively.
In the transaction loop:
0.000161 recv(4, "\10\0", 2, 0) = 2 <0.059478>
0.059589 recv(4, "q\1\1\2\0\1\0\0", 8, 0) = 8 <0.000047>
0.000167 send(4, "\20\0", 2, 0) = 2 <0.000073>
0.000183 send(4, "q\1\1\2\2\1\0\0\235\256\322\2664\22\0\0", 16, 0) = 16 <0.000050>
0.000160 recv(4, "\10\0", 2, 0) = 2 <0.059513>
0.059625 recv(4, "r\1\1\2\0\1\0\0", 8, 0) = 8 <0.000046>
0.000167 send(4, "\20\0", 2, 0) = 2 <0.000071>
0.000182 send(4, "r\1\1\2\2\1\0\0\235\256\322\2664\22\0\0", 16, 0) = 16 <0.000049>
0.000161 recv(4, "\10\0", 2, 0) = 2 <0.059059>
0.059172 recv(4, "s\1\1\2\0\1\0\0", 8, 0) = 8 <0.000047>
0.000183 send(4, "\20\0", 2, 0) = 2 <0.000073>
0.000183 send(4, "s\1\1\2\2\1\0\0\235\256\322\2664\22\0\0", 16, 0) = 16 <0.000049>
0.000161 recv(4, "\10\0", 2, 0) = 2 <0.059330>
0.059441 recv(4, "t\1\1\2\0\1\0\0", 8, 0) = 8 <0.000046>
0.000166 send(4, "\20\0", 2, 0) = 2 <0.000072>
0.000182 send(4, "t\1\1\2\2\1\0\0\235\256\322\2664\22\0\0", 16, 0) = 16 <0.000050>
0.000163 recv(4, "\10\0", 2, 0) = 2 <0.059506>
0.059618 recv(4, "u\1\1\2\0\1\0\0", 8, 0) = 8 <0.000046>
0.000166 send(4, "\20\0", 2, 0) = 2 <0.000070>
0.000181 send(4, "u\1\1\2\2\1\0\0\235\256\322\2664\22\0\0", 16, 0) = 16 <0.000049>
0.000160 recv(4, "\10\0", 2, 0) = 2 <0.059359>
0.059488 recv(4, "v\1\1\2\0\1\0\0", 8, 0) = 8 <0.000048>
0.000175 send(4, "\20\0", 2, 0) = 2 <0.000077>
0.000189 send(4, "v\1\1\2\2\1\0\0\235\256\322\2664\22\0\0", 16, 0) = 16 <0.000051>
0.000165 recv(4, "\10\0", 2, 0) = 2 <0.059496>
0.059612 recv(4, "w\1\1\2\0\1\0\0", 8, 0) = 8 <0.000046>
0.000170 send(4, "\20\0", 2, 0) = 2 <0.000074>
0.000182 send(4, "w\1\1\2\2\1\0\0\235\256\322\2664\22\0\0", 16, 0) = 16 <0.000050>
The summary:
% time seconds usecs/call calls errors syscall
------ ----------- ----------- --------- --------- ----------------
98.59 0.010000 12 801 recv
1.41 0.000143 0 800 send
0.00 0.000000 0 12 read
0.00 0.000000 0 3 write
0.00 0.000000 0 25 19 open
0.00 0.000000 0 7 close
0.00 0.000000 0 1 execve
0.00 0.000000 0 8 lseek
0.00 0.000000 0 6 6 access
0.00 0.000000 0 3 brk
0.00 0.000000 0 1 readlink
0.00 0.000000 0 1 munmap
0.00 0.000000 0 2 setitimer
0.00 0.000000 0 1 uname
0.00 0.000000 0 9 mprotect
0.00 0.000000 0 5 writev
0.00 0.000000 0 2 rt_sigaction
0.00 0.000000 0 16 mmap2
0.00 0.000000 0 16 15 stat64
0.00 0.000000 0 6 fstat64
0.00 0.000000 0 1 socket
0.00 0.000000 0 1 bind
0.00 0.000000 0 1 listen
0.00 0.000000 0 1 accept
0.00 0.000000 0 1 setsockopt
0.00 0.000000 0 1 set_tls
------ ----------- ----------- --------- --------- ----------------
100.00 0.010143 1731 40 total
In passing, I am not sure I completely understand the summary. The summary suggests that recv happens very quick compared to the time indicated in each call to recv.
It looks like the time spent in the first recv is what is killing the RPC system at nearly 60ms per call. Am I misreading this? I am not sure of the units but so I am guessing seconds.
So, after profiling both the client and the server, it appears the vast amount of time is spent in recv.
If we assumed that extra time spent in the intitial recv on the server side was because the client was still processing something and hadn't send it yet, that should have shown up when profiling the client.
Any suggestions you may have as to how to further debug this would be greatly appreciated.
Thanks!

Related

gnuplot date output in X doesn't display right

Im parsing linux sar output and i have dat file which looks like this :
07:09:49 CPU %usr %nice %sys %iowait %steal %irq %soft %guest %idle
07:09:51 all 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 100.00
07:09:53 all 11.82 0.00 0.13 0.00 0.00 0.00 0.00 0.00 88.05
07:09:55 all 53.99 0.00 0.63 0.00 0.13 0.00 0.13 0.00 45.12
07:09:57 all 55.18 0.00 0.25 0.00 0.00 0.00 0.00 0.00 44.57
07:09:59 all 66.58 0.00 0.51 0.00 0.00 0.00 0.13 0.00 32.78
07:10:01 all 71.90 0.00 0.63 0.13 0.00 0.00 0.13 0.00 27.22
07:10:03 all 70.24 0.00 0.63 0.00 0.00 0.00 0.13 0.00 29.00
07:10:05 all 55.39 0.00 0.63 0.00 0.00 0.00 0.13 0.00 43.85
07:10:07 all 72.90 0.00 0.38 0.00 0.00 0.00 0.00 0.00 26.73
07:10:09 all 60.96 0.00 0.38 0.00 0.13 0.00 0.13 0.00 38.40
07:10:11 all 76.60 0.00 0.63 0.00 0.00 0.00 0.13 0.00 22.65
07:10:13 all 53.87 0.00 0.76 0.00 0.00 0.00 0.13 0.00 45.25
07:10:15 all 46.73 0.00 0.63 0.00 0.00 0.00 0.00 0.00 52.64
07:10:17 all 56.37 0.00 0.50 0.00 0.00 0.00 0.13 0.00 43.00
07:10:19 all 58.15 0.00 0.63 0.00 0.00 0.00 0.13 0.00 41.09
07:10:21 all 61.26 0.00 0.75 0.00 0.00 0.00 0.13 0.00 37.86
07:10:23 all 51.50 0.00 0.75 0.12 0.12 0.00 0.25 0.00 47.2
set title ' CPU usage'
set xdata time
set timefmt '%H:%M:%S'
set xlabel 'time'
set ylabel 'CPU Usage'
set style data lines
plot 'filename.dat' using 1:3 title '0.6'
pause -1
the out put in the X data is not related to the time presented in the file
You have to set the formatting of the tic labels:
set format x '%H:%M:%S'

concatenate dataframes with different column ordering [duplicate]

This question already has answers here:
Pandas concat yields ValueError: Plan shapes are not aligned
(7 answers)
Closed 6 years ago.
I am parsing data from excel files and the columns of the resulting DataFrame may or may not align to a base DataFramewhere I want to stack several parsed DataFrame.
Lets call the DataFrame I parse from data A, and the base DataFrame df_A.
I read an excel shee resulting in A=
Index AGUB AGUG MUEB MUEB SIL SIL SILB SILB
2012-01-01 00:00:00 0.00 0 0.00 50.78 0.00 0.00 0.00 0.00
2012-01-01 01:00:00 0.00 0 0.00 53.15 0.00 53.15 0.00 0.00
2012-01-01 02:00:00 0.00 0 0.00 0.00 53.15 53.15 53.15 53.15
2012-01-01 03:00:00 0.00 0 0.00 0.00 0.00 55.16 0.00 0.00
2012-01-01 04:00:00 0.00 0 0.00 0.00 0.00 0.00 0.00 0.00
2012-01-01 05:00:00 48.96 0 0.00 0.00 0.00 0.00 0.00 0.00
2012-01-01 06:00:00 0.00 0 0.00 0.00 0.00 0.00 0.00 0.00
2012-01-01 07:00:00 0.00 0 0.00 0.00 0.00 0.00 0.00 0.00
2012-01-01 08:00:00 0.00 0 0.00 0.00 0.00 0.00 0.00 0.00
2012-01-01 09:00:00 52.28 0 0.00 0.00 0.00 0.00 0.00 0.00
2012-01-01 10:00:00 0.00 0 0.00 0.00 0.00 0.00 0.00 0.00
2012-01-01 11:00:00 36.93 0 0.00 0.00 0.00 0.00 0.00 0.00
2012-01-01 12:00:00 0.00 0 0.00 0.00 0.00 0.00 0.00 0.00
2012-01-01 13:00:00 0.00 0 0.00 0.00 0.00 0.00 0.00 50.00
2012-01-01 14:00:00 0.00 0 0.00 0.00 0.00 0.00 0.00 34.01
2012-01-01 15:00:00 0.00 0 0.00 0.00 0.00 0.00 0.00 0.00
2012-01-01 16:00:00 0.00 0 0.00 0.00 0.00 0.00 0.00 0.00
2012-01-01 17:00:00 53.00 0 0.00 0.00 0.00 0.00 0.00 0.00
2012-01-01 18:00:00 0.00 75 0.00 75.00 0.00 75.00 0.00 0.00
2012-01-01 19:00:00 0.00 70 0.00 70.00 0.00 0.00 0.00 0.00
2012-01-01 20:00:00 0.00 0 0.00 0.00 0.00 0.00 0.00 0.00
2012-01-01 21:00:00 0.00 0 0.00 0.00 0.00 0.00 0.00 0.00
2012-01-01 22:00:00 0.00 0 0.00 0.00 0.00 0.00 0.00 0.00
2012-01-01 23:00:00 0.00 0 53.45 53.45 0.00 0.00 0.00 0.00
I create the base dataframe:
units = ['MUE', 'MUEB', 'SIL', 'SILB', 'AGUG', 'AGUB', 'MUEBP', 'MUELP']
df_A = pd.DataFrame(columns=units)
df_A = pd.concat([df_A, A], axis=0)
Usually with concat if A had less columns than df_A it'll be fine, but in this case the only difference in the columns is the order. the concatenation leads to the following error:
ValueError: Plan shapes are not aligned
I'd like to know how to concatenate the two dataframes with the column order given by df_A.
I've tried this and it doesn't matter whether there are more columns in the source, or target defined DataFrame - either way, the result is a dataframe that consists of a union of all supplied columns (with empty columns specified in the target, but not populated by the source populated with NaN).
Where I have been able to reproduce your error is where the column names in either the source or target dataframe include a duplicate name (or empty column names).
In your example, various columns appear more than once in your source file. I don't think concat copes very well with these kinds of duplicate columns.
import pandas as pd
s1 = [0,1,2,3,4,5]
s2 = [0,0,0,0,1,1]
A = pd.DataFrame([s2,s1],columns=['A','B','C','D','E','F'])
Resulting in:
A B C D E F
-----------
0 0 0 0 1 1
0 1 2 3 4 5
Take a subset of columns and use them to create a new dataframe called B
B = A[['A','C','E']]
A C E
-----
0 0 1
0 2 4
Create a new empty target dataframe
col_names = ['D','A','C','B']
Z = pd.DataFrame(columns=col_names)
D A C B
-------
And concatenate the two:
Z = pd.concat([B,Z],axis=0)
A C D E
0 0 NaN 1
0 2 NaN 4
Works fine!
But if I recreate the empty dataframe using columns as so:
col_names = ['D','A','C','D']
Z = pd.DataFrame(columns=col_names)
D A C D
And try to concatenate:
col_names = ['D','A','C','D']
Z = pd.DataFrame(columns=col_names)
Then I get the error you describe.
It's because of the duplicate columns in the data (SIL). See: Pandas concat gives error ValueError: Plan shapes are not aligned

Grep specific paragraph of command output in Linux

I'm trying to parse iostat -x 1 2 command's output to monitor remote computer from my java application.
This is the output:
Linux 2.6.39-400.126.1.el5uek (abcprod.abc-en.local) 02/27/2014
avg-cpu: %user %nice %system %iowait %steal %idle
2.57 0.00 0.87 0.01 0.00 96.56
Device: rrqm/s wrqm/s r/s w/s rsec/s wsec/s avgrq-sz avgqu-sz await svctm %util
sda 0.00 54.24 0.35 10.64 6.95 518.97 47.89 0.01 1.06 0.19 0.21
sda1 0.00 0.00 0.00 0.00 0.00 0.00 68.40 0.00 2.08 0.94 0.00
sda2 0.00 54.23 0.35 10.64 6.94 518.97 47.89 0.01 1.06 0.19 0.21
dm-0 0.00 0.00 0.18 48.77 4.18 390.19 8.06 0.08 1.63 0.02 0.10
dm-1 0.00 0.00 0.00 0.00 0.00 0.00 8.00 0.00 1.06 0.18 0.00
dm-2 0.00 0.00 0.00 0.00 0.00 0.00 8.00 0.00 1.78 0.14 0.00
dm-3 0.00 0.00 0.17 16.10 2.76 128.78 8.09 0.03 2.10 0.07 0.11
avg-cpu: %user %nice %system %iowait %steal %idle
11.61 0.00 3.20 0.00 0.00 85.19
Device: rrqm/s wrqm/s r/s w/s rsec/s wsec/s avgrq-sz avgqu-sz await svctm %util
sda 0.00 191.00 0.00 43.00 0.00 1872.00 43.53 0.00 0.09 0.05 0.20
sda1 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00
sda2 0.00 191.00 0.00 43.00 0.00 1872.00 43.53 0.00 0.09 0.05 0.20
dm-0 0.00 0.00 0.00 234.00 0.00 1872.00 8.00 0.00 0.02 0.01 0.20
dm-1 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00
dm-2 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00
dm-3 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00
I only need the second part of the output(beginning from fourth paragraph):
avg-cpu: %user %nice %system %iowait %steal %idle
11.61 0.00 3.20 0.00 0.00 85.19
Device: rrqm/s wrqm/s r/s w/s rsec/s wsec/s avgrq-sz avgqu-sz await svctm %util
sda 0.00 191.00 0.00 43.00 0.00 1872.00 43.53 0.00 0.09 0.05 0.20
sda1 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00
sda2 0.00 191.00 0.00 43.00 0.00 1872.00 43.53 0.00 0.09 0.05 0.20
dm-0 0.00 0.00 0.00 234.00 0.00 1872.00 8.00 0.00 0.02 0.01 0.20
dm-1 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00
dm-2 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00
dm-3 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00
Do not how to use grep to do it, but you can use perl:
iostat -x 1 2 | perl -e 'local $/=""; #p=<STDIN>; print #p[3,4];'
Some explanations:
local, see perlsub
A local modifies its listed variables to be "local" to the enclosing block, eval, or do FILE --and to any subroutine called from within that block. A local just gives temporary values to global (meaning package) variables.
$/, see perlvar
The input record separator, newline by default. This influences Perl's idea of what a "line" is.
If the number of the lines for the first paragraph is fixed you can use sed like this
iostat -x 1 2 | sed 'N,$!d' - where N is the number of the lines of first paragraph

Parsing iostat output

the output of iostat is like that:
Device: rrqm/s wrqm/s r/s w/s rkB/s wkB/s avgrq-sz avgqu-sz await svctm %util
sda 0.00 2.40 0.01 3.92 0.16 25.28 12.95 0.05 12.81 6.58 2.58
sda1 0.00 0.00 0.00 0.00 0.00 0.00 25.86 0.00 6.57 5.38 0.00
sda2 0.00 2.40 0.01 3.92 0.16 25.28 12.95 0.05 12.81 6.58 2.58
sdb 0.00 0.00 0.00 0.00 0.00 0.00 8.00 0.00 30.37 20.16 0.00
VG00-LogVol00
0.00 0.00 0.00 0.70 0.02 2.79 8.04 0.02 23.72 3.71 0.26
VG00-LogVol04
0.00 0.00 0.00 4.31 0.03 17.26 8.01 0.07 16.74 4.32 1.87
VG00-LogVol03
0.00 0.00 0.00 0.24 0.00 0.98 8.01 0.01 21.37 8.52 0.21
VG00-LogVol08
0.00 0.00 0.00 0.00 0.00 0.00 8.00 0.00 14.03 2.31 0.00
VG00-LogVol01
0.00 0.00 0.00 0.00 0.00 0.00 8.03 0.00 127.25 1.17 0.00
VG00-LogVol07
0.00 0.00 0.00 0.00 0.00 0.00 8.00 0.00 2.42 1.72 0.00
VG00-LogVol06
0.00 0.00 0.00 0.80 0.01 3.21 8.02 0.01 10.28 4.89 0.39
VG00-LogVol02
0.00 0.00 0.01 0.26 0.10 1.04 8.52 0.01 52.88 6.01 0.16
VG00-LogVol05
0.00 0.00 0.00 0.00 0.00 0.00 8.00 0.00 3.73 0.33 0.00
I try to parse the output but when I reach "VG00-LogVol00", "VG00-LogVol04" I have problems parsing the text. Is there a way to remove the extra lines using sed?
Thank you
If VG00 is always present in split lines, you could do it like this:
sed '/VG00/ { N; s/\n// }'
With the copy/pasted text I have the following aligns the columns (GNU sed and BSD sed):
sed '/VG00/ { N; s/\n//; s/ \{5,\}/ /; }'
Output:
Device: rrqm/s wrqm/s r/s w/s rkB/s wkB/s avgrq-sz avgqu-sz await svctm %util
sda 0.00 2.40 0.01 3.92 0.16 25.28 12.95 0.05 12.81 6.58 2.58
sda1 0.00 0.00 0.00 0.00 0.00 0.00 25.86 0.00 6.57 5.38 0.00
sda2 0.00 2.40 0.01 3.92 0.16 25.28 12.95 0.05 12.81 6.58 2.58
sdb 0.00 0.00 0.00 0.00 0.00 0.00 8.00 0.00 30.37 20.16 0.00
VG00-LogVol00 0.00 0.00 0.00 0.70 0.02 2.79 8.04 0.02 23.72 3.71 0.26
VG00-LogVol04 0.00 0.00 0.00 4.31 0.03 17.26 8.01 0.07 16.74 4.32 1.87
VG00-LogVol03 0.00 0.00 0.00 0.24 0.00 0.98 8.01 0.01 21.37 8.52 0.21
VG00-LogVol08 0.00 0.00 0.00 0.00 0.00 0.00 8.00 0.00 14.03 2.31 0.00
VG00-LogVol01 0.00 0.00 0.00 0.00 0.00 0.00 8.03 0.00 127.25 1.17 0.00
VG00-LogVol07 0.00 0.00 0.00 0.00 0.00 0.00 8.00 0.00 2.42 1.72 0.00
VG00-LogVol06 0.00 0.00 0.00 0.80 0.01 3.21 8.02 0.01 10.28 4.89 0.39
VG00-LogVol02 0.00 0.00 0.01 0.26 0.10 1.04 8.52 0.01 52.88 6.01 0.16
VG00-LogVol05 0.00 0.00 0.00 0.00 0.00 0.00 8.00 0.00 3.73 0.33 0.00
I'd go for
sed -e '/^\([^[:space:]]\+\)$/{N;s/\n//;}'
assuming the device lines have no whitespace.
But I'd also look into the possibility to influence iostat and make it produce different output. I don't know the options there, though.

How to Interpret I/O on ksar, sar

Device: rrqm/s wrqm/s r/s w/s rkB/s wkB/s avgrq-sz avgqu-sz await svctm %util
sda 0.01 1.38 0.02 0.51 0.37 7.56 29.42 0.02 31.72 6.15 0.33
sda1 0.00 0.00 0.00 0.00 0.00 0.00 53.57 0.00 71.60 15.33 0.00
sda2 0.00 0.00 0.00 0.00 0.00 0.00 38.77 0.00 14.13 13.56 0.00
sda3 0.00 0.20 0.02 0.11 0.30 1.23 24.46 0.00 35.65 9.69 0.12
sda4 0.00 0.00 0.00 0.00 0.00 0.00 2.00 0.00 8.12 8.12 0.00
sda5 0.00 1.11 0.01 0.24 0.06 5.43 44.15 0.01 44.22 7.06 0.18
sda6 0.00 0.00 0.00 0.00 0.00 0.01 39.47 0.00 51.98 17.60 0.00
sda7 0.00 0.00 0.00 0.00 0.00 0.00 23.46 0.00 23.69 13.80 0.00
sda8 0.00 0.00 0.00 0.01 0.00 0.04 11.37 0.00 36.27 24.38 0.02
sda9 0.00 0.05 0.00 0.16 0.00 0.84 10.79 0.00 8.46 7.56 0.12
I've a graph that looks like this...Is it consider high at 12.5 /s ?How do i interpret if i/o is good or bad?

Resources