diff options
author | Holger Hans Peter Freyther <holger@moiji-mobile.com> | 2016-08-19 19:15:39 +0200 |
---|---|---|
committer | Holger Hans Peter Freyther <holger@moiji-mobile.com> | 2016-08-19 19:23:00 +0200 |
commit | 99526a6ad07c02e40e0831fd952974c5b7446f31 (patch) | |
tree | 9bc1fe1e69567224ed7c85e23a9ecc9b1c184bfc /src/osmo_server_main.c | |
parent | c3455dcb7951069dab99effae71aac2a14961823 (diff) |
server: Add global and per client counters and begin to count
Add the basics for getting a picture what a client and the server
is doing. We need to create unique descriptions as the code is
working with names and not numbers for clients.
Change-Id: I4a9be5bdd815d280cccf0199efc2ca79fc77d393
Diffstat (limited to 'src/osmo_server_main.c')
-rw-r--r-- | src/osmo_server_main.c | 39 |
1 files changed, 39 insertions, 0 deletions
diff --git a/src/osmo_server_main.c b/src/osmo_server_main.c index ef01300..bb94ec4 100644 --- a/src/osmo_server_main.c +++ b/src/osmo_server_main.c @@ -28,6 +28,7 @@ #include <osmocom/core/select.h> #include <osmocom/core/stats.h> #include <osmocom/core/talloc.h> +#include <osmocom/core/utils.h> #include <osmocom/vty/logging.h> #include <osmocom/vty/telnet_interface.h> @@ -52,6 +53,38 @@ struct osmo_pcap_server *pcap_server; extern void *tall_msgb_ctx; extern void *tall_ctr_ctx; + +static const struct rate_ctr_desc pcap_peer_ctr_desc[] = { + [PEER_CTR_CONNECT] = { "peer.connect", "Connect of a peer " }, + [PEER_CTR_BYTES] = { "peer.bytes", "Received bytes " }, + [PEER_CTR_PKTS] = { "peer.pkts", "Received packets " }, + [PEER_CTR_PROTATE] = { "peer.file_rotated","Capture file rotated" }, +}; + +static const struct rate_ctr_desc pcap_server_ctr_desc[] = { + [SERVER_CTR_CONNECT] = { "server.connect", "Connect of a peer " }, + [SERVER_CTR_BYTES] = { "server.bytes", "Received bytes " }, + [SERVER_CTR_PKTS] = { "server.pkts", "Received packets " }, + [SERVER_CTR_PROTATE] = { "server.file_rotated", "Capture file rotated" }, + [SERVER_CTR_NOCLIENT] = { "server.no_client", "Unknown connected " }, +}; + +const struct rate_ctr_group_desc pcap_peer_group_desc = { + .group_name_prefix = NULL, /* will be dynamically patched */ + .group_description = "PCAP peer statistics", + .num_ctr = ARRAY_SIZE(pcap_peer_ctr_desc), + .ctr_desc = pcap_peer_ctr_desc, + .class_id = OSMO_STATS_CLASS_PEER, +}; + +static const struct rate_ctr_group_desc pcap_server_group_desc = { + .group_name_prefix = "pcap.server", + .group_description = "PCAP Server global statistics", + .num_ctr = ARRAY_SIZE(pcap_server_ctr_desc), + .ctr_desc = pcap_server_ctr_desc, + .class_id = OSMO_STATS_CLASS_GLOBAL, +}; + static struct vty_app_info vty_info = { .name = "OsmoPCAPServer", .version = PACKAGE_VERSION, @@ -194,6 +227,12 @@ int main(int argc, char **argv) LOGP(DSERVER, LOGL_ERROR, "Failed to allocate osmo_pcap_server.\n"); exit(1); } + pcap_server->ctrg = rate_ctr_group_alloc(pcap_server, &pcap_server_group_desc, 0); + if (!pcap_server->ctrg) { + LOGP(DSERVER, LOGL_ERROR, "Failed to allocate rate counter.\n"); + exit(1); + } + INIT_LLIST_HEAD(&pcap_server->conn); pcap_server->base_path = talloc_strdup(pcap_server, "./"); pcap_server->max_size = 1073741824; |