Browse Source

MT#55283 refactor interfaces stats block

Change-Id: I705b6d473d94525f6afd5a052d3eb6cbfe8dab37
pull/1614/head
Richard Fuchs 3 years ago
parent
commit
4498e181a6
7 changed files with 28 additions and 25 deletions
  1. +1
    -1
      daemon/call.c
  2. +3
    -3
      daemon/codec.c
  3. +2
    -2
      daemon/media_player.c
  4. +7
    -7
      daemon/media_socket.c
  5. +5
    -5
      daemon/statistics.c
  6. +7
    -4
      include/media_socket.h
  7. +3
    -3
      include/statistics.h

+ 1
- 1
daemon/call.c View File

@ -531,7 +531,7 @@ static void count_stream_stats_kernel(struct packet_stream *ps) {
else \
diff_ ## x ## _ ## io = (ke)->x - ks_val; \
atomic64_add(&ps->stats_ ## io.x, diff_ ## x ## _ ## io); \
atomic64_add(&ps->selected_sfd->local_intf->stats_ ## io.x, diff_ ## x ## _ ## io); \
atomic64_add(&ps->selected_sfd->local_intf->stats.io.x, diff_ ## x ## _ ## io); \
RTPE_STATS_ADD(x ## _kernel, diff_ ## x ## _ ## io); \
} while (0)


+ 3
- 3
daemon/codec.c View File

@ -1629,8 +1629,8 @@ static int __handler_func_sequencer(struct media_packet *mp, struct transcode_pa
atomic64_inc(&ssrc_in->packets);
atomic64_add(&ssrc_in->octets, mp->payload.len);
atomic64_inc(&mp->sfd->local_intf->stats_in.packets);
atomic64_add(&mp->sfd->local_intf->stats_in.bytes, mp->payload.len);
atomic64_inc(&mp->sfd->local_intf->stats.in.packets);
atomic64_add(&mp->sfd->local_intf->stats.in.bytes, mp->payload.len);
if (packet->bypass_seq) {
// bypass sequencer
@ -1672,7 +1672,7 @@ static int __handler_func_sequencer(struct media_packet *mp, struct transcode_pa
if (func_ret != 1)
__transcode_packet_free(packet);
ssrc_in_p->duplicates++;
atomic64_inc(&mp->sfd->local_intf->stats.duplicates);
atomic64_inc(&mp->sfd->local_intf->stats.s.duplicates);
RTPE_STATS_INC(rtp_duplicates);
goto out;
}


+ 2
- 2
daemon/media_player.c View File

@ -252,8 +252,8 @@ static bool __send_timer_send_1(struct rtp_header *rh, struct packet_stream *sin
atomic64_inc(&sink->stats_out.packets);
atomic64_add(&sink->stats_out.bytes, cp->s.len);
atomic64_inc(&sink_fd->local_intf->stats_out.packets);
atomic64_add(&sink_fd->local_intf->stats_out.bytes, cp->s.len);
atomic64_inc(&sink_fd->local_intf->stats.out.packets);
atomic64_add(&sink_fd->local_intf->stats.out.bytes, cp->s.len);
log_info_pop();


+ 7
- 7
daemon/media_socket.c View File

@ -1523,7 +1523,7 @@ static void __stream_update_stats(struct packet_stream *ps, int have_in_lock) {
parent->jitter = stats_info.ssrc_stats[u].jitter;
RTPE_STATS_ADD(packets_lost, stats_info.ssrc_stats[u].total_lost);
atomic64_add(&ps->selected_sfd->local_intf->stats.packets_lost,
atomic64_add(&ps->selected_sfd->local_intf->stats.s.packets_lost,
stats_info.ssrc_stats[u].total_lost);
uint32_t ssrc_map_out = ssrc_ctx->ssrc_map_out;
@ -1941,7 +1941,7 @@ static void media_packet_rtp_in(struct packet_handler_ctx *phc)
phc->payload_type,
FMT_M(endpoint_print_buf(&phc->mp.fsin)));
atomic64_inc(&phc->mp.stream->stats_in.errors);
atomic64_inc(&phc->mp.sfd->local_intf->stats_in.errors);
atomic64_inc(&phc->mp.sfd->local_intf->stats.in.errors);
RTPE_STATS_INC(errors_user);
}
else {
@ -2131,7 +2131,7 @@ static int media_packet_address_check(struct packet_handler_ctx *phc)
FMT_M(sockaddr_print_buf(&phc->mp.stream->endpoint.address),
phc->mp.stream->endpoint.port));
atomic64_inc(&phc->mp.stream->stats_in.errors);
atomic64_inc(&phc->mp.sfd->local_intf->stats_in.errors);
atomic64_inc(&phc->mp.sfd->local_intf->stats.in.errors);
ret = -1;
}
}
@ -2500,8 +2500,8 @@ static int stream_packet(struct packet_handler_ctx *phc) {
}
}
atomic64_add(&phc->mp.stream->stats_in.bytes, phc->s.len);
atomic64_inc(&phc->mp.sfd->local_intf->stats_in.packets);
atomic64_add(&phc->mp.sfd->local_intf->stats_in.bytes, phc->s.len);
atomic64_inc(&phc->mp.sfd->local_intf->stats.in.packets);
atomic64_add(&phc->mp.sfd->local_intf->stats.in.bytes, phc->s.len);
atomic64_set(&phc->mp.stream->last_packet, rtpe_now.tv_sec);
RTPE_STATS_INC(packets_user);
RTPE_STATS_ADD(bytes_user, phc->s.len);
@ -2665,7 +2665,7 @@ next_mirror:
err_next:
ilog(LOG_DEBUG | LOG_FLAG_LIMIT ,"Error when sending message. Error: %s", strerror(errno));
atomic64_inc(&sink->stats_in.errors);
atomic64_inc(&sink->selected_sfd->local_intf->stats_out.errors);
atomic64_inc(&sink->selected_sfd->local_intf->stats.out.errors);
RTPE_STATS_INC(errors_user);
goto next;
@ -2708,7 +2708,7 @@ out:
if (handler_ret < 0) {
atomic64_inc(&phc->mp.stream->stats_in.errors);
atomic64_inc(&phc->mp.sfd->local_intf->stats_in.errors);
atomic64_inc(&phc->mp.sfd->local_intf->stats.in.errors);
RTPE_STATS_INC(errors_user);
}


+ 5
- 5
daemon/statistics.c View File

@ -681,7 +681,7 @@ GQueue *statistics_gather_metrics(void) {
HEADER("}", NULL);
#define F(f) \
METRICs(#f, UINT64F, atomic64_get(&lif->stats.f)); \
METRICs(#f, UINT64F, atomic64_get(&lif->stats.s.f)); \
PROM("interface_" #f, "counter"); \
PROMLAB("name=\"%s\",address=\"%s\"", lif->logical->name.s, \
sockaddr_print_buf(&lif->spec->local_address.addr));
@ -692,10 +692,10 @@ GQueue *statistics_gather_metrics(void) {
HEADER("{", NULL);
struct interface_sampled_stats_avg stat_avg;
interface_sampled_avg(&stat_avg, &lif->sampled_stats);
interface_sampled_avg(&stat_avg, &lif->stats.sampled);
#define INTF_SAMPLED_STAT(stat_name, name, divisor, prefix, label...) \
STAT_GET_PRINT_GEN(&lif->sampled_stats, &sampled_avgs, stat_name, name, divisor, prefix, label)
STAT_GET_PRINT_GEN(&lif->stats.sampled, &stat_avg, stat_name, name, divisor, prefix, label)
INTF_SAMPLED_STAT(mos, "MOS", 10.0, "interface_",
"name=\"%s\",address=\"%s\"", lif->logical->name.s,
@ -721,7 +721,7 @@ GQueue *statistics_gather_metrics(void) {
HEADER("ingress", NULL);
HEADER("{", NULL);
#define F(f) \
METRICs(#f, UINT64F, atomic64_get(&lif->stats_in.f)); \
METRICs(#f, UINT64F, atomic64_get(&lif->stats.in.f)); \
PROM("interface_" #f, "gauge"); \
PROMLAB("name=\"%s\",address=\"%s\",direction=\"ingress\"", lif->logical->name.s, \
sockaddr_print_buf(&lif->spec->local_address.addr));
@ -732,7 +732,7 @@ GQueue *statistics_gather_metrics(void) {
HEADER("egress", NULL);
HEADER("{", NULL);
#define F(f) \
METRICs(#f, UINT64F, atomic64_get(&lif->stats_out.f)); \
METRICs(#f, UINT64F, atomic64_get(&lif->stats.out.f)); \
PROM("interface_" #f, "gauge"); \
PROMLAB("name=\"%s\",address=\"%s\",direction=\"egress\"", lif->logical->name.s, \
sockaddr_print_buf(&lif->spec->local_address.addr));


+ 7
- 4
include/media_socket.h View File

@ -129,6 +129,12 @@ struct interface_sampled_stats_avg {
struct interface_sampled_stats_fields avg;
struct interface_sampled_stats_fields stddev;
};
struct interface_stats_block {
struct interface_counter_stats_dir in,
out;
struct interface_counter_stats s;
struct interface_sampled_stats sampled;
};
INLINE void interface_sampled_calc_diff(const struct interface_sampled_stats *stats,
struct interface_sampled_stats *intv, struct interface_sampled_stats *diff)
{
@ -149,10 +155,7 @@ struct local_intf {
const struct logical_intf *logical;
str ice_foundation;
struct interface_counter_stats_dir stats_in,
stats_out;
struct interface_counter_stats stats;
struct interface_sampled_stats sampled_stats;
struct interface_stats_block stats;
};
struct intf_list {
struct local_intf *local_intf;


+ 3
- 3
include/statistics.h View File

@ -174,9 +174,9 @@ extern struct global_sampled_min_max rtpe_sampled_min_max; // master lifetime m
RTPE_STATS_SAMPLE(field, num); \
if (sfd) { \
struct local_intf *__intf = sfd->local_intf; \
atomic64_add(&__intf->sampled_stats.sums.field, num); \
atomic64_add(&__intf->sampled_stats.sums_squared.field, num * num); \
atomic64_inc(&__intf->sampled_stats.counts.field); \
atomic64_add(&__intf->stats.sampled.sums.field, num); \
atomic64_add(&__intf->stats.sampled.sums_squared.field, num * num); \
atomic64_inc(&__intf->stats.sampled.counts.field); \
} \
} while (0)


Loading…
Cancel
Save