]> granicus.if.org Git - sysstat/commitdiff
sadf: PCP: Add support for A_SWAP activity
authorSebastien GODARD <sysstat@users.noreply.github.com>
Wed, 20 Mar 2019 10:28:10 +0000 (11:28 +0100)
committerSebastien GODARD <sysstat@users.noreply.github.com>
Wed, 20 Mar 2019 10:28:10 +0000 (11:28 +0100)
Add metrics displayed by "sar -W" (swapping 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 3a7a9b00ee3c8107d34b456f5538aded888e334a..c992a4eb43d8bfcb0bdd43eaae5b2f38784306a9 100644 (file)
@@ -231,6 +231,7 @@ struct activity swap_act = {
        .f_json_print   = json_print_swap_stats,
        .f_svg_print    = svg_print_swap_stats,
        .f_raw_print    = raw_print_swap_stats,
+       .f_pcp_print    = pcp_print_swap_stats,
        .f_count_new    = NULL,
        .item_list      = NULL,
        .desc           = "Swap activity",
index 83b2e9c50d6d28803cdfe4cdfdb15579a40c930f..24d22522613088f64f24ecbacc97244dbb08328c 100644 (file)
@@ -185,6 +185,24 @@ void pcp_def_irq_metrics(struct activity *a)
 #endif /* HAVE_PCP */
 }
 
+/*
+ ***************************************************************************
+ * Define PCP metrics for swapping statistics.
+ ***************************************************************************
+ */
+void pcp_def_swap_metrics(void)
+{
+#ifdef HAVE_PCP
+       pmiAddMetric("swap.pagesin",
+                    PM_IN_NULL, PM_TYPE_FLOAT, PM_INDOM_NULL, PM_SEM_INSTANT,
+                    pmiUnits(0, -1, 1, 0, PM_TIME_SEC, PM_COUNT_ONE));
+
+       pmiAddMetric("swap.pagesout",
+                    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 memory statistics.
index a67993d6abe196f0b4175227134e76c388feddaf..040b3af6665414f67059cd5dca90e0b6a9fc4467 100644 (file)
@@ -15,6 +15,7 @@
 void pcp_def_cpu_metrics(struct activity *);
 void pcp_def_pcsw_metrics(void);
 void pcp_def_irq_metrics(struct activity *);
+void pcp_def_swap_metrics(void);
 void pcp_def_memory_metrics(struct activity *);
 void pcp_def_queue_metrics(void);
 
index 8cac0669409215edee86a95dad939ab0b38efd11..d71602b2aa78752ee5f235c99b78f5a04bfd704d 100644 (file)
@@ -237,6 +237,36 @@ __print_funct_t pcp_print_irq_stats(struct activity *a, int curr, unsigned long
 #endif /* HAVE_PCP */
 }
 
+/*
+ ***************************************************************************
+ * Display swapping 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_swap_stats(struct activity *a, int curr, unsigned long long itv,
+                                    struct record_header *record_hdr)
+{
+#ifdef HAVE_PCP
+       char buf[64];
+       struct stats_swap
+               *ssc = (struct stats_swap *) a->buf[curr],
+               *ssp = (struct stats_swap *) a->buf[!curr];
+
+       snprintf(buf, sizeof(buf), "%f",
+                S_VALUE(ssp->pswpin, ssc->pswpin, itv));
+       pmiPutValue("swap.pagesin", NULL, buf);
+
+       snprintf(buf, sizeof(buf), "%f",
+                S_VALUE(ssp->pswpout, ssc->pswpout, itv));
+       pmiPutValue("swap.pagesout", NULL, buf);
+#endif /* HAVE_PCP */
+}
+
 /*
  ***************************************************************************
  * Display memory statistics in PCP format.
index 0ab592faa15ce2d99cd5047dea6b80b8352f5fcc..36f36790f9de29a6bd4b213eaf284fe6744bcbd0 100644 (file)
@@ -19,6 +19,8 @@ __print_funct_t pcp_print_pcsw_stats
        (struct activity *, int, unsigned long long, struct record_header *);
 __print_funct_t pcp_print_irq_stats
        (struct activity *, int, unsigned long long, struct record_header *);
+__print_funct_t pcp_print_swap_stats
+       (struct activity *, int, unsigned long long, struct record_header *);
 __print_funct_t pcp_print_memory_stats
        (struct activity *, int, unsigned long long, struct record_header *);
 __print_funct_t pcp_print_queue_stats
index b0e60c7514afa8f10a51ac89c25168bb8a54dcef..a0c31761095f7288b1e8dcb6ec0c1676014ed8f6 100644 (file)
@@ -509,6 +509,10 @@ __printf_funct_t print_pcp_statistics(int *tab, int action, struct activity *act
                                        pcp_def_irq_metrics(act[p]);
                                        break;
 
+                               case A_SWAP:
+                                       pcp_def_swap_metrics();
+                                       break;
+
                                case A_MEMORY:
                                        pcp_def_memory_metrics(act[p]);
                                        break;