statistics.h 3.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116
  1. /*
  2. * $Id$
  3. *
  4. * Copyright (C) 2006 Voice Sistem SRL
  5. *
  6. * This file is part of Kamailio, a free SIP server.
  7. *
  8. * Kamailio is free software; you can redistribute it and/or modify
  9. * it under the terms of the GNU General Public License as published by
  10. * the Free Software Foundation; either version 2 of the License, or
  11. * (at your option) any later version.
  12. *
  13. * Kamailio is distributed in the hope that it will be useful,
  14. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  15. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  16. * GNU General Public License for more details.
  17. *
  18. * You should have received a copy of the GNU General Public License
  19. * along with this program; if not, write to the Free Software
  20. * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
  21. *
  22. * History:
  23. * ---------
  24. * 2006-01-16 first version (bogdan)
  25. * 2006-11-28 added get_stat_var_from_num_code() (Jeffrey Magder -
  26. * SOMA Networks)
  27. * 2010-08-08 removed all the parts emulated by kstats_wrapper.[ch] (andrei)
  28. */
  29. /*!
  30. * \file
  31. * \brief Kamailio statistics handling
  32. */
  33. #ifndef _KSTATISTICS_H_
  34. #define _KSTATISTICS_H_
  35. #include "kstats_wrapper.h"
  36. #define NUM_IP_OCTETS 4
  37. #define NUM_IPV6_OCTETS 16
  38. #ifdef STATISTICS
  39. /*! \brief
  40. * Returns the statistic associated with 'numerical_code' and 'is_a_reply'.
  41. * Specifically:
  42. *
  43. * - if in_codes is nonzero, then the stat_var for the number of messages
  44. * _received_ with the 'numerical_code' will be returned if it exists.
  45. * - otherwise, the stat_var for the number of messages _sent_ with the
  46. * 'numerical_code' will be returned, if the stat exists.
  47. */
  48. stat_var *get_stat_var_from_num_code(unsigned int numerical_code, int in_codes);
  49. #else
  50. #define get_stat_var_from_num_code( _n_code, _in_code) NULL
  51. #endif
  52. /*!
  53. * This function will retrieve a list of all ip addresses and ports that Kamailio
  54. * is listening on, with respect to the transport protocol specified with
  55. * 'protocol'. This function only returns IPv4 addresses.
  56. *
  57. * The first parameter, ipList, is a pointer to a pointer. It will be assigned a
  58. * new block of memory holding the IP Addresses and ports being listened to with
  59. * respect to 'protocol'. The array maps a 2D array into a 1 dimensional space,
  60. * and is layed out as follows:
  61. *
  62. * The first NUM_IP_OCTETS indices will be the IP address, and the next index
  63. * the port. So if NUM_IP_OCTETS is equal to 4 and there are two IP addresses
  64. * found, then:
  65. *
  66. * - ipList[0] will be the first octet of the first ip address
  67. * - ipList[3] will be the last octet of the first ip address.
  68. * - iplist[4] will be the port of the first ip address
  69. * -
  70. * - iplist[5] will be the first octet of the first ip address,
  71. * - and so on.
  72. *
  73. * The function will return the number of sockets which were found. This can be
  74. * used to index into ipList.
  75. *
  76. * \note This function assigns a block of memory equal to:
  77. *
  78. * returnedValue * (NUM_IP_OCTETS + 1) * sizeof(int);
  79. *
  80. * Therefore it is CRUCIAL that you free ipList when you are done with its
  81. * contents, to avoid a nasty memory leak.
  82. */
  83. int get_socket_list_from_proto(int **ipList, int protocol);
  84. /*! \brief Function to get a list of all IP addresses and ports in a specific
  85. * family, like AF_INET or AF_INET6
  86. *
  87. * For documentation see \ref get_socket_list_from_proto()
  88. */
  89. int get_socket_list_from_proto_and_family(int **ipList, int protocol, int family);
  90. /*!
  91. * Returns the sum of the number of bytes waiting to be consumed on all network
  92. * interfaces and transports that Kamailio is listening on.
  93. *
  94. * Note: This currently only works on systems supporting the /proc/net/[tcp|udp]
  95. * interface. On other systems, zero will always be returned. Details of
  96. * why this is so can be found in network_stats.c
  97. */
  98. int get_total_bytes_waiting(void);
  99. #endif