]> granicus.if.org Git - sysstat/commitdiff
sadf: PCP: Add PSI support
authorSebastien GODARD <sysstat@users.noreply.github.com>
Tue, 14 Apr 2020 08:15:15 +0000 (10:15 +0200)
committerSebastien GODARD <sysstat@users.noreply.github.com>
Tue, 14 Apr 2020 08:15:15 +0000 (10:15 +0200)
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 47b9440f86d6727f3ba04c05f03619be02614290..bbc554751ea0a6ac2f08096ccfc6b1a17b8e9eb3 100644 (file)
@@ -1899,7 +1899,7 @@ struct activity psi_cpu_act = {
        .f_json_print   = json_print_psicpu_stats,
        .f_svg_print    = svg_print_psicpu_stats,
        .f_raw_print    = raw_print_psicpu_stats,
-//FIXME        .f_pcp_print    = pcp_print_psicpu_stats,
+       .f_pcp_print    = pcp_print_psicpu_stats,
        .f_count_new    = NULL,
        .item_list      = NULL,
        .desc           = "Pressure-stall CPU statistics",
@@ -1945,7 +1945,7 @@ struct activity psi_io_act = {
        .f_json_print   = json_print_psiio_stats,
        .f_svg_print    = svg_print_psiio_stats,
        .f_raw_print    = raw_print_psiio_stats,
-//FIXME        .f_pcp_print    = pcp_print_psiio_stats,
+       .f_pcp_print    = pcp_print_psiio_stats,
        .f_count_new    = NULL,
        .item_list      = NULL,
        .desc           = "Pressure-stall I/O statistics",
@@ -1991,7 +1991,7 @@ struct activity psi_mem_act = {
        .f_json_print   = json_print_psimem_stats,
        .f_svg_print    = svg_print_psimem_stats,
        .f_raw_print    = raw_print_psimem_stats,
-//FIXME        .f_pcp_print    = pcp_print_psimem_stats,
+       .f_pcp_print    = pcp_print_psimem_stats,
        .f_count_new    = NULL,
        .item_list      = NULL,
        .desc           = "Pressure-stall memory statistics",
index 570e419c661bf2b0aa216d772507c89308a70378..b350aaa4f79a54b7e089fcd555ce8253f5b6e380 100644 (file)
@@ -1756,3 +1756,74 @@ void pcp_def_fchost_metrics(struct activity *a)
                     pmiUnits(0, -1, 1, 0, PM_TIME_SEC, PM_COUNT_ONE));
 #endif /* HAVE_PCP */
 }
+
+/*
+ ***************************************************************************
+ * Define PCP metrics for pressure-stall statistics.
+ *
+ * IN:
+ * @a  Activity structure with statistics.
+ ***************************************************************************
+ */
+void pcp_def_psi_metrics(struct activity *a)
+{
+#ifdef HAVE_PCP
+       static pmInDom indom = PM_INDOM_NULL;
+
+       if (indom == PM_INDOM_NULL) {
+               /* Create domain */
+               indom = pmInDom_build(0, PM_INDOM_PSI);
+
+               pmiAddInstance(indom, "10 sec", 0);
+               pmiAddInstance(indom, "60 sec", 1);
+               pmiAddInstance(indom, "300 sec", 2);
+       }
+
+       if (a->id == A_PSI_CPU) {
+               /* Create metrics for A_PSI_CPU */
+               pmiAddMetric("psi.cpu.some.trends",
+                            PM_IN_NULL, PM_TYPE_FLOAT, indom, PM_SEM_INSTANT,
+                            pmiUnits(0, 0, 0, 0, 0, 0));
+
+               pmiAddMetric("psi.cpu.some.total",
+                            PM_IN_NULL, PM_TYPE_FLOAT, PM_INDOM_NULL, PM_SEM_INSTANT,
+                            pmiUnits(0, -1, 1, 0, PM_TIME_SEC, PM_COUNT_ONE));
+       }
+       else if (a->id == A_PSI_IO) {
+               /* Create metrics for A_PSI_IO */
+               pmiAddMetric("psi.io.some.trends",
+                            PM_IN_NULL, PM_TYPE_FLOAT, indom, PM_SEM_INSTANT,
+                            pmiUnits(0, 0, 0, 0, 0, 0));
+
+               pmiAddMetric("psi.io.some.total",
+                            PM_IN_NULL, PM_TYPE_FLOAT, PM_INDOM_NULL, PM_SEM_INSTANT,
+                            pmiUnits(0, -1, 1, 0, PM_TIME_SEC, PM_COUNT_ONE));
+
+               pmiAddMetric("psi.io.full.trends",
+                            PM_IN_NULL, PM_TYPE_FLOAT, indom, PM_SEM_INSTANT,
+                            pmiUnits(0, 0, 0, 0, 0, 0));
+
+               pmiAddMetric("psi.io.full.total",
+                            PM_IN_NULL, PM_TYPE_FLOAT, PM_INDOM_NULL, PM_SEM_INSTANT,
+                            pmiUnits(0, -1, 1, 0, PM_TIME_SEC, PM_COUNT_ONE));
+       }
+       else {
+               /* Create metrics for A_PSI_MEM */
+               pmiAddMetric("psi.mem.some.trends",
+                            PM_IN_NULL, PM_TYPE_FLOAT, indom, PM_SEM_INSTANT,
+                            pmiUnits(0, 0, 0, 0, 0, 0));
+
+               pmiAddMetric("psi.mem.some.total",
+                            PM_IN_NULL, PM_TYPE_FLOAT, PM_INDOM_NULL, PM_SEM_INSTANT,
+                            pmiUnits(0, -1, 1, 0, PM_TIME_SEC, PM_COUNT_ONE));
+
+               pmiAddMetric("psi.mem.full.trends",
+                            PM_IN_NULL, PM_TYPE_FLOAT, indom, PM_SEM_INSTANT,
+                            pmiUnits(0, 0, 0, 0, 0, 0));
+
+               pmiAddMetric("psi.mem.full.total",
+                            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 bc5cd89f8e9cb99783b62746283a7ee1d4ba0d54..1eff754a5d8279b0c7a9fd6bee1c91b70ce4b210 100644 (file)
@@ -47,6 +47,7 @@ void pcp_def_pwr_in_metrics(struct activity *);
 void pcp_def_pwr_usb_metrics(struct activity *);
 void pcp_def_filesystem_metrics(struct activity *);
 void pcp_def_fchost_metrics(struct activity *);
+void pcp_def_psi_metrics(struct activity *);
 
 /* Define domains number */
 #define PM_INDOM_CPU           0
@@ -61,5 +62,6 @@ void pcp_def_fchost_metrics(struct activity *);
 #define PM_INDOM_FAN           9
 #define PM_INDOM_TEMP          10
 #define PM_INDOM_IN            11
+#define PM_INDOM_PSI           12
 
 #endif /* _PCP_DEF_METRICS_H */
index 675a08255f4e00b8d14ab35f2b821a5020c9198f..b640d5e5e2c6b5d4f0677a391fd3bcd845795147 100644 (file)
@@ -2242,3 +2242,134 @@ __print_funct_t pcp_print_fchost_stats(struct activity *a, int curr, unsigned lo
        }
 #endif /* HAVE_PCP */
 }
+
+/*
+ ***************************************************************************
+ * Display pressure-stall CPU 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_psicpu_stats(struct activity *a, int curr, unsigned long long itv,
+                                      struct record_header *record_hdr)
+{
+#ifdef HAVE_PCP
+       char buf[64];
+       struct stats_psi_cpu
+               *psic = (struct stats_psi_cpu *) a->buf[curr],
+               *psip = (struct stats_psi_cpu *) a->buf[!curr];
+
+       snprintf(buf, sizeof(buf), "%f", (double) psic->some_acpu_10 / 100);
+       pmiPutValue("psi.cpu.some.trends", "10 sec", buf);
+
+       snprintf(buf, sizeof(buf), "%f", (double) psic->some_acpu_60 / 100);
+       pmiPutValue("psi.cpu.some.trends", "60 sec", buf);
+
+       snprintf(buf, sizeof(buf), "%f", (double) psic->some_acpu_300 / 100);
+       pmiPutValue("psi.cpu.some.trends", "300 sec", buf);
+
+       snprintf(buf, sizeof(buf), "%f",
+                S_VALUE(psip->some_cpu_total, psic->some_cpu_total, itv));
+       pmiPutValue("psi.cpu.some.total", NULL, buf);
+#endif /* HAVE_PCP */
+}
+
+/*
+ ***************************************************************************
+ * Display pressure-stall I/O 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_psiio_stats(struct activity *a, int curr, unsigned long long itv,
+                                     struct record_header *record_hdr)
+{
+#ifdef HAVE_PCP
+       char buf[64];
+       struct stats_psi_io
+               *psic = (struct stats_psi_io *) a->buf[curr],
+               *psip = (struct stats_psi_io *) a->buf[!curr];
+
+       snprintf(buf, sizeof(buf), "%f", (double) psic->some_aio_10 / 100);
+       pmiPutValue("psi.io.some.trends", "10 sec", buf);
+
+       snprintf(buf, sizeof(buf), "%f", (double) psic->some_aio_60 / 100);
+       pmiPutValue("psi.io.some.trends", "60 sec", buf);
+
+       snprintf(buf, sizeof(buf), "%f", (double) psic->some_aio_300 / 100);
+       pmiPutValue("psi.io.some.trends", "300 sec", buf);
+
+       snprintf(buf, sizeof(buf), "%f",
+                S_VALUE(psip->some_io_total, psic->some_io_total, itv));
+       pmiPutValue("psi.io.some.total", NULL, buf);
+
+       snprintf(buf, sizeof(buf), "%f", (double) psic->full_aio_10 / 100);
+       pmiPutValue("psi.io.full.trends", "10 sec", buf);
+
+       snprintf(buf, sizeof(buf), "%f", (double) psic->full_aio_60 / 100);
+       pmiPutValue("psi.io.full.trends", "60 sec", buf);
+
+       snprintf(buf, sizeof(buf), "%f", (double) psic->full_aio_300 / 100);
+       pmiPutValue("psi.io.full.trends", "300 sec", buf);
+
+       snprintf(buf, sizeof(buf), "%f",
+                S_VALUE(psip->full_io_total, psic->full_io_total, itv));
+       pmiPutValue("psi.io.full.total", NULL, buf);
+#endif /* HAVE_PCP */
+}
+
+/*
+ ***************************************************************************
+ * Display pressure-stall memory 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_psimem_stats(struct activity *a, int curr, unsigned long long itv,
+                                      struct record_header *record_hdr)
+{
+#ifdef HAVE_PCP
+       char buf[64];
+       struct stats_psi_mem
+               *psic = (struct stats_psi_mem *) a->buf[curr],
+               *psip = (struct stats_psi_mem *) a->buf[!curr];
+
+       snprintf(buf, sizeof(buf), "%f", (double) psic->some_amem_10 / 100);
+       pmiPutValue("psi.mem.some.trends", "10 sec", buf);
+
+       snprintf(buf, sizeof(buf), "%f", (double) psic->some_amem_60 / 100);
+       pmiPutValue("psi.mem.some.trends", "60 sec", buf);
+
+       snprintf(buf, sizeof(buf), "%f", (double) psic->some_amem_300 / 100);
+       pmiPutValue("psi.mem.some.trends", "300 sec", buf);
+
+       snprintf(buf, sizeof(buf), "%f",
+                S_VALUE(psip->some_mem_total, psic->some_mem_total, itv));
+       pmiPutValue("psi.mem.some.total", NULL, buf);
+
+       snprintf(buf, sizeof(buf), "%f", (double) psic->full_amem_10 / 100);
+       pmiPutValue("psi.mem.full.trends", "10 sec", buf);
+
+       snprintf(buf, sizeof(buf), "%f", (double) psic->full_amem_60 / 100);
+       pmiPutValue("psi.mem.full.trends", "60 sec", buf);
+
+       snprintf(buf, sizeof(buf), "%f", (double) psic->full_amem_300 / 100);
+       pmiPutValue("psi.mem.full.trends", "300 sec", buf);
+
+       snprintf(buf, sizeof(buf), "%f",
+                S_VALUE(psip->full_mem_total, psic->full_mem_total, itv));
+       pmiPutValue("psi.mem.full.total", NULL, buf);
+#endif /* HAVE_PCP */
+}
index 8e21297e947ecf9d5653e69b83fa5f2f20908053..7a0536d361bae1621386d1f717aeb13ac75f26b0 100644 (file)
@@ -89,5 +89,11 @@ __print_funct_t pcp_print_fchost_stats
        (struct activity *, int, unsigned long long, struct record_header *);
 __print_funct_t pcp_print_softnet_stats
        (struct activity *, int, unsigned long long, struct record_header *);
+__print_funct_t pcp_print_psicpu_stats
+       (struct activity *, int, unsigned long long, struct record_header *);
+__print_funct_t pcp_print_psiio_stats
+       (struct activity *, int, unsigned long long, struct record_header *);
+__print_funct_t pcp_print_psimem_stats
+       (struct activity *, int, unsigned long long, struct record_header *);
 
 #endif /* _PCP_STATS_H */
index 00b99445b5c128218d0cce5a0ea3bcf2b6dbf75a..6c322ba90242667bc4b0bc5f84d3ef2758cd2332 100644 (file)
@@ -792,6 +792,12 @@ __printf_funct_t print_pcp_statistics(int *tab, int action, struct activity *act
                                case A_NET_FC:
                                        pcp_def_fchost_metrics(act[p]);
                                        break;
+
+                               case A_PSI_CPU:
+                               case A_PSI_IO:
+                               case A_PSI_MEM:
+                                       pcp_def_psi_metrics(act[p]);
+                                       break;
                        }
                }
        }