blob: 489e0e416c5ca424c1add948e9bfcb85a73d17d6 [file] [log] [blame]
Jacob Erlbeck95bf82802015-10-20 19:05:52 +02001/* (C) 2015 by Sysmocom s.f.m.c. GmbH
2 *
3 * All Rights Reserved
4 *
5 * This program is free software; you can redistribute it and/or modify
6 * it under the terms of the GNU General Public License as published by
7 * the Free Software Foundation; either version 2 of the License, or
8 * (at your option) any later version.
9 *
10 * This program is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 * GNU General Public License for more details.
14 *
15 * You should have received a copy of the GNU General Public License along
16 * with this program; if not, write to the Free Software Foundation, Inc.,
17 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
18 *
19 */
20#pragma once
21
22#include <sys/socket.h>
23#include <osmocom/core/linuxlist.h>
24
25enum stats_reporter_type {
26 STATS_REPORTER_STATSD,
27};
28
29struct stats_reporter {
30 enum stats_reporter_type type;
31 char *name;
32
33 /* config */
34 int enabled;
Jacob Erlbeck95bf82802015-10-20 19:05:52 +020035 char *name_prefix;
36 char *dest_addr_str;
37 char *bind_addr_str;
38 int dest_port;
39 int mtu;
40
41 /* state */
42 int running;
43 struct sockaddr dest_addr;
44 int dest_addr_len;
45 struct sockaddr bind_addr;
46 int bind_addr_len;
47 int fd;
48
49 struct llist_head list;
50};
51
Jacob Erlbeckb1dbfb42015-10-26 11:58:38 +010052struct stats_config {
53 int interval;
54};
55
56extern struct stats_config *stats_config;
57
Jacob Erlbeck95bf82802015-10-20 19:05:52 +020058void stats_init(void *ctx);
59int stats_report();
60
Jacob Erlbeckb1dbfb42015-10-26 11:58:38 +010061int stats_set_interval(int interval);
62
Jacob Erlbeck95bf82802015-10-20 19:05:52 +020063struct stats_reporter *stats_reporter_alloc(enum stats_reporter_type type,
64 const char *name);
65void stats_reporter_free(struct stats_reporter *srep);
66struct stats_reporter *stats_reporter_create_statsd(const char *name);
67
68struct stats_reporter *stats_reporter_find(enum stats_reporter_type type,
69 const char *name);
70
71int stats_reporter_set_remote_addr(struct stats_reporter *srep, const char *addr);
72int stats_reporter_set_remote_port(struct stats_reporter *srep, int port);
73int stats_reporter_set_local_addr(struct stats_reporter *srep, const char *addr);
Jacob Erlbeck95bf82802015-10-20 19:05:52 +020074int stats_reporter_set_name_prefix(struct stats_reporter *srep, const char *prefix);
75int stats_reporter_enable(struct stats_reporter *srep);
76int stats_reporter_disable(struct stats_reporter *srep);