Statistics support. More...
#include <string.h>#include <stdio.h>#include <stdlib.h>#include "../../ut.h"#include "../../dprint.h"#include "../../socket_info.h"#include "statistics.h"
Go to the source code of this file.
Definition in file lib/kcore/statistics.c.
| int get_socket_list_from_proto | ( | int ** | ipList, | |
| int | protocol | |||
| ) |
The first parameter, ipList, is a pointer to a pointer. It will be assigned a new block of memory holding the IP Addresses and ports being listened to with respect to 'protocol'. The array maps a 2D array into a 1 dimensional space, and is layed out as follows:
The first NUM_IP_OCTETS indices will be the IP address, and the next index the port. So if NUM_IP_OCTETS is equal to 4 and there are two IP addresses found, then:
The function will return the number of sockets which were found. This can be used to index into ipList.
returnedValue * (NUM_IP_OCTETS + 1) * sizeof(int);
Therefore it is CRUCIAL that you free ipList when you are done with its contents, to avoid a nasty memory leak.
Definition at line 115 of file lib/kcore/statistics.c.
Referenced by get_total_bytes_waiting().

| int get_total_bytes_waiting | ( | void | ) |
Note: This currently only works on systems supporting the /proc/net/[tcp|udp] interface. On other systems, zero will always be returned. To change this in the future, add an equivalent for get_used_waiting_queue().
Definition at line 395 of file lib/kcore/statistics.c.
References get_socket_list_from_proto(), and get_used_waiting_queue().
Referenced by check_msg_queue_alarm().


| static int get_used_waiting_queue | ( | int | forTCP, | |
| int * | interfaceList, | |||
| int | listSize | |||
| ) | [static] |
The check will be limited to the TCP or UDP transport exclusively. Specifically:
Note: This only works on linux systems supporting the /proc/net/[tcp|udp] interface. On other systems, zero will always be returned.
Definition at line 336 of file lib/kcore/statistics.c.
References match_ip_and_port(), and parse_proc_net_line().
Referenced by get_total_bytes_waiting().


| static int match_ip_and_port | ( | int * | ipOne, | |
| int * | ipArray, | |||
| int | sizeOf_ipArray | |||
| ) | [static] |
The format of ipOne and ipArray are described in the comments of get_socket_list_from_proto() in this file.
Definition at line 289 of file lib/kcore/statistics.c.
Referenced by get_used_waiting_queue().

| static int parse_proc_net_line | ( | char * | line, | |
| int * | ipAddress, | |||
| int * | rx_queue | |||
| ) | [static] |
Returns 1 on success, and 0 on a failed parse.
Note: The format of ipAddress is as defined in the comments of get_socket_list_from_proto() in this file.
Definition at line 206 of file lib/kcore/statistics.c.
Referenced by get_used_waiting_queue().

1.7.1