[uWSGI] gather TCP socket metrics with TCP_INFO?

est electronixtar at gmail.com
Wed Oct 9 03:07:37 CEST 2013


Hi,

Upon further thinking, I think TCP metrics on uWSGI is not as useful as on
the most front nginx level.

Strangely, there's no doc found on new wiki.nginx.org site, but on the old
doc site

http://nginx.org/en/docs/http/ngx_http_core_module.html#variables

$tcpinfo_rtt, $tcpinfo_rttvar, $tcpinfo_snd_cwnd, $tcpinfo_rcv_space
information about the client TCP connection; available on systems that
support the TCP_INFO socket option



On Tue, Oct 8, 2013 at 6:04 PM, Łukasz Mierzwa <l.mierzwa at gmail.com> wrote:

> There are dozen of monitoring tools that can provide any system related
> stats, uWSGI should focus on application metrics, I don't think we need to
> reimplement statsd or collectd.
> But if metrics subsystem will finally land and one can just add option to
> push lines from /proc files to carbon, than in many cases it should be it's
> just a matter of configuration.
>
>
> 2013/10/8 Roberto De Ioris <roberto at unbit.it>
>
>>
>> > Hi guys,
>> >
>> > I am recently interested in socket programming. I found this gem in
>> kernel
>> > socket:
>> >
>> > http://lxr.free-electrons.com/source/include/uapi/linux/tcp.h#L148
>> >
>> > Example code like this:
>> >
>> > import socket, struct
>> > s=socket.socket(socket.AF_INET, socket.SOCK_STREAM)
>> > s.connect(('www.google.com', 80))
>> > s.send('GET / HTTP/1.1\r\n\r\n')
>> > s.recv(1024)
>> > a=struct.unpack("B"*7+"I"*24, s.getsockopt(socket.SOL_TCP,
>> > socket.TCP_INFO,
>> > 104))
>> > b=['tcpi_state', 'tcpi_ca_state', 'tcpi_retransmits', 'tcpi_probes',
>> > 'tcpi_backoff', 'tcpi_options', 'tcpi_snd_wscale+tcpi_rcv_wscale',
>> > 'tcpi_rto', 'tcpi_ato', 'tcpi_snd_mss', 'tcpi_rcv_mss', 'tcpi_unacked',
>> > 'tcpi_sacked', 'tcpi_lost', 'tcpi_retrans', 'tcpi_fackets',
>> > 'tcpi_last_data_sent', 'tcpi_last_ack_sent   ', 'tcpi_last_data_recv',
>> > 'tcpi_last_ack_recv', 'tcpi_pmtu', 'tcpi_rcv_ssthresh', 'tcpi_rtt',
>> > 'tcpi_rttvar', 'tcpi_snd_ssthresh', 'tcpi_snd_cwnd', 'tcpi_advmss',
>> > 'tcpi_reordering', 'tcpi_rcv_rtt', 'tcpi_rcv_space',
>> > 'tcpi_total_retrans',]
>> > print '\r\n'.join('%s: %s' % x for x in zip(b, a))
>> >
>> >
>> > I find metrics like tcpi_lost, tcpi_retrans, tcpi_rtt, tcpi_rcv_rtt
>> > potentially very useful to monitor server performance. It would be
>> awesome
>> > if uWSGI consider adding some of the info to the stats server. (or some
>> > where better)
>> >
>> > What do you guys think?
>>
>>
>>
>> Hi, TCP_INFO is currently used to get the size of the listen queue:
>>
>> https://github.com/unbit/uwsgi/blob/master/core/master.c#L180
>>
>> i do not know which (other) kind of infos could be useful.
>>
>> We are about to release 1.9.18, soon after we will finally merge the
>> metric subsystem so if you want to add metrics it should be pretty easy
>> (you will need to write in c obviously but there will be no more than a
>> dozens of lines)
>>
>> --
>> Roberto De Ioris
>> http://unbit.it
>> _______________________________________________
>> uWSGI mailing list
>> uWSGI at lists.unbit.it
>> http://lists.unbit.it/cgi-bin/mailman/listinfo/uwsgi
>>
>
>
>
> --
> Łukasz Mierzwa
>
> _______________________________________________
> uWSGI mailing list
> uWSGI at lists.unbit.it
> http://lists.unbit.it/cgi-bin/mailman/listinfo/uwsgi
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.unbit.it/pipermail/uwsgi/attachments/20131009/70a3b8ab/attachment-0001.html>


More information about the uWSGI mailing list