summaryrefslogtreecommitdiffstats
path: root/include/osmocom
diff options
context:
space:
mode:
authorJacob Erlbeck <jerlbeck@sysmocom.de>2015-10-20 19:05:52 +0200
committerJacob Erlbeck <jerlbeck@sysmocom.de>2015-10-29 01:10:03 +0100
commit95bf828003b065f00a78144296072a9730cbf7bc (patch)
tree078566837c46a906ab0dc0bb6b8a24fa97736abb /include/osmocom
parent45513e6040195f5494d40a2750de4dac7037593f (diff)
stats: Add the reporting framework
This commit provides the stats reporting framework that can manage several types of measurement reporters. Initially support for rate_ctr and the statsd protocol is included. Sponsored-by: On-Waves ehf
Diffstat (limited to 'include/osmocom')
-rw-r--r--include/osmocom/core/stats.h70
1 files changed, 70 insertions, 0 deletions
diff --git a/include/osmocom/core/stats.h b/include/osmocom/core/stats.h
new file mode 100644
index 00000000..b4fb727c
--- /dev/null
+++ b/include/osmocom/core/stats.h
@@ -0,0 +1,70 @@
+/* (C) 2015 by Sysmocom s.f.m.c. GmbH
+ *
+ * All Rights Reserved
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License along
+ * with this program; if not, write to the Free Software Foundation, Inc.,
+ * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ */
+#pragma once
+
+#include <sys/socket.h>
+#include <osmocom/core/linuxlist.h>
+
+enum stats_reporter_type {
+ STATS_REPORTER_STATSD,
+};
+
+struct stats_reporter {
+ enum stats_reporter_type type;
+ char *name;
+
+ /* config */
+ int enabled;
+ int interval;
+ char *name_prefix;
+ char *dest_addr_str;
+ char *bind_addr_str;
+ int dest_port;
+ int mtu;
+
+ /* state */
+ int running;
+ struct sockaddr dest_addr;
+ int dest_addr_len;
+ struct sockaddr bind_addr;
+ int bind_addr_len;
+ int fd;
+
+ struct llist_head list;
+};
+
+void stats_init(void *ctx);
+int stats_report();
+
+struct stats_reporter *stats_reporter_alloc(enum stats_reporter_type type,
+ const char *name);
+void stats_reporter_free(struct stats_reporter *srep);
+struct stats_reporter *stats_reporter_create_statsd(const char *name);
+
+struct stats_reporter *stats_reporter_find(enum stats_reporter_type type,
+ const char *name);
+
+int stats_reporter_set_remote_addr(struct stats_reporter *srep, const char *addr);
+int stats_reporter_set_remote_port(struct stats_reporter *srep, int port);
+int stats_reporter_set_local_addr(struct stats_reporter *srep, const char *addr);
+int stats_reporter_set_interval(struct stats_reporter *srep, int interval);
+int stats_reporter_set_name_prefix(struct stats_reporter *srep, const char *prefix);
+int stats_reporter_enable(struct stats_reporter *srep);
+int stats_reporter_disable(struct stats_reporter *srep);