From: Sebastien GODARD Date: Sun, 31 Mar 2019 16:20:58 +0000 (+0200) Subject: sadf: PCP: Add support for A_NET_UDP activity X-Git-Tag: v12.1.4~23 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=9808041198a7a3629fb2fa95360499896a3867e5;p=sysstat sadf: PCP: Add support for A_NET_UDP activity Add metrics displayed by "sar -n UDP" (UDP network statistics) to PCP archive. Signed-off-by: Sebastien GODARD --- diff --git a/activity.c b/activity.c index c1d6df9..4c95a06 100644 --- a/activity.c +++ b/activity.c @@ -1109,6 +1109,7 @@ struct activity net_udp_act = { .f_json_print = json_print_net_udp_stats, .f_svg_print = svg_print_net_udp_stats, .f_raw_print = raw_print_net_udp_stats, + .f_pcp_print = pcp_print_net_udp_stats, .f_count_new = NULL, .item_list = NULL, .desc = "UDPv4 traffic statistics", diff --git a/pcp_def_metrics.c b/pcp_def_metrics.c index ea94b9f..59b9642 100644 --- a/pcp_def_metrics.c +++ b/pcp_def_metrics.c @@ -950,3 +950,29 @@ void pcp_def_net_etcp_metrics(void) pmiUnits(0, -1, 1, 0, PM_TIME_SEC, PM_COUNT_ONE)); #endif /* HAVE_PCP */ } + +/* + *************************************************************************** + * Define PCP metrics for UDP network statistics. + *************************************************************************** + */ +void pcp_def_net_udp_metrics(void) +{ +#ifdef HAVE_PCP + pmiAddMetric("network.snmp.udp.udpInDatagrams", + PM_IN_NULL, PM_TYPE_FLOAT, PM_INDOM_NULL, PM_SEM_INSTANT, + pmiUnits(0, -1, 1, 0, PM_TIME_SEC, PM_COUNT_ONE)); + + pmiAddMetric("network.snmp.udp.udpOutDatagrams", + PM_IN_NULL, PM_TYPE_FLOAT, PM_INDOM_NULL, PM_SEM_INSTANT, + pmiUnits(0, -1, 1, 0, PM_TIME_SEC, PM_COUNT_ONE)); + + pmiAddMetric("network.snmp.udp.udpNoPorts", + PM_IN_NULL, PM_TYPE_FLOAT, PM_INDOM_NULL, PM_SEM_INSTANT, + pmiUnits(0, -1, 1, 0, PM_TIME_SEC, PM_COUNT_ONE)); + + pmiAddMetric("network.snmp.udp.udpInErrors", + PM_IN_NULL, PM_TYPE_FLOAT, PM_INDOM_NULL, PM_SEM_INSTANT, + pmiUnits(0, -1, 1, 0, PM_TIME_SEC, PM_COUNT_ONE)); +#endif /* HAVE_PCP */ +} diff --git a/pcp_def_metrics.h b/pcp_def_metrics.h index f65aed9..84f5882 100644 --- a/pcp_def_metrics.h +++ b/pcp_def_metrics.h @@ -31,6 +31,7 @@ void pcp_def_net_icmp_metrics(void); void pcp_def_net_eicmp_metrics(void); void pcp_def_net_tcp_metrics(void); void pcp_def_net_etcp_metrics(void); +void pcp_def_net_udp_metrics(void); /* Define domains number */ #define PM_INDOM_CPU 0 diff --git a/pcp_stats.c b/pcp_stats.c index a559455..f882946 100644 --- a/pcp_stats.c +++ b/pcp_stats.c @@ -1241,3 +1241,41 @@ __print_funct_t pcp_print_net_etcp_stats(struct activity *a, int curr, unsigned pmiPutValue("network.snmp.tcp.tcpOutRsts", NULL, buf); #endif /* HAVE_PCP */ } + +/* + *************************************************************************** + * Display UDP network statistics in PCP format. + * + * IN: + * @a Activity structure with statistics. + * @curr Index in array for current sample statistics. + * @itv Interval of time in 1/100th of a second. + * @record_hdr Record header for current sample. + *************************************************************************** + */ +__print_funct_t pcp_print_net_udp_stats(struct activity *a, int curr, unsigned long long itv, + struct record_header *record_hdr) +{ +#ifdef HAVE_PCP + char buf[64]; + struct stats_net_udp + *snuc = (struct stats_net_udp *) a->buf[curr], + *snup = (struct stats_net_udp *) a->buf[!curr]; + + snprintf(buf, sizeof(buf), "%f", + S_VALUE(snup->InDatagrams, snuc->InDatagrams, itv)); + pmiPutValue("network.snmp.udp.udpInDatagrams", NULL, buf); + + snprintf(buf, sizeof(buf), "%f", + S_VALUE(snup->OutDatagrams, snuc->OutDatagrams, itv)); + pmiPutValue("network.snmp.udp.udpOutDatagrams", NULL, buf); + + snprintf(buf, sizeof(buf), "%f", + S_VALUE(snup->NoPorts, snuc->NoPorts, itv)); + pmiPutValue("network.snmp.udp.udpNoPorts", NULL, buf); + + snprintf(buf, sizeof(buf), "%f", + S_VALUE(snup->InErrors, snuc->InErrors, itv)); + pmiPutValue("network.snmp.udp.udpInErrors", NULL, buf); +#endif /* HAVE_PCP */ +} diff --git a/pcp_stats.h b/pcp_stats.h index 4938dcc..6e686f1 100644 --- a/pcp_stats.h +++ b/pcp_stats.h @@ -53,5 +53,7 @@ __print_funct_t pcp_print_net_tcp_stats (struct activity *, int, unsigned long long, struct record_header *); __print_funct_t pcp_print_net_etcp_stats (struct activity *, int, unsigned long long, struct record_header *); +__print_funct_t pcp_print_net_udp_stats + (struct activity *, int, unsigned long long, struct record_header *); #endif /* _PCP_STATS_H */ diff --git a/sadf_misc.c b/sadf_misc.c index f0d1c33..dad4649 100644 --- a/sadf_misc.c +++ b/sadf_misc.c @@ -576,6 +576,10 @@ __printf_funct_t print_pcp_statistics(int *tab, int action, struct activity *act case A_NET_ETCP: pcp_def_net_etcp_metrics(); break; + + case A_NET_UDP: + pcp_def_net_udp_metrics(); + break; } } }