blob: b4fb727c0ebe9198cb4661215f88e5116dbe5bc0 [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;
35 int interval;
36 char *name_prefix;
37 char *dest_addr_str;
38 char *bind_addr_str;
39 int dest_port;
40 int mtu;
41
42 /* state */
43 int running;
44 struct sockaddr dest_addr;
45 int dest_addr_len;
46 struct sockaddr bind_addr;
47 int bind_addr_len;
48 int fd;
49
50 struct llist_head list;
51};
52
53void stats_init(void *ctx);
54int stats_report();
55
56struct stats_reporter *stats_reporter_alloc(enum stats_reporter_type type,
57 const char *name);
58void stats_reporter_free(struct stats_reporter *srep);
59struct stats_reporter *stats_reporter_create_statsd(const char *name);
60
61struct stats_reporter *stats_reporter_find(enum stats_reporter_type type,
62 const char *name);
63
64int stats_reporter_set_remote_addr(struct stats_reporter *srep, const char *addr);
65int stats_reporter_set_remote_port(struct stats_reporter *srep, int port);
66int stats_reporter_set_local_addr(struct stats_reporter *srep, const char *addr);
67int stats_reporter_set_interval(struct stats_reporter *srep, int interval);
68int stats_reporter_set_name_prefix(struct stats_reporter *srep, const char *prefix);
69int stats_reporter_enable(struct stats_reporter *srep);
70int stats_reporter_disable(struct stats_reporter *srep);