From: Sebastien GODARD Date: Sun, 31 Mar 2019 16:43:45 +0000 (+0200) Subject: sadf: PCP: Add support for A_NET_IP6 and A_NET_EIP6 activities X-Git-Tag: v12.1.4~22 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=04ba6bc4cc9cb37a013cbd8d5fda0e61fcfaa59c;p=sysstat sadf: PCP: Add support for A_NET_IP6 and A_NET_EIP6 activities Add metrics displayed by "sar -n IP6" and "sar -n EIP6" (IPv6 network statistics) to PCP archive. Signed-off-by: Sebastien GODARD --- diff --git a/activity.c b/activity.c index 4c95a06..6eff06f 100644 --- a/activity.c +++ b/activity.c @@ -1201,6 +1201,7 @@ struct activity net_ip6_act = { .f_json_print = json_print_net_ip6_stats, .f_svg_print = svg_print_net_ip6_stats, .f_raw_print = raw_print_net_ip6_stats, + .f_pcp_print = pcp_print_net_ip6_stats, .f_count_new = NULL, .item_list = NULL, .desc = "IPv6 traffic statistics", @@ -1247,6 +1248,7 @@ struct activity net_eip6_act = { .f_json_print = json_print_net_eip6_stats, .f_svg_print = svg_print_net_eip6_stats, .f_raw_print = raw_print_net_eip6_stats, + .f_pcp_print = pcp_print_net_eip6_stats, .f_count_new = NULL, .item_list = NULL, .desc = "IPv6 traffic errors statistics", diff --git a/pcp_def_metrics.c b/pcp_def_metrics.c index 59b9642..e318835 100644 --- a/pcp_def_metrics.c +++ b/pcp_def_metrics.c @@ -976,3 +976,107 @@ void pcp_def_net_udp_metrics(void) pmiUnits(0, -1, 1, 0, PM_TIME_SEC, PM_COUNT_ONE)); #endif /* HAVE_PCP */ } + +/* + *************************************************************************** + * Define PCP metrics for IPv6 network statistics. + *************************************************************************** + */ +void pcp_def_net_ip6_metrics(void) +{ +#ifdef HAVE_PCP + pmiAddMetric("network.snmp.ip6.ipv6IfStatsInReceives", + 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.ip6.ipv6IfStatsOutForwDatagrams", + 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.ip6.ipv6IfStatsInDelivers", + 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.ip6.ipv6IfStatsOutRequests", + 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.ip6.ipv6IfStatsReasmReqds", + 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.ip6.ipv6IfStatsReasmOKs", + 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.ip6.ipv6IfStatsInMcastPkts", + 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.ip6.ipv6IfStatsOutMcastPkts", + 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.ip6.ipv6IfStatsOutFragOKs", + 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.ip6.ipv6IfStatsOutFragCreates", + 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 */ +} + +/* + *************************************************************************** + * Define PCP metrics for IPv6 network errors statistics. + *************************************************************************** + */ +void pcp_def_net_eip6_metrics(void) +{ +#ifdef HAVE_PCP + pmiAddMetric("network.snmp.ip6.ipv6IfStatsInHdrErrors", + 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.ip6.ipv6IfStatsInAddrErrors", + 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.ip6.ipv6IfStatsInUnknownProtos", + 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.ip6.ipv6IfStatsInTooBigErrors", + 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.ip6.ipv6IfStatsInDiscards", + 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.ip6.ipv6IfStatsOutDiscards", + 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.ip6.ipv6IfStatsInNoRoutes", + 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.ip6.ipv6IfStatsOutNoRoutes", + 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.ip6.ipv6IfStatsReasmFails", + 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.ip6.ipv6IfStatsOutFragFails", + 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.ip6.ipv6IfStatsInTruncatedPkts", + 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 84f5882..1f25cfc 100644 --- a/pcp_def_metrics.h +++ b/pcp_def_metrics.h @@ -32,6 +32,8 @@ 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); +void pcp_def_net_ip6_metrics(void); +void pcp_def_net_eip6_metrics(void); /* Define domains number */ #define PM_INDOM_CPU 0 diff --git a/pcp_stats.c b/pcp_stats.c index f882946..da74701 100644 --- a/pcp_stats.c +++ b/pcp_stats.c @@ -1279,3 +1279,131 @@ __print_funct_t pcp_print_net_udp_stats(struct activity *a, int curr, unsigned l pmiPutValue("network.snmp.udp.udpInErrors", NULL, buf); #endif /* HAVE_PCP */ } + +/* + *************************************************************************** + * Display IPv6 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_ip6_stats(struct activity *a, int curr, unsigned long long itv, + struct record_header *record_hdr) +{ +#ifdef HAVE_PCP + char buf[64]; + struct stats_net_ip6 + *snic = (struct stats_net_ip6 *) a->buf[curr], + *snip = (struct stats_net_ip6 *) a->buf[!curr]; + + snprintf(buf, sizeof(buf), "%f", + S_VALUE(snip->InReceives6, snic->InReceives6, itv)); + pmiPutValue("network.snmp.ip6.ipv6IfStatsInReceives", NULL, buf); + + snprintf(buf, sizeof(buf), "%f", + S_VALUE(snip->OutForwDatagrams6, snic->OutForwDatagrams6, itv)); + pmiPutValue("network.snmp.ip6.ipv6IfStatsOutForwDatagrams", NULL, buf); + + snprintf(buf, sizeof(buf), "%f", + S_VALUE(snip->InDelivers6, snic->InDelivers6, itv)); + pmiPutValue("network.snmp.ip6.ipv6IfStatsInDelivers", NULL, buf); + + snprintf(buf, sizeof(buf), "%f", + S_VALUE(snip->OutRequests6, snic->OutRequests6, itv)); + pmiPutValue("network.snmp.ip6.ipv6IfStatsOutRequests", NULL, buf); + + snprintf(buf, sizeof(buf), "%f", + S_VALUE(snip->ReasmReqds6, snic->ReasmReqds6, itv)); + pmiPutValue("network.snmp.ip6.ipv6IfStatsReasmReqds", NULL, buf); + + snprintf(buf, sizeof(buf), "%f", + S_VALUE(snip->ReasmOKs6, snic->ReasmOKs6, itv)); + pmiPutValue("network.snmp.ip6.ipv6IfStatsReasmOKs", NULL, buf); + + snprintf(buf, sizeof(buf), "%f", + S_VALUE(snip->InMcastPkts6, snic->InMcastPkts6, itv)); + pmiPutValue("network.snmp.ip6.ipv6IfStatsInMcastPkts", NULL, buf); + + snprintf(buf, sizeof(buf), "%f", + S_VALUE(snip->OutMcastPkts6, snic->OutMcastPkts6, itv)); + pmiPutValue("network.snmp.ip6.ipv6IfStatsOutMcastPkts", NULL, buf); + + snprintf(buf, sizeof(buf), "%f", + S_VALUE(snip->FragOKs6, snic->FragOKs6, itv)); + pmiPutValue("network.snmp.ip6.ipv6IfStatsOutFragOKs", NULL, buf); + + snprintf(buf, sizeof(buf), "%f", + S_VALUE(snip->FragCreates6, snic->FragCreates6, itv)); + pmiPutValue("network.snmp.ip6.ipv6IfStatsOutFragCreates", NULL, buf); +#endif /* HAVE_PCP */ +} + +/* + *************************************************************************** + * Display IPv6 network errors 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_eip6_stats(struct activity *a, int curr, unsigned long long itv, + struct record_header *record_hdr) +{ +#ifdef HAVE_PCP + char buf[64]; + struct stats_net_eip6 + *sneic = (struct stats_net_eip6 *) a->buf[curr], + *sneip = (struct stats_net_eip6 *) a->buf[!curr]; + + snprintf(buf, sizeof(buf), "%f", + S_VALUE(sneip->InHdrErrors6, sneic->InHdrErrors6, itv)); + pmiPutValue("network.snmp.ip6.ipv6IfStatsInHdrErrors", NULL, buf); + + snprintf(buf, sizeof(buf), "%f", + S_VALUE(sneip->InAddrErrors6, sneic->InAddrErrors6, itv)); + pmiPutValue("network.snmp.ip6.ipv6IfStatsInAddrErrors", NULL, buf); + + snprintf(buf, sizeof(buf), "%f", + S_VALUE(sneip->InUnknownProtos6, sneic->InUnknownProtos6, itv)); + pmiPutValue("network.snmp.ip6.ipv6IfStatsInUnknownProtos", NULL, buf); + + snprintf(buf, sizeof(buf), "%f", + S_VALUE(sneip->InTooBigErrors6, sneic->InTooBigErrors6, itv)); + pmiPutValue("network.snmp.ip6.ipv6IfStatsInTooBigErrors", NULL, buf); + + snprintf(buf, sizeof(buf), "%f", + S_VALUE(sneip->InDiscards6, sneic->InDiscards6, itv)); + pmiPutValue("network.snmp.ip6.ipv6IfStatsInDiscards", NULL, buf); + + snprintf(buf, sizeof(buf), "%f", + S_VALUE(sneip->OutDiscards6, sneic->OutDiscards6, itv)); + pmiPutValue("network.snmp.ip6.ipv6IfStatsOutDiscards", NULL, buf); + + snprintf(buf, sizeof(buf), "%f", + S_VALUE(sneip->InNoRoutes6, sneic->InNoRoutes6, itv)); + pmiPutValue("network.snmp.ip6.ipv6IfStatsInNoRoutes", NULL, buf); + + snprintf(buf, sizeof(buf), "%f", + S_VALUE(sneip->OutNoRoutes6, sneic->OutNoRoutes6, itv)); + pmiPutValue("network.snmp.ip6.ipv6IfStatsOutNoRoutes", NULL, buf); + + snprintf(buf, sizeof(buf), "%f", + S_VALUE(sneip->ReasmFails6, sneic->ReasmFails6, itv)); + pmiPutValue("network.snmp.ip6.ipv6IfStatsReasmFails", NULL, buf); + + snprintf(buf, sizeof(buf), "%f", + S_VALUE(sneip->FragFails6, sneic->FragFails6, itv)); + pmiPutValue("network.snmp.ip6.ipv6IfStatsOutFragFails", NULL, buf); + + snprintf(buf, sizeof(buf), "%f", + S_VALUE(sneip->InTruncatedPkts6, sneic->InTruncatedPkts6, itv)); + pmiPutValue("network.snmp.ip6.ipv6IfStatsInTruncatedPkts", NULL, buf); +#endif /* HAVE_PCP */ +} diff --git a/pcp_stats.h b/pcp_stats.h index 6e686f1..0f372d7 100644 --- a/pcp_stats.h +++ b/pcp_stats.h @@ -55,5 +55,9 @@ __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 *); +__print_funct_t pcp_print_net_ip6_stats + (struct activity *, int, unsigned long long, struct record_header *); +__print_funct_t pcp_print_net_eip6_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 dad4649..e9cd8e5 100644 --- a/sadf_misc.c +++ b/sadf_misc.c @@ -580,6 +580,14 @@ __printf_funct_t print_pcp_statistics(int *tab, int action, struct activity *act case A_NET_UDP: pcp_def_net_udp_metrics(); break; + + case A_NET_IP6: + pcp_def_net_ip6_metrics(); + break; + + case A_NET_EIP6: + pcp_def_net_eip6_metrics(); + break; } } }