Giter Club home page Giter Club logo

connstat's People

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

connstat's Issues

connstat should output possible fields when providing an invalid command-line field

connstat outputs a python backtrace when I try and output an invalid field:

delphix@localhost:~$ connstat -e -F lport=2049 -o garbage -i 1
Traceback (most recent call last):
  File "/usr/bin/connstat", line 209, in <module>
    output_fields.append(Field[item])
  File "/usr/lib/python3.6/enum.py", line 329, in __getitem__
    return cls._member_map_[name]
KeyError: 'garbage'

Build failure when KVERS environmental variable set

With #10 a bug was introduced in the configure.sh script. When the KVERS environmental variable is set(instead of allowing the configure script to set it based on "uname -r") the KCENTEVERS variable would not be set at all. The result in the following build error:

make[3]: Entering directory '/usr/src/linux-headers-4.15.0-45-generic'
CC [M] /home/ubuntu/linux-pkg/packages/connstat/tmp/repo/module/src/connstat.o
/home/ubuntu/linux-pkg/packages/connstat/tmp/repo/module/src/connstat.c: In function ‘get_tcp4_sock’:
/home/ubuntu/linux-pkg/packages/connstat/tmp/repo/module/src/connstat.c:106:26: error: operator '>' has no left operand
#if (KERNEL_CENTEVERSION > 415)
^
/home/ubuntu/linux-pkg/packages/connstat/tmp/repo/module/src/connstat.c: At top level:
/home/ubuntu/linux-pkg/packages/connstat/tmp/repo/module/src/connstat.c:190:26: error: operator '>' has no left operand
#if (KERNEL_CENTEVERSION > 415)
^

connstat command can't handle running on an older kernel

If a new field is added to connstat, both the connstat module (which implements the /proc/net/tcp_stats interface), and the command (which consumes that output) must be updated. If the connstat command is updated and one attempts to run it with -o all before rebooting to apply the kernel change, it will fail as follows:

delphix@guild:~$ connstat -o all
Traceback (most recent call last):
  File "/usr/bin/connstat", line 236, in <module>
    output += connstat_regurgitate()
  File "/usr/bin/connstat", line 162, in connstat_regurgitate
    line_out += sformat.format(line_str_list[f.index], format)
IndexError: list index out of range

This is because the connstat command knows about an extra field that the kernel is not (yet) outputting.

connstat should gracefully handle keyboard interrupt

I shouldn't see a python backtrace when hitting ^C with connstat:

delphix@localhost:~$ connstat -e -F lport=2049 -i 1
          laddr lport          raddr rport       state
 192.168.100.34  2049192.168.100.183   852 ESTABLISHED
          laddr lport          raddr rport       state
 192.168.100.34  2049192.168.100.183   852 ESTABLISHED
^CTraceback (most recent call last):
  File "/usr/bin/connstat", line 247, in <module>
    time.sleep(args.SECONDS)
KeyboardInterrupt

would like to display TCP receive queue size with connstat

The amount of data in the receive queue is helpful to understand certain performance problems. A full receive queue is indicative that the receiving application isn't reading data fast enough to keep pace with the sender, and in that case, an investigation would focus on why the application can't read faster.

connstat suna column doesn't seem to represent send+unacknowledged data

In a transmit thoughput test where the window should always be full, I've noticed that the connstat suna column is almost always 0:

delphix@localhost:~$ connstat -P -e -F lport=2049 -o outbytes,swnd,cwnd,suna -i 1
286642251936,8379904,9851748,0
287869152636,6086144,9851748,0
289368120416,8379904,9851748,0
290574077972,8140288,9851748,0
292022492724,8379904,9851748,0
293249708272,7639040,9851748,0
294717983420,8379904,9851748,0
295929200080,8379904,9851748,0
...

Note here that we're transmitting at around 10Gbps, so suna should be nearly equal to the send window.

timestamp output is corrupt

Thu Dec  5 00:03:05 UTC 2019
= 0
          laddr lport          raddr rport       state
        0.0.0.0   873        0.0.0.0     0      LISTEN
      127.0.0.1  8586        0.0.0.0     0      LISTEN
...

Notice the = 0 there. That shouldn't be there at all. In parsable output mode, we see the same thing:

delphix@gibson:~$ connstat -T d -P -o laddr
Thu Dec  5 00:04:18 UTC 2019
= 0
0.0.0.0
127.0.0.1

In parsable output mode, there should be an equal sign at the start of the timestamp line.

For the other timestamp format, we have the problem that the equal sign is in the right place, but it shows up for both parsable and non-parsable mode. It should only be there for parsable output mode.

Build failure when running on Ubuntu 18.10 based VM

When trying to build this on an Ubuntu 18.10 based VM, it failed with the following errors:

make[5]: Entering directory '/usr/src/linux-headers-4.18.0-1006-aws'
  CC [M]  /home/ubuntu/connstat/module/src/connstat.o
/home/ubuntu/connstat/module/src/connstat.c: In function ‘get_tcp4_sock’:                                                                  
/home/ubuntu/connstat/module/src/connstat.c:105:17: error: implicit declaration of function ‘sk_state_load’; did you mean ‘inet_sk_state_load’? [-Werror=implicit-function-declaration]
         state = sk_state_load(sk);
                 ^~~~~~~~~~~~~
                 inet_sk_state_load
/home/ubuntu/connstat/module/src/connstat.c: At top level:
/home/ubuntu/connstat/module/src/connstat.c:186:20: error: ‘tcp_seq_open’ undeclared here (not in a function); did you mean ‘tcp_seq_stop’?
         .open    = tcp_seq_open,
                    ^~~~~~~~~~~~
                    tcp_seq_stop
/home/ubuntu/connstat/module/src/connstat.c:189:20: error: ‘seq_release_net’ undeclared here (not in a function); did you mean ‘seq_release’?
         .release = seq_release_net
                    ^~~~~~~~~~~~~~~
                    seq_release
/home/ubuntu/connstat/module/src/connstat.c:193:10: error: ‘struct tcp_seq_afinfo’ has no member named ‘name’                              
         .name           = "stats_tcp",
          ^~~~
/home/ubuntu/connstat/module/src/connstat.c:193:27: warning: initialization of ‘short unsigned int’ from ‘char *’ makes integer from pointer without a cast [-Wint-conversion]
         .name           = "stats_tcp",
                           ^~~~~~~~~~~
/home/ubuntu/connstat/module/src/connstat.c:193:27: note: (near initialization for ‘connstat_seq_afinfo.family’)                           
/home/ubuntu/connstat/module/src/connstat.c:193:27: error: initializer element is not computable at load time                              
/home/ubuntu/connstat/module/src/connstat.c:193:27: note: (near initialization for ‘connstat_seq_afinfo.family’)                           
/home/ubuntu/connstat/module/src/connstat.c:195:10: error: ‘struct tcp_seq_afinfo’ has no member named ‘seq_fops’                          
         .seq_fops       = &connstat_seq_fops,
          ^~~~~~~~
/home/ubuntu/connstat/module/src/connstat.c:195:27: warning: excess elements in struct initializer                                         
         .seq_fops       = &connstat_seq_fops,
                           ^
/home/ubuntu/connstat/module/src/connstat.c:195:27: note: (near initialization for ‘connstat_seq_afinfo’)                                  
/home/ubuntu/connstat/module/src/connstat.c:196:10: error: ‘struct tcp_seq_afinfo’ has no member named ‘seq_ops’                           
         .seq_ops        = {
          ^~~~~~~
/home/ubuntu/connstat/module/src/connstat.c:196:27: error: extra brace group at end of initializer                                         
         .seq_ops        = {
                           ^
/home/ubuntu/connstat/module/src/connstat.c:196:27: note: (near initialization for ‘connstat_seq_afinfo’)                                  
/home/ubuntu/connstat/module/src/connstat.c:196:27: warning: excess elements in struct initializer                                         
/home/ubuntu/connstat/module/src/connstat.c:196:27: note: (near initialization for ‘connstat_seq_afinfo’)                                  
/home/ubuntu/connstat/module/src/connstat.c: In function ‘connstat_proc_init_net’:                                                         
/home/ubuntu/connstat/module/src/connstat.c:203:16: error: implicit declaration of function ‘tcp_proc_register’; did you mean ‘tcp4_proc_exit’? [-Werror=implicit-function-declaration]
         return tcp_proc_register(net, &connstat_seq_afinfo);
                ^~~~~~~~~~~~~~~~~
                tcp4_proc_exit
/home/ubuntu/connstat/module/src/connstat.c: In function ‘connstat_proc_exit_net’:                                                         
/home/ubuntu/connstat/module/src/connstat.c:208:2: error: implicit declaration of function ‘tcp_proc_unregister’; did you mean ‘proto_unregister’? [-Werror=implicit-function-declaration]
  tcp_proc_unregister(net, &connstat_seq_afinfo);
  ^~~~~~~~~~~~~~~~~~~
  proto_unregister
cc1: some warnings being treated as errors

The ubuntu-18-10 image on DCOA can be used to reproduce this error.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.