SCTP Socket State Parser

Parsers provided by this module include:

SCTPEps - file /proc/net/sctp/eps

SCTPAsc - file /proc/net/sctp/assocs on RHEL-6

SCTPAsc7 - file /proc/net/sctp/assocs on RHEL-7

SCTPSnmp - file /proc/net/sctp/snmp

class insights.parsers.sctp.SCTPAsc(*args, **kwargs)[source]

Bases: SCTPAscBase

This parser parses the file /proc/net/sctp/assocs from RHEL-6. It has different columns as compare to RHEL-7.

Typical contents of /proc/net/sctp/assocs on RHEL-6 file are:

ASSOC     SOCK   STY SST ST HBKT ASSOC-ID TX_QUEUE RX_QUEUE UID INODE LPORT RPORT LADDRS <-> RADDRS HBINT INS OUTS MAXRT T1X T2X RTXC
ffff88045ac7e000 ffff88062077aa00 2   1   4  1205  963        0        0     200 273361167 11567 11166  10.0.0.102 10.0.0.70 <-> *10.0.0.109 10.0.0.77      1000     2     2   10    0    0        0
ffff88061fbf2000 ffff88060ff92500 2   1   4  1460  942        0        0     200 273360669 11566 11167  10.0.0.102 10.0.0.70 <-> *10.0.0.109 10.0.0.77      1000     2     2   10    0    0        0

Output data is stored in the list of dictionaries

Examples

>>> type(sctp_asc)
<class 'insights.parsers.sctp.SCTPAsc'>
>>> sorted(sctp_asc.sctp_local_ports) == sorted(['11567','11566'])
True
>>> sorted(sctp_asc.sctp_remote_ports) == sorted(['11166','11167'])
True
>>> sorted(sctp_asc.sctp_local_ips) == sorted(['10.0.0.102', '10.0.0.70'])
True
>>> sorted(sctp_asc.sctp_remote_ips) == sorted(['*10.0.0.109', '10.0.0.77'])
True
>>> sorted(sctp_asc.search(local_port='11566')) == sorted([{'init_chunks_send': '0', 'uid': '200', 'shutdown_chunks_send': '0', 'max_outstream': '2', 'tx_que': '0', 'inode': '273360669', 'hrtbt_intrvl': '1000', 'sk_type': '2', 'remote_addr': ['*10.0.0.109', '10.0.0.77'], 'data_chunks_retrans': '0', 'local_addr': ['10.0.0.102', '10.0.0.70'], 'asc_id': '942', 'max_instream': '2', 'remote_port': '11167', 'asc_state': '4', 'max_retrans_atmpt': '10', 'sk_state': '1', 'socket': 'ffff88060ff92500', 'asc_struct': 'ffff88061fbf2000', 'local_port': '11566', 'hash_bkt': '1460', 'rx_que': '0'}])
True
class insights.parsers.sctp.SCTPAsc7(*args, **kwargs)[source]

Bases: SCTPAscBase

This parser parses the file /proc/net/sctp/assocs from RHEL-7. It has different columns as compare to RHEL-6.

Typical contents of /proc/net/sctp/assocs on RHEL-7 file are:

ASSOC     SOCK   STY SST ST HBKT ASSOC-ID TX_QUEUE RX_QUEUE UID INODE LPORT RPORT LADDRS <-> RADDRS HBINT INS OUTS MAXRT T1X T2X RTXC wmema wmemq sndbuf rcvbuf
ffff8805d36b3000 ffff880f8911f380 0   10  3  0    12754        0        0       0 496595 3868   3868  10.131.222.5 <-> *10.131.160.81 10.131.176.81        30000    17    10   10    0    0        0        11        12  1000000  2000000
ffff8805f17e1000 ffff881004aff380 0   10  3  0    12728        0        0       0 532396 3868   3868  10.131.222.3 <-> *10.131.160.81 10.131.176.81        30000    17    10   10    0    0        0        13        14  3000000  4000000

Output data is stored in the list of dictionaries

Examples

>>> type(sctp_asc_7)
<class 'insights.parsers.sctp.SCTPAsc7'>
>>> sctp_asc_7.sctp_local_ips == sorted(['10.131.222.5', '10.131.222.3'])
True
>>> sctp_asc_7.data[0]['rcvbuf']
'2000000'
class insights.parsers.sctp.SCTPAscBase(context)[source]

Bases: Parser

This parser parses the content of /proc/net/sctp/assocs file. And returns a list of dictionaries. The dictionary contains details of individual SCTP endpoint, which includes Association Struct, Socket, Socket type, Socket State, Association state, hash bucket, association id, tx queue, rx queue, uid, inode, local port, remote port, ‘local addr, remote addr, heartbeat interval, max in-stream, max out-stream, max retransmission attempt, number of init chunks send, number of shutdown chunks send, data chunks retransmitted’

parse_content(content)[source]

This method must be implemented by classes based on this class.

property sctp_local_ips

This function returns a list of all local peer’s ip addresses if SCTP endpoints are created, else [].

Type

(list)

property sctp_local_ports

This function returns a list of SCTP local peer ports if SCTP endpoints are created, else [].

Type

(list)

property sctp_remote_ips

This function returns a list of all remote peer’s ip addresses if SCTP endpoints are created, else [].

Type

(list)

property sctp_remote_ports

This function returns a list of SCTP remote peer ports if SCTP endpoints are created, else [].

Type

(list)

search(**args)[source]
(list): This function return a list of all SCTP associations when args search matches,

when args search do not match then it returns [].

class insights.parsers.sctp.SCTPEps(context)[source]

Bases: Parser

This parser parses the content of /proc/net/sctp/eps file. It returns a list of dictionaries. The dictionary contains detail information of individual SCTP endpoint, which includes Endpoints, Socket, Socket type, Socket State, hash bucket, bind port, UID, socket inodes, Local IP address.

Typical contents of /proc/net/sctp/eps file are:

ENDPT            SOCK             STY SST HBKT LPORT   UID INODE     LADDRS
ffff88017e0a0200 ffff880300f7fa00 2   10  29   11165   200 299689357 10.0.0.102 10.0.0.70
ffff880612e81c00 ffff8803c28a1b00 2   10  30   11166   200 273361203 10.0.0.102 10.0.0.70 172.31.1.2

Output data is stored in the list of dictionaries

Examples

>>> type(sctp_info)
<class 'insights.parsers.sctp.SCTPEps'>
>>> sorted(sctp_info.sctp_local_ports) == sorted(['11165', '11166'])
True
>>> sorted(sctp_info.sctp_local_ips) == sorted(['10.0.0.102', '10.0.0.70', '172.31.1.2'])
True
>>> sorted(sctp_info.search(local_port="11165")) == sorted([{'endpoints': 'ffff88017e0a0200', 'socket': 'ffff880299f7fa00', 'sk_type': '2', 'sk_state': '10', 'hash_bkt': '29', 'local_port': '11165', 'uid': '200', 'inode': '299689357', 'local_addr': ['10.0.0.102', '10.0.0.70']}])
True
>>> len(sctp_info.search(local_port="11165")) == 1
True
>>> len(sctp_info.search(endpoints="ffff88017e0a0200")) == 1
True
>>> sctp_info.sctp_eps_ips
{'ffff88017e0a0200': ['10.0.0.102', '10.0.0.70'], 'ffff880612e81c00': ['10.0.0.102', '10.0.0.70', '172.31.1.2']}
parse_content(content)[source]

This method must be implemented by classes based on this class.

property sctp_eps_ips

This function returns a dict of all endpoints and corresponding local ip addresses used by SCTP endpoints if SCTP endpoints are created, else {}.

Type

(dict)

property sctp_local_ips

This function returns a list of all local ip addresses if SCTP endpoints are created, else [].

Type

(list)

property sctp_local_ports

This function returns a list of SCTP ports if SCTP endpoints are created, else [].

Type

(list)

search(**args)[source]
(list): This function return a list of all endpoints when args search matches,

when args search do not match then it returns [].

class insights.parsers.sctp.SCTPSnmp(context)[source]

Bases: Parser, dict

This parser parses the content of /proc/net/sctp/snmp file, which contains statistics related to SCTP states, packets and chunks.

Sample content:

SctpCurrEstab                           5380
SctpActiveEstabs                        12749
SctpPassiveEstabs                       55
SctpAborteds                            2142
SctpShutdowns                           5295
SctpOutOfBlues                          36786
SctpChecksumErrors                      0
SctpOutCtrlChunks                       1051492

Data is stored in a dictionary.

Examples

>>> type(sctp_snmp)
<class 'insights.parsers.sctp.SCTPSnmp'>
>>> sctp_snmp.get('SctpCurrEstab')
5380
>>> sctp_snmp.get('SctpChecksumErrors') == 0
True
>>> 'SctpShutdowns' in sctp_snmp
True
>>> len(sctp_snmp)
8
>>> sorted(sctp_snmp.keys())
['SctpAborteds', 'SctpActiveEstabs', 'SctpChecksumErrors', 'SctpCurrEstab', 'SctpOutCtrlChunks', 'SctpOutOfBlues', 'SctpPassiveEstabs', 'SctpShutdowns']

Resultant Data:

{
    'SctpCurrEstab': 5380,
    'SctpActiveEstabs': 12749,
    'SctpPassiveEstabs': 55,
    'SctpAborteds': 2142,
    'SctpShutdowns': 5295,
    'SctpOutOfBlues': 36786,
    'SctpChecksumErrors': 0,
    ...
    ...
}
Raises
parse_content(content)[source]

This method must be implemented by classes based on this class.