Module: sip-router
Branch: andrei/counters
Commit: 62ab77b9b7692f48067f36cf241d7feb0879de2f
URL:
http://git.sip-router.org/cgi-bin/gitweb.cgi/sip-router/?a=commit;h=62ab77b…
Author: Andrei Pelinescu-Onciul <andrei(a)iptel.org>
Committer: Andrei Pelinescu-Onciul <andrei(a)iptel.org>
Date: Mon Aug 9 17:04:41 2010 +0200
sctp: switched to counter arrays + more stats
- use counters arrays
- added counters descriptions
- don't attempt to compile if sctp support or sctp stats support
are disabled
- more stats: current_opened_connections and
current_tracked_connections.
---
sctp_stats.c | 83 ++++++++++++++++++++++++++++++++++++++++++++++++++-------
1 files changed, 72 insertions(+), 11 deletions(-)
diff --git a/sctp_stats.c b/sctp_stats.c
index 46b8a49..e024811 100644
--- a/sctp_stats.c
+++ b/sctp_stats.c
@@ -25,29 +25,87 @@
* 2010-08-09 initial version (andrei)
*/
+#ifdef USE_SCTP
+
#include "sctp_stats.h"
+
+#ifdef USE_SCTP_STATS
+
#include "counters.h"
+#include "sctp_server.h"
struct sctp_counters_h sctp_cnts_h;
+
+enum sctp_info_req { SCTP_INFO_NONE, SCTP_INFO_CONN_NO, SCTP_INFO_TRACKED_NO };
+static counter_val_t sctp_info(counter_handle_t h, void* what);
+
+
+
+/* sctp counters definitions */
+counter_def_t sctp_cnt_defs[] = {
+ {&sctp_cnts_h.established, "established", 0, 0, 0,
+ "incremented each time a new association is established."},
+ {&sctp_cnts_h.connect_failed, "connect_failed", 0, 0, 0,
+ "incremented each time a new outgoing connection fails."},
+ {&sctp_cnts_h.local_reject, "local_reject", 0, 0, 0,
+ "number of rejected incoming connections."},
+ {&sctp_cnts_h.remote_shutdown, "remote_shutdown", 0, 0, 0,
+ "incremented each time an association is closed by the peer."},
+ {&sctp_cnts_h.assoc_shutdown, "assoc_shutdown", 0, 0, 0,
+ "incremented each time an association is shutdown."},
+ {&sctp_cnts_h.comm_lost, "comm_lost", 0, 0, 0,
+ "incremented each time an established connection is close due to"
+ "some error."},
+ {&sctp_cnts_h.sendq_full, "sendq_full", 0, 0, 0,
+ "number of failed send attempt due to exceeded buffering capacity"
+ " (full kernel buffers)."},
+ {&sctp_cnts_h.send_failed, "send_failed", 0, 0, 0,
+ "number of failed send attempt for any reason except full buffers."},
+ {&sctp_cnts_h.send_force_retry, "send_force_retry", 0, 0, 0,
+ "incremented each time a failed send is force-retried"
+ "(possible only if sctp_send_retries ! = 0"},
+ {0, "current_opened_connections", 0,
+ sctp_info, (void*)(long)SCTP_INFO_CONN_NO,
+ "number of currently opened associations."},
+ {0, "current_tracked_connections", 0,
+ sctp_info, (void*)(long)SCTP_INFO_TRACKED_NO,
+ "number of currently tracked associations."},
+ {0, 0, 0, 0, 0, 0 }
+};
+
+
+
+/** helper function for some stats (which are kept internally inside sctp).
+ */
+static counter_val_t sctp_info(counter_handle_t h, void* what)
+{
+ enum sctp_info_req w;
+ struct sctp_gen_info i;
+
+ if (sctp_disable)
+ return 0;
+ w = (int)(long)what;
+ sctp_get_info(&i);
+ switch(w) {
+ case SCTP_INFO_CONN_NO:
+ return i.sctp_connections_no;
+ case SCTP_INFO_TRACKED_NO:
+ return i.sctp_tracked_no;
+ case SCTP_INFO_NONE:
+ break;
+ };
+ return 0;
+}
+
/** intialize sctp statistics.
* Must be called before forking.
* @return < 0 on errror, 0 on success.
*/
int sctp_stats_init()
{
-#define SCTP_REG_COUNTER(name) \
- if (counter_register(&sctp_cnts_h.name, "sctp", # name, 0, 0, 0, 0) <
0) \
+ if (counter_register_array("sctp", sctp_cnt_defs) < 0)
goto error;
-
- SCTP_REG_COUNTER(established);
- SCTP_REG_COUNTER(connect_failed);
- SCTP_REG_COUNTER(local_reject);
- SCTP_REG_COUNTER(remote_shutdown);
- SCTP_REG_COUNTER(assoc_shutdown);
- SCTP_REG_COUNTER(comm_lost);
- SCTP_REG_COUNTER(sendq_full);
- SCTP_REG_COUNTER(send_force_retry);
return 0;
error:
return -1;
@@ -59,4 +117,7 @@ void sctp_stats_destroy()
/* do nothing */
}
+#endif /* USE_SCTP_STATS */
+#endif /* USE_SCTP */
+
/* vi: set ts=4 sw=4 tw=79:ai:cindent: */