stp: Add basic RX/TX rate counters on AS and ASP level
This adds some very basic rx/px rate counters to the SS7 AS and ASP OsmoSTP> show rate-counters SIGTRAN Application Server 0 (as-rkm-1): rx:msu:total: 86078 (1888/s 86078/m 0/h 0/d) tx:msu:total: 0 (0/s 0/m 0/h 0/d) SIGTRAN Application Server Process 0 (asp-dyn-0): rx:packets:total: 86081 (1888/s 86081/m 0/h 0/d) tx:packets:total: 5 (0/s 5/m 0/h 0/d) Change-Id: Idb811ca81adfe47152d484f6b981e661dc569e15
This commit is contained in:
parent
5ad97995e9
commit
ff7404c742
|
@ -9,6 +9,7 @@
|
|||
#include <osmocom/core/msgb.h>
|
||||
#include <osmocom/core/prim.h>
|
||||
#include <osmocom/core/socket.h>
|
||||
#include <osmocom/core/rate_ctr.h>
|
||||
|
||||
extern struct llist_head osmo_ss7_instances;
|
||||
|
||||
|
@ -310,6 +311,9 @@ struct osmo_ss7_as {
|
|||
/*! Were we allocated by "simple client" support? */
|
||||
bool simple_client_allocated;
|
||||
|
||||
/*! Rate Counter Group */
|
||||
struct rate_ctr_group *ctrg;
|
||||
|
||||
struct {
|
||||
char *name;
|
||||
char *description;
|
||||
|
@ -412,6 +416,9 @@ struct osmo_ss7_asp {
|
|||
/*! Were we allocated by "simple client" support? */
|
||||
bool simple_client_allocated;
|
||||
|
||||
/*! Rate Counter Group */
|
||||
struct rate_ctr_group *ctrg;
|
||||
|
||||
/*! Pending message for non-blocking IPA read */
|
||||
struct msgb *pending_msg;
|
||||
|
||||
|
|
|
@ -47,6 +47,7 @@
|
|||
#include <osmocom/sigtran/protocol/mtp.h>
|
||||
|
||||
#include "xua_internal.h"
|
||||
#include "ss7_internal.h"
|
||||
#include "xua_asp_fsm.h"
|
||||
|
||||
|
||||
|
@ -224,6 +225,8 @@ static int ipa_rx_msg_sccp(struct osmo_ss7_asp *asp, struct msgb *msg)
|
|||
return -1;
|
||||
}
|
||||
|
||||
rate_ctr_inc2(as->ctrg, SS7_AS_CTR_RX_MSU_TOTAL);
|
||||
|
||||
/* pull the IPA header */
|
||||
msgb_pull_to_l2(msg);
|
||||
|
||||
|
|
|
@ -44,6 +44,7 @@
|
|||
#include "xua_as_fsm.h"
|
||||
#include "xua_asp_fsm.h"
|
||||
#include "xua_internal.h"
|
||||
#include "ss7_internal.h"
|
||||
|
||||
#define M3UA_MSGB_SIZE 1500
|
||||
|
||||
|
@ -553,6 +554,8 @@ static int m3ua_rx_xfer(struct osmo_ss7_asp *asp, struct xua_msg *xua)
|
|||
if (rc)
|
||||
return rc;
|
||||
|
||||
rate_ctr_inc2(as->ctrg, SS7_AS_CTR_RX_MSU_TOTAL);
|
||||
|
||||
/* FIXME: check for AS state == ACTIVE */
|
||||
|
||||
/* store the MTP-level information in the xua_msg for use by
|
||||
|
|
|
@ -48,6 +48,7 @@
|
|||
|
||||
#include "sccp_internal.h"
|
||||
#include "xua_internal.h"
|
||||
#include "ss7_internal.h"
|
||||
#include "xua_asp_fsm.h"
|
||||
#include "xua_as_fsm.h"
|
||||
|
||||
|
@ -895,6 +896,19 @@ const char *osmo_ss7_route_print(const struct osmo_ss7_route *rt)
|
|||
* SS7 Application Server
|
||||
***********************************************************************/
|
||||
|
||||
static const struct rate_ctr_desc ss7_as_rcd[] = {
|
||||
[SS7_AS_CTR_RX_MSU_TOTAL] = { "rx.msu.total", "Total number of MSU received" },
|
||||
[SS7_AS_CTR_TX_MSU_TOTAL] = { "tx.msu.total", "Total number of MSU transmitted" },
|
||||
};
|
||||
|
||||
static const struct rate_ctr_group_desc ss7_as_rcgd = {
|
||||
.group_name_prefix = "sigtran.as",
|
||||
.group_description = "SIGTRAN Application Server",
|
||||
.num_ctr = ARRAY_SIZE(ss7_as_rcd),
|
||||
.ctr_desc = ss7_as_rcd,
|
||||
};
|
||||
static unsigned int g_ss7_as_rcg_idx;
|
||||
|
||||
/*! \brief Find Application Server by given name
|
||||
* \param[in] inst SS7 Instance on which we operate
|
||||
* \param[in] name Name of AS
|
||||
|
@ -1002,6 +1016,12 @@ osmo_ss7_as_find_or_create(struct osmo_ss7_instance *inst, const char *name,
|
|||
as = talloc_zero(inst, struct osmo_ss7_as);
|
||||
if (!as)
|
||||
return NULL;
|
||||
as->ctrg = rate_ctr_group_alloc(as, &ss7_as_rcgd, g_ss7_as_rcg_idx++);
|
||||
if (!as->ctrg) {
|
||||
talloc_free(as);
|
||||
return NULL;
|
||||
}
|
||||
rate_ctr_group_set_name(as->ctrg, name);
|
||||
as->inst = inst;
|
||||
as->cfg.name = talloc_strdup(as, name);
|
||||
as->cfg.proto = proto;
|
||||
|
@ -1125,6 +1145,26 @@ bool osmo_ss7_as_active(const struct osmo_ss7_as *as)
|
|||
* SS7 Application Server Process
|
||||
***********************************************************************/
|
||||
|
||||
enum ss7_asp_ctr {
|
||||
SS7_ASP_CTR_PKT_RX_TOTAL,
|
||||
SS7_ASP_CTR_PKT_RX_UNKNOWN,
|
||||
SS7_ASP_CTR_PKT_TX_TOTAL,
|
||||
};
|
||||
|
||||
static const struct rate_ctr_desc ss7_asp_rcd[] = {
|
||||
[SS7_ASP_CTR_PKT_RX_TOTAL] = { "rx.packets.total", "Total number of packets received" },
|
||||
[SS7_ASP_CTR_PKT_RX_UNKNOWN] = { "rx.packets.unknown", "Number of packets received for unknown PPID" },
|
||||
[SS7_ASP_CTR_PKT_TX_TOTAL] = { "tx.packets.total", "Total number of packets transmitted" },
|
||||
};
|
||||
|
||||
static const struct rate_ctr_group_desc ss7_asp_rcgd = {
|
||||
.group_name_prefix = "sigtran.asp",
|
||||
.group_description = "SIGTRAN Application Server Process",
|
||||
.num_ctr = ARRAY_SIZE(ss7_asp_rcd),
|
||||
.ctr_desc = ss7_asp_rcd,
|
||||
};
|
||||
static unsigned int g_ss7_asp_rcg_idx;
|
||||
|
||||
int osmo_ss7_asp_peer_snprintf(char* buf, size_t buf_len, struct osmo_ss7_asp_peer *peer)
|
||||
{
|
||||
int len = 0, offset = 0, rem = buf_len;
|
||||
|
@ -1485,6 +1525,12 @@ osmo_ss7_asp_find_or_create(struct osmo_ss7_instance *inst, const char *name,
|
|||
if (!asp) {
|
||||
/* FIXME: check if local port has SCTP? */
|
||||
asp = talloc_zero(inst, struct osmo_ss7_asp);
|
||||
asp->ctrg = rate_ctr_group_alloc(asp, &ss7_asp_rcgd, g_ss7_asp_rcg_idx++);
|
||||
if (!asp->ctrg) {
|
||||
talloc_free(asp);
|
||||
return NULL;
|
||||
}
|
||||
rate_ctr_group_set_name(asp->ctrg, name);
|
||||
asp->inst = inst;
|
||||
asp->cfg.remote.port = remote_port;
|
||||
asp->cfg.local.port = local_port;
|
||||
|
@ -1781,6 +1827,8 @@ static int xua_srv_conn_cb(struct osmo_stream_srv *conn)
|
|||
msgb_sctp_stream(msg) = sinfo.sinfo_stream;
|
||||
msg->dst = asp;
|
||||
|
||||
rate_ctr_inc2(asp->ctrg, SS7_ASP_CTR_PKT_RX_TOTAL);
|
||||
|
||||
if (ppid == SUA_PPID && asp->cfg.proto == OSMO_SS7_ASP_PROT_SUA)
|
||||
rc = sua_rx_msg(asp, msg);
|
||||
else if (ppid == M3UA_PPID && asp->cfg.proto == OSMO_SS7_ASP_PROT_M3UA)
|
||||
|
@ -1860,6 +1908,7 @@ static int ipa_cli_read_cb(struct osmo_stream_cli *conn)
|
|||
return -1;
|
||||
}
|
||||
msg->dst = asp;
|
||||
rate_ctr_inc2(asp->ctrg, SS7_ASP_CTR_PKT_RX_TOTAL);
|
||||
return ipa_rx_msg(asp, msg);
|
||||
}
|
||||
|
||||
|
@ -1918,6 +1967,8 @@ static int xua_cli_read_cb(struct osmo_stream_cli *conn)
|
|||
msgb_sctp_stream(msg) = sinfo.sinfo_stream;
|
||||
msg->dst = asp;
|
||||
|
||||
rate_ctr_inc2(asp->ctrg, SS7_ASP_CTR_PKT_RX_TOTAL);
|
||||
|
||||
if (ppid == SUA_PPID && asp->cfg.proto == OSMO_SS7_ASP_PROT_SUA)
|
||||
rc = sua_rx_msg(asp, msg);
|
||||
else if (ppid == M3UA_PPID && asp->cfg.proto == OSMO_SS7_ASP_PROT_M3UA)
|
||||
|
@ -2086,6 +2137,8 @@ int osmo_ss7_asp_send(struct osmo_ss7_asp *asp, struct msgb *msg)
|
|||
OSMO_ASSERT(0);
|
||||
}
|
||||
|
||||
rate_ctr_inc2(asp->ctrg, SS7_ASP_CTR_PKT_TX_TOTAL);
|
||||
|
||||
if (asp->cfg.is_server) {
|
||||
if (!asp->server) {
|
||||
LOGPASP(asp, DLSS7, LOGL_ERROR, "Cannot transmit, no asp->server\n");
|
||||
|
@ -2361,6 +2414,8 @@ static osmo_ss7_asp_rx_unknown_cb *g_osmo_ss7_asp_rx_unknown_cb;
|
|||
|
||||
int ss7_asp_rx_unknown(struct osmo_ss7_asp *asp, int ppid_mux, struct msgb *msg)
|
||||
{
|
||||
rate_ctr_inc2(asp->ctrg, SS7_ASP_CTR_PKT_RX_UNKNOWN);
|
||||
|
||||
if (g_osmo_ss7_asp_rx_unknown_cb)
|
||||
return (*g_osmo_ss7_asp_rx_unknown_cb)(asp, ppid_mux, msg);
|
||||
|
||||
|
|
|
@ -35,6 +35,7 @@
|
|||
#include <osmocom/sigtran/protocol/m3ua.h>
|
||||
|
||||
#include "xua_internal.h"
|
||||
#include "ss7_internal.h"
|
||||
|
||||
/* convert from M3UA message to MTP-TRANSFER.ind osmo_mtp_prim */
|
||||
struct osmo_mtp_prim *m3ua_to_xfer_ind(struct xua_msg *xua)
|
||||
|
@ -227,6 +228,8 @@ static int hmrt_message_for_routing(struct osmo_ss7_instance *inst,
|
|||
dpc, osmo_ss7_pointcode_print(inst, dpc), rt_name);
|
||||
}
|
||||
|
||||
rate_ctr_inc2(as->ctrg, SS7_AS_CTR_TX_MSU_TOTAL);
|
||||
|
||||
switch (as->cfg.proto) {
|
||||
case OSMO_SS7_ASP_PROT_M3UA:
|
||||
DEBUGP(DLSS7, "rt->dest.as proto is M3UA for dpc=%u=%s\n",
|
||||
|
|
|
@ -7,3 +7,8 @@
|
|||
|
||||
bool osmo_ss7_asp_set_default_peer_hosts(struct osmo_ss7_asp *asp);
|
||||
bool osmo_ss7_xua_server_set_default_local_hosts(struct osmo_xua_server *oxs);
|
||||
|
||||
enum ss7_as_ctr {
|
||||
SS7_AS_CTR_RX_MSU_TOTAL,
|
||||
SS7_AS_CTR_TX_MSU_TOTAL,
|
||||
};
|
||||
|
|
|
@ -46,6 +46,7 @@
|
|||
#include "xua_asp_fsm.h"
|
||||
#include "xua_internal.h"
|
||||
#include "sccp_internal.h"
|
||||
#include "ss7_internal.h"
|
||||
|
||||
/* Appendix C.4 of Q.714 (all in milliseconds) */
|
||||
#define CONNECTION_TIMER ( 1 * 60 * 100)
|
||||
|
@ -521,6 +522,8 @@ static int sua_rx_cl(struct osmo_ss7_asp *asp, struct xua_msg *xua)
|
|||
if (rc)
|
||||
return rc;
|
||||
|
||||
rate_ctr_inc2(as->ctrg, SS7_AS_CTR_RX_MSU_TOTAL);
|
||||
|
||||
switch (xua->hdr.msg_type) {
|
||||
case 0: /* Reserved, permitted by ETSI TS 101 592 5.2.3.2 */
|
||||
case SUA_CL_CLDT:
|
||||
|
@ -549,6 +552,8 @@ static int sua_rx_co(struct osmo_ss7_asp *asp, struct xua_msg *xua)
|
|||
if (rc)
|
||||
return rc;
|
||||
|
||||
rate_ctr_inc2(as->ctrg, SS7_AS_CTR_RX_MSU_TOTAL);
|
||||
|
||||
switch (xua->hdr.msg_type) {
|
||||
case 0: /* Reserved, permitted by ETSI TS 101 592 5.2.3.2 */
|
||||
case SUA_CO_CORE:
|
||||
|
|
|
@ -32,6 +32,7 @@
|
|||
#include <osmocom/core/utils.h>
|
||||
#include <osmocom/core/logging.h>
|
||||
#include <osmocom/core/application.h>
|
||||
#include <osmocom/core/rate_ctr.h>
|
||||
#include <osmocom/core/fsm.h>
|
||||
#include <osmocom/vty/vty.h>
|
||||
#include <osmocom/vty/stats.h>
|
||||
|
@ -254,6 +255,7 @@ int main(int argc, char **argv)
|
|||
signal(SIGUSR1, &signal_handler);
|
||||
signal(SIGUSR2, &signal_handler);
|
||||
osmo_init_ignore_signals();
|
||||
rate_ctr_init(tall_stp_ctx);
|
||||
|
||||
if (cmdline_config.daemonize) {
|
||||
rc = osmo_daemonize();
|
||||
|
|
Loading…
Reference in New Issue