From: Sebastien GODARD Date: Sun, 31 Mar 2019 15:56:05 +0000 (+0200) Subject: sadf: PCP: Add support for A_NET_ICMP and A_NET_EICMP activities X-Git-Tag: v12.1.4~25 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=4e2b842a6f6e53b97fb28c301c739ccaf97c6523;p=sysstat sadf: PCP: Add support for A_NET_ICMP and A_NET_EICMP activities Add metrics displayed by "sar -n ICMP" and "sar -n EICMP" (network ICMP statistics) to PCP archive. Signed-off-by: Sebastien GODARD --- diff --git a/activity.c b/activity.c index 0df8e20..8a01b44 100644 --- a/activity.c +++ b/activity.c @@ -924,6 +924,7 @@ struct activity net_icmp_act = { .f_json_print = json_print_net_icmp_stats, .f_svg_print = svg_print_net_icmp_stats, .f_raw_print = raw_print_net_icmp_stats, + .f_pcp_print = pcp_print_net_icmp_stats, .f_count_new = NULL, .item_list = NULL, .desc = "ICMPv4 traffic statistics", @@ -970,6 +971,7 @@ struct activity net_eicmp_act = { .f_json_print = json_print_net_eicmp_stats, .f_svg_print = svg_print_net_eicmp_stats, .f_raw_print = raw_print_net_eicmp_stats, + .f_pcp_print = pcp_print_net_eicmp_stats, .f_count_new = NULL, .item_list = NULL, .desc = "ICMPv4 traffic errors statistics", diff --git a/pcp_def_metrics.c b/pcp_def_metrics.c index 1ced8b2..895d9aa 100644 --- a/pcp_def_metrics.c +++ b/pcp_def_metrics.c @@ -770,3 +770,127 @@ void pcp_def_net_eip_metrics(void) pmiUnits(0, -1, 1, 0, PM_TIME_SEC, PM_COUNT_ONE)); #endif /* HAVE_PCP */ } + +/* + *************************************************************************** + * Define PCP metrics for ICMP network statistics. + *************************************************************************** + */ +void pcp_def_net_icmp_metrics(void) +{ +#ifdef HAVE_PCP + pmiAddMetric("network.snmp.icmp.icmpInMsgs", + 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.icmp.icmpOutMsgs", + 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.icmp.icmpInEchos", + 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.icmp.icmpInEchoReps", + 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.icmp.icmpOutEchos", + 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.icmp.icmpOutEchoReps", + 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.icmp.icmpInTimestamps", + 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.icmp.icmpInTimestampReps", + 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.icmp.icmpOutTimestamps", + 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.icmp.icmpOutTimestampReps", + 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.icmp.icmpInAddrMasks", + 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.icmp.icmpInAddrMaskReps", + 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.icmp.icmpOutAddrMasks", + 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.icmp.icmpOutAddrMaskReps", + 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 ICMP network errors statistics. + *************************************************************************** + */ +void pcp_def_net_eicmp_metrics(void) +{ +#ifdef HAVE_PCP + pmiAddMetric("network.snmp.icmp.icmpInErrors", + 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.icmp.icmpOutErrors", + 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.icmp.icmpInDestUnreachs", + 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.icmp.icmpOutDestUnreachs", + 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.icmp.icmpInTimeExcds", + 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.icmp.icmpOutTimeExcds", + 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.icmp.icmpInParmProbs", + 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.icmp.icmpOutParmProbs", + 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.icmp.icmpInSrcQuenchs", + 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.icmp.icmpOutSrcQuenchs", + 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.icmp.icmpInRedirects", + 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.icmp.icmpOutRedirects", + 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 a037496..1c096bb 100644 --- a/pcp_def_metrics.h +++ b/pcp_def_metrics.h @@ -27,6 +27,8 @@ void pcp_def_net_nfs_metrics(void); void pcp_def_net_nfsd_metrics(void); void pcp_def_net_ip_metrics(void); void pcp_def_net_eip_metrics(void); +void pcp_def_net_icmp_metrics(void); +void pcp_def_net_eicmp_metrics(void); /* Define domains number */ #define PM_INDOM_CPU 0 diff --git a/pcp_stats.c b/pcp_stats.c index 784988a..4e2eb5d 100644 --- a/pcp_stats.c +++ b/pcp_stats.c @@ -1012,3 +1012,152 @@ __print_funct_t pcp_print_net_eip_stats(struct activity *a, int curr, unsigned l pmiPutValue("network.snmp.ip.ipFragFails", NULL, buf); #endif /* HAVE_PCP */ } + +/* + *************************************************************************** + * Display ICMP 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_icmp_stats(struct activity *a, int curr, unsigned long long itv, + struct record_header *record_hdr) +{ +#ifdef HAVE_PCP + char buf[64]; + struct stats_net_icmp + *snic = (struct stats_net_icmp *) a->buf[curr], + *snip = (struct stats_net_icmp *) a->buf[!curr]; + + snprintf(buf, sizeof(buf), "%f", + S_VALUE(snip->InMsgs, snic->InMsgs, itv)); + pmiPutValue("network.snmp.icmp.icmpInMsgs", NULL, buf); + + snprintf(buf, sizeof(buf), "%f", + S_VALUE(snip->OutMsgs, snic->OutMsgs, itv)); + pmiPutValue("network.snmp.icmp.icmpOutMsgs", NULL, buf); + + snprintf(buf, sizeof(buf), "%f", + S_VALUE(snip->InEchos, snic->InEchos, itv)); + pmiPutValue("network.snmp.icmp.icmpInEchos", NULL, buf); + + snprintf(buf, sizeof(buf), "%f", + S_VALUE(snip->InEchoReps, snic->InEchoReps, itv)); + pmiPutValue("network.snmp.icmp.icmpInEchoReps", NULL, buf); + + snprintf(buf, sizeof(buf), "%f", + S_VALUE(snip->OutEchos, snic->OutEchos, itv)); + pmiPutValue("network.snmp.icmp.icmpOutEchos", NULL, buf); + + snprintf(buf, sizeof(buf), "%f", + S_VALUE(snip->OutEchoReps, snic->OutEchoReps, itv)); + pmiPutValue("network.snmp.icmp.icmpOutEchoReps", NULL, buf); + + snprintf(buf, sizeof(buf), "%f", + S_VALUE(snip->InTimestamps, snic->InTimestamps, itv)); + pmiPutValue("network.snmp.icmp.icmpInTimestamps", NULL, buf); + + snprintf(buf, sizeof(buf), "%f", + S_VALUE(snip->InTimestampReps, snic->InTimestampReps, itv)); + pmiPutValue("network.snmp.icmp.icmpInTimestampReps", NULL, buf); + + snprintf(buf, sizeof(buf), "%f", + S_VALUE(snip->OutTimestamps, snic->OutTimestamps, itv)); + pmiPutValue("network.snmp.icmp.icmpOutTimestamps", NULL, buf); + + snprintf(buf, sizeof(buf), "%f", + S_VALUE(snip->OutTimestampReps, snic->OutTimestampReps, itv)); + pmiPutValue("network.snmp.icmp.icmpOutTimestampReps", NULL, buf); + + snprintf(buf, sizeof(buf), "%f", + S_VALUE(snip->InAddrMasks, snic->InAddrMasks, itv)); + pmiPutValue("network.snmp.icmp.icmpInAddrMasks", NULL, buf); + + snprintf(buf, sizeof(buf), "%f", + S_VALUE(snip->InAddrMaskReps, snic->InAddrMaskReps, itv)); + pmiPutValue("network.snmp.icmp.icmpInAddrMaskReps", NULL, buf); + + snprintf(buf, sizeof(buf), "%f", + S_VALUE(snip->OutAddrMasks, snic->OutAddrMasks, itv)); + pmiPutValue("network.snmp.icmp.icmpOutAddrMasks", NULL, buf); + + snprintf(buf, sizeof(buf), "%f", + S_VALUE(snip->OutAddrMaskReps, snic->OutAddrMaskReps, itv)); + pmiPutValue("network.snmp.icmp.icmpOutAddrMaskReps", NULL, buf); +#endif /* HAVE_PCP */ +} + + +/* + *************************************************************************** + * Display ICMP 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_eicmp_stats(struct activity *a, int curr, unsigned long long itv, + struct record_header *record_hdr) +{ +#ifdef HAVE_PCP + char buf[64]; + struct stats_net_eicmp + *sneic = (struct stats_net_eicmp *) a->buf[curr], + *sneip = (struct stats_net_eicmp *) a->buf[!curr]; + + snprintf(buf, sizeof(buf), "%f", + S_VALUE(sneip->InErrors, sneic->InErrors, itv)); + pmiPutValue("network.snmp.icmp.icmpInErrors", NULL, buf); + + snprintf(buf, sizeof(buf), "%f", + S_VALUE(sneip->OutErrors, sneic->OutErrors, itv)); + pmiPutValue("network.snmp.icmp.icmpOutErrors", NULL, buf); + + snprintf(buf, sizeof(buf), "%f", + S_VALUE(sneip->InDestUnreachs, sneic->InDestUnreachs, itv)); + pmiPutValue("network.snmp.icmp.icmpInDestUnreachs", NULL, buf); + + snprintf(buf, sizeof(buf), "%f", + S_VALUE(sneip->OutDestUnreachs, sneic->OutDestUnreachs, itv)); + pmiPutValue("network.snmp.icmp.icmpOutDestUnreachs", NULL, buf); + + snprintf(buf, sizeof(buf), "%f", + S_VALUE(sneip->InTimeExcds, sneic->InTimeExcds, itv)); + pmiPutValue("network.snmp.icmp.icmpInTimeExcds", NULL, buf); + + snprintf(buf, sizeof(buf), "%f", + S_VALUE(sneip->OutTimeExcds, sneic->OutTimeExcds, itv)); + pmiPutValue("network.snmp.icmp.icmpOutTimeExcds", NULL, buf); + + snprintf(buf, sizeof(buf), "%f", + S_VALUE(sneip->InParmProbs, sneic->InParmProbs, itv)); + pmiPutValue("network.snmp.icmp.icmpInParmProbs", NULL, buf); + + snprintf(buf, sizeof(buf), "%f", + S_VALUE(sneip->OutParmProbs, sneic->OutParmProbs, itv)); + pmiPutValue("network.snmp.icmp.icmpOutParmProbs", NULL, buf); + + snprintf(buf, sizeof(buf), "%f", + S_VALUE(sneip->InSrcQuenchs, sneic->InSrcQuenchs, itv)); + pmiPutValue("network.snmp.icmp.icmpInSrcQuenchs", NULL, buf); + + snprintf(buf, sizeof(buf), "%f", + S_VALUE(sneip->OutSrcQuenchs, sneic->OutSrcQuenchs, itv)); + pmiPutValue("network.snmp.icmp.icmpOutSrcQuenchs", NULL, buf); + + snprintf(buf, sizeof(buf), "%f", + S_VALUE(sneip->InRedirects, sneic->InRedirects, itv)); + pmiPutValue("network.snmp.icmp.icmpInRedirects", NULL, buf); + + snprintf(buf, sizeof(buf), "%f", + S_VALUE(sneip->OutRedirects, sneic->OutRedirects, itv)); + pmiPutValue("network.snmp.icmp.icmpOutRedirects", NULL, buf); +#endif /* HAVE_PCP */ +} diff --git a/pcp_stats.h b/pcp_stats.h index fd93d75..66405a7 100644 --- a/pcp_stats.h +++ b/pcp_stats.h @@ -45,5 +45,9 @@ __print_funct_t pcp_print_net_ip_stats (struct activity *, int, unsigned long long, struct record_header *); __print_funct_t pcp_print_net_eip_stats (struct activity *, int, unsigned long long, struct record_header *); +__print_funct_t pcp_print_net_icmp_stats + (struct activity *, int, unsigned long long, struct record_header *); +__print_funct_t pcp_print_net_eicmp_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 4ebe4fd..b227498 100644 --- a/sadf_misc.c +++ b/sadf_misc.c @@ -560,6 +560,14 @@ __printf_funct_t print_pcp_statistics(int *tab, int action, struct activity *act case A_NET_EIP: pcp_def_net_eip_metrics(); break; + + case A_NET_ICMP: + pcp_def_net_icmp_metrics(); + break; + + case A_NET_EICMP: + pcp_def_net_eicmp_metrics(); + break; } } }