]> granicus.if.org Git - sysstat/commitdiff
sadf: PCP: Add support for A_NET_ICMP and A_NET_EICMP activities
authorSebastien GODARD <sysstat@users.noreply.github.com>
Sun, 31 Mar 2019 15:56:05 +0000 (17:56 +0200)
committerSebastien GODARD <sysstat@users.noreply.github.com>
Sun, 31 Mar 2019 15:56:05 +0000 (17:56 +0200)
Add metrics displayed by "sar -n ICMP" and "sar -n EICMP" (network ICMP
statistics) to PCP archive.

Signed-off-by: Sebastien GODARD <sysstat@users.noreply.github.com>
activity.c
pcp_def_metrics.c
pcp_def_metrics.h
pcp_stats.c
pcp_stats.h
sadf_misc.c

index 0df8e208e1ee0e85941d33639deaef8b58cbe696..8a01b449dee67a3e73372cd865fe6ba97916e362 100644 (file)
@@ -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",
index 1ced8b2caa7c51ad3d9a3d534768437302ffbfdf..895d9aa86e22732d224b4fe841fdce2767cca110 100644 (file)
@@ -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 */
+}
index a037496043d3faeedb22453452ad37de8a62b9f0..1c096bb35ffbaccfe851f471e8b0ba3b6b158786 100644 (file)
@@ -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
index 784988adf2fd66e336f9e73913e03b7442db6c79..4e2eb5da0f1edd90bd54fcacc0fd7679e1f82150 100644 (file)
@@ -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 */
+}
index fd93d757bb299f9b0e0059a1f6c62f91f1cd34c4..66405a7349ea11474e5057e1eb2ca2f9d0b77d68 100644 (file)
@@ -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 */
index 4ebe4fd273fbf6193ce856454beaa3e2fdf1967d..b227498c09958c70ecded8ad6d2a030266fa453a 100644 (file)
@@ -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;
                        }
                }
        }