aboutsummaryrefslogtreecommitdiffstats
path: root/openbsc/include/openbsc
diff options
context:
space:
mode:
authorHarald Welte <laforge@netfilter.org>2009-12-22 19:07:32 +0100
committerHarald Welte <laforge@netfilter.org>2009-12-22 20:42:40 +0100
commitffa55a4e8783419f60932ef2f9e872293cf932b9 (patch)
treec615771fe04a89807a012d8e100de53847b70d0f /openbsc/include/openbsc
parent4983921af1a84ea20c6be7944bf0ff4928578a69 (diff)
statistics: Introduce 'struct counter' instead of using unsigned long
This has the advantage that counters can be added all over the code very easily, while having only one routine that stores all of the current counter values to the database. The counters are synced every 60 seconds, providing relatively fine grained statistics about the network usage as time passes by.
Diffstat (limited to 'openbsc/include/openbsc')
-rw-r--r--openbsc/include/openbsc/Makefile.am2
-rw-r--r--openbsc/include/openbsc/db.h4
-rw-r--r--openbsc/include/openbsc/gsm_data.h51
-rw-r--r--openbsc/include/openbsc/statistics.h30
4 files changed, 61 insertions, 26 deletions
diff --git a/openbsc/include/openbsc/Makefile.am b/openbsc/include/openbsc/Makefile.am
index 27c88b770..b4760252e 100644
--- a/openbsc/include/openbsc/Makefile.am
+++ b/openbsc/include/openbsc/Makefile.am
@@ -5,4 +5,4 @@ noinst_HEADERS = abis_nm.h abis_rsl.h debug.h db.h gsm_04_08.h gsm_data.h \
gsm_utils.h ipaccess.h rs232.h openbscdefines.h rtp_proxy.h \
bsc_rll.h mncc.h talloc.h transaction.h ussd.h gsm_04_80.h \
silent_call.h mgcp.h meas_rep.h bitvec.h rest_octets.h \
- system_information.h handover.h
+ system_information.h handover.h statistics.h
diff --git a/openbsc/include/openbsc/db.h b/openbsc/include/openbsc/db.h
index 07135937b..fca736493 100644
--- a/openbsc/include/openbsc/db.h
+++ b/openbsc/include/openbsc/db.h
@@ -53,4 +53,8 @@ int db_sms_mark_sent(struct gsm_sms *sms);
int db_apdu_blob_store(struct gsm_subscriber *subscr,
u_int8_t apdu_id_flags, u_int8_t len,
u_int8_t *apdu);
+
+/* Statistics counter storage */
+int db_store_counter(struct counter *ctr);
+
#endif /* _DB_H */
diff --git a/openbsc/include/openbsc/gsm_data.h b/openbsc/include/openbsc/gsm_data.h
index 74e193832..c2eec4156 100644
--- a/openbsc/include/openbsc/gsm_data.h
+++ b/openbsc/include/openbsc/gsm_data.h
@@ -61,6 +61,7 @@ enum gsm_chreq_reason_t {
#include <openbsc/mncc.h>
#include <openbsc/tlv.h>
#include <openbsc/bitvec.h>
+#include <openbsc/statistics.h>
#define ARRAY_SIZE(x) (sizeof(x) / sizeof((x)[0]))
@@ -460,43 +461,43 @@ struct gsm_bts {
/* Some statistics of our network */
struct gsmnet_stats {
struct {
- unsigned long total;
- unsigned long no_channel;
+ struct counter *total;
+ struct counter *no_channel;
} chreq;
struct {
- unsigned long attempted;
- unsigned long no_channel; /* no channel available */
- unsigned long timeout; /* T3103 timeout */
- unsigned long completed; /* HO COMPL received */
- unsigned long failed; /* HO FAIL received */
+ struct counter *attempted;
+ struct counter *no_channel; /* no channel available */
+ struct counter *timeout; /* T3103 timeout */
+ struct counter *completed; /* HO COMPL received */
+ struct counter *failed; /* HO FAIL received */
} handover;
struct {
- unsigned long attach;
- unsigned long normal;
- unsigned long periodic;
- unsigned long detach;
+ struct counter *attach;
+ struct counter *normal;
+ struct counter *periodic;
+ struct counter *detach;
} loc_upd_type;
struct {
- unsigned long reject;
- unsigned long accept;
+ struct counter *reject;
+ struct counter *accept;
} loc_upd_resp;
struct {
- unsigned long attempted;
- unsigned long detached;
- unsigned long completed;
- unsigned long expired;
+ struct counter *attempted;
+ struct counter *detached;
+ struct counter *completed;
+ struct counter *expired;
} paging;
struct {
- unsigned long submitted; /* MO SMS submissions */
- unsigned long no_receiver;
- unsigned long delivered; /* MT SMS deliveries */
- unsigned long rp_err_mem;
- unsigned long rp_err_other;
+ struct counter *submitted; /* MO SMS submissions */
+ struct counter *no_receiver;
+ struct counter *delivered; /* MT SMS deliveries */
+ struct counter *rp_err_mem;
+ struct counter *rp_err_other;
} sms;
struct {
- unsigned long dialled; /* total number of dialled calls */
- unsigned long alerted; /* we alerted the other end */
- unsigned long connected;/* how many calls were accepted */
+ struct counter *dialled; /* total number of dialled calls */
+ struct counter *alerted; /* we alerted the other end */
+ struct counter *connected;/* how many calls were accepted */
} call;
};
diff --git a/openbsc/include/openbsc/statistics.h b/openbsc/include/openbsc/statistics.h
new file mode 100644
index 000000000..9291a8c25
--- /dev/null
+++ b/openbsc/include/openbsc/statistics.h
@@ -0,0 +1,30 @@
+#ifndef _STATISTICS_H
+#define _STATISTICS_H
+
+struct counter {
+ struct llist_head list;
+ const char *name;
+ const char *description;
+ unsigned long value;
+};
+
+static inline void counter_inc(struct counter *ctr)
+{
+ ctr->value++;
+}
+
+static inline unsigned long counter_get(struct counter *ctr)
+{
+ return ctr->value;
+}
+
+static inline void counter_reset(struct counter *ctr)
+{
+ ctr->value = 0;
+}
+
+struct counter *counter_alloc(const char *name);
+void counter_free(struct counter *ctr);
+int counters_store_db(void);
+
+#endif /* _STATISTICS_H */