Add metrics displayed by "sar -W" (swapping statistics) to PCP archive.
Signed-off-by: Sebastien GODARD <sysstat@users.noreply.github.com>
.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",
#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.
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);
#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.
(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
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;