format_sar.o: format.c sa.h common.h rd_stats.h rd_sensors.h
$(CC) -o $@ -c $(CFLAGS) -DSOURCE_SAR $(DFLAGS) $<
-sadf_misc.o: sadf_misc.c sadf.h sa.h common.h rd_stats.h rd_sensors.h
+pcp_def_metrics.o: pcp_def_metrics.c
+
+sadf_misc.o: sadf_misc.c sadf.h pcp_def_metrics.h sa.h common.h rd_stats.h rd_sensors.h
sa_conv.o: sa_conv.c version.h sadf.h sa.h common.h rd_stats.h rd_sensors.h sa_conv.h
sadf: LFLAGS += $(LFPCP)
-sadf: sadf.o act_sadf.o format_sadf.o sadf_misc.o sa_conv.o rndr_stats.o xml_stats.o json_stats.o svg_stats.o raw_stats.o pcp_stats.o sa_common.o librdstats_light.a libsyscom.a
+sadf: sadf.o act_sadf.o format_sadf.o sadf_misc.o pcp_def_metrics.o sa_conv.o rndr_stats.o xml_stats.o json_stats.o svg_stats.o raw_stats.o pcp_stats.o sa_common.o librdstats_light.a libsyscom.a
iostat.o: iostat.c iostat.h version.h common.h ioconf.h sysconfig.h rd_stats.h count.h
--- /dev/null
+/*
+ * pcp_def_metrics.c: Funtions used by sadf to define PCP metrics
+ * (C) 2019 by Sebastien GODARD (sysstat <at> orange.fr)
+ *
+ ***************************************************************************
+ * This program is free software; you can redistribute it and/or modify it *
+ * under the terms of the GNU General Public License as published by the *
+ * Free Software Foundation; either version 2 of the License, or (at your *
+ * option) any later version. *
+ * *
+ * This program is distributed in the hope that it will be useful, but *
+ * WITHOUT ANY WARRANTY; without the implied warranty of MERCHANTABILITY *
+ * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License *
+ * for more details. *
+ * *
+ * You should have received a copy of the GNU General Public License along *
+ * with this program; if not, write to the Free Software Foundation, Inc., *
+ * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1335 USA *
+ ***************************************************************************
+ */
+
+#include "common.h"
+#include "sa.h"
+
+#ifdef HAVE_PCP
+#include <pcp/pmapi.h>
+#include <pcp/import.h>
+#endif
+
+/*
+ ***************************************************************************
+ * Define PCP metrics for CPU statistics.
+ *
+ * IN:
+ * @a Activity structure with statistics.
+ ***************************************************************************
+ */
+void pcp_def_cpu_metrics(struct activity *a)
+{
+#ifdef HAVE_PCP
+ int i, first = TRUE;
+ char buf[64];
+ pmInDom indom;
+
+ for (i = 0; (i < a->nr_ini) && (i < a->bitmap->b_size + 1); i++) {
+
+ /*
+ * Should current CPU (including CPU "all") be displayed?
+ * NB: Offline not tested (they may be turned off and on within
+ * the same file.
+ */
+ if (!(a->bitmap->b_array[i >> 3] & (1 << (i & 0x07))))
+ /* CPU not selected */
+ continue;
+
+ if (!i) {
+ /* This is CPU "all" */
+ pmiAddMetric("kernel.all.cpu.user",
+ PM_IN_NULL, PM_TYPE_FLOAT, PM_INDOM_NULL, PM_SEM_INSTANT,
+ pmiUnits(0, 0, 0, 0, 0, 0));
+
+ pmiAddMetric("kernel.all.cpu.nice",
+ PM_IN_NULL, PM_TYPE_FLOAT, PM_INDOM_NULL, PM_SEM_INSTANT,
+ pmiUnits(0, 0, 0, 0, 0, 0));
+
+ pmiAddMetric("kernel.all.cpu.sys",
+ PM_IN_NULL, PM_TYPE_FLOAT, PM_INDOM_NULL, PM_SEM_INSTANT,
+ pmiUnits(0, 0, 0, 0, 0, 0));
+
+ pmiAddMetric("kernel.all.cpu.idle",
+ PM_IN_NULL, PM_TYPE_FLOAT, PM_INDOM_NULL, PM_SEM_INSTANT,
+ pmiUnits(0, 0, 0, 0, 0, 0));
+
+ pmiAddMetric("kernel.all.cpu.iowait",
+ PM_IN_NULL, PM_TYPE_FLOAT, PM_INDOM_NULL, PM_SEM_INSTANT,
+ pmiUnits(0, 0, 0, 0, 0, 0));
+
+ pmiAddMetric("kernel.all.cpu.steal",
+ PM_IN_NULL, PM_TYPE_FLOAT, PM_INDOM_NULL, PM_SEM_INSTANT,
+ pmiUnits(0, 0, 0, 0, 0, 0));
+
+ pmiAddMetric("kernel.all.cpu.hardirq",
+ PM_IN_NULL, PM_TYPE_FLOAT, PM_INDOM_NULL, PM_SEM_INSTANT,
+ pmiUnits(0, 0, 0, 0, 0, 0));
+
+ pmiAddMetric("kernel.all.cpu.softirq",
+ PM_IN_NULL, PM_TYPE_FLOAT, PM_INDOM_NULL, PM_SEM_INSTANT,
+ pmiUnits(0, 0, 0, 0, 0, 0));
+
+ pmiAddMetric("kernel.all.cpu.guest",
+ PM_IN_NULL, PM_TYPE_FLOAT, PM_INDOM_NULL, PM_SEM_INSTANT,
+ pmiUnits(0, 0, 0, 0, 0, 0));
+
+ pmiAddMetric("kernel.all.cpu.guest_nice",
+ PM_IN_NULL, PM_TYPE_FLOAT, PM_INDOM_NULL, PM_SEM_INSTANT,
+ pmiUnits(0, 0, 0, 0, 0, 0));
+ }
+ else {
+ if (first) {
+ first = FALSE;
+
+ indom = pmInDom_build(0, 0);
+ pmiAddMetric("kernel.percpu.cpu.user",
+ PM_IN_NULL, PM_TYPE_FLOAT, indom, PM_SEM_INSTANT,
+ pmiUnits(0, 0, 0, 0, 0, 0));
+
+ pmiAddMetric("kernel.percpu.cpu.nice",
+ PM_IN_NULL, PM_TYPE_FLOAT, indom, PM_SEM_INSTANT,
+ pmiUnits(0, 0, 0, 0, 0, 0));
+
+ pmiAddMetric("kernel.percpu.cpu.sys",
+ PM_IN_NULL, PM_TYPE_FLOAT, indom, PM_SEM_INSTANT,
+ pmiUnits(0, 0, 0, 0, 0, 0));
+
+ pmiAddMetric("kernel.percpu.cpu.idle",
+ PM_IN_NULL, PM_TYPE_FLOAT, indom, PM_SEM_INSTANT,
+ pmiUnits(0, 0, 0, 0, 0, 0));
+
+ pmiAddMetric("kernel.percpu.cpu.iowait",
+ PM_IN_NULL, PM_TYPE_FLOAT, indom, PM_SEM_INSTANT,
+ pmiUnits(0, 0, 0, 0, 0, 0));
+
+ pmiAddMetric("kernel.percpu.cpu.steal",
+ PM_IN_NULL, PM_TYPE_FLOAT, indom, PM_SEM_INSTANT,
+ pmiUnits(0, 0, 0, 0, 0, 0));
+
+ pmiAddMetric("kernel.percpu.cpu.hardirq",
+ PM_IN_NULL, PM_TYPE_FLOAT, indom, PM_SEM_INSTANT,
+ pmiUnits(0, 0, 0, 0, 0, 0));
+
+ pmiAddMetric("kernel.percpu.cpu.softirq",
+ PM_IN_NULL, PM_TYPE_FLOAT, indom, PM_SEM_INSTANT,
+ pmiUnits(0, 0, 0, 0, 0, 0));
+
+ pmiAddMetric("kernel.percpu.cpu.guest",
+ PM_IN_NULL, PM_TYPE_FLOAT, indom, PM_SEM_INSTANT,
+ pmiUnits(0, 0, 0, 0, 0, 0));
+
+ pmiAddMetric("kernel.percpu.cpu.guest_nice",
+ PM_IN_NULL, PM_TYPE_FLOAT, indom, PM_SEM_INSTANT,
+ pmiUnits(0, 0, 0, 0, 0, 0));
+ }
+ sprintf(buf, "cpu%d", i - 1);
+ pmiAddInstance(indom, buf, i - 1);
+ }
+ }
+#endif /* HAVE_PCP */
+}
+
+/*
+ ***************************************************************************
+ * Define PCP metrics for queue and load statistics.
+ ***************************************************************************
+ */
+void pcp_def_pcsw_metrics(void)
+{
+#ifdef HAVE_PCP
+ pmiAddMetric("kernel.all.pswitch",
+ PM_IN_NULL, PM_TYPE_FLOAT, PM_INDOM_NULL, PM_SEM_INSTANT,
+ pmiUnits(0, -1, 1, 0, PM_TIME_SEC, PM_COUNT_ONE));
+
+ pmiAddMetric("kernel.all.proc",
+ 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 queue and load statistics.
+ ***************************************************************************
+ */
+void pcp_def_queue_metrics(void)
+{
+#ifdef HAVE_PCP
+ pmInDom indom;
+ pmiAddMetric("proc.runq.runnable",
+ PM_IN_NULL, PM_TYPE_U64, PM_INDOM_NULL, PM_SEM_INSTANT,
+ pmiUnits(0, 0, 1, 0, 0, PM_COUNT_ONE));
+
+ pmiAddMetric("proc.nprocs",
+ PM_IN_NULL, PM_TYPE_U64, PM_INDOM_NULL, PM_SEM_INSTANT,
+ pmiUnits(0, 0, 1, 0, 0, PM_COUNT_ONE));
+
+ pmiAddMetric("proc.blocked",
+ PM_IN_NULL, PM_TYPE_U64, PM_INDOM_NULL, PM_SEM_INSTANT,
+ pmiUnits(0, 0, 1, 0, 0, PM_COUNT_ONE));
+
+ indom = pmInDom_build(0, 1);
+ pmiAddMetric("kernel.all.load",
+ PM_IN_NULL, PM_TYPE_FLOAT, indom, PM_SEM_INSTANT,
+ pmiUnits(0, 0, 0, 0, 0, 0));
+ pmiAddInstance(indom, "1 min", 0);
+ pmiAddInstance(indom, "5 min", 1);
+ pmiAddInstance(indom, "15 min", 2);
+#endif /* HAVE_PCP */
+}
+
--- /dev/null
+/*
+ * pcp_def_metrics.h: Include file used to define PCP metrics.
+ * (C) 2019 by Sebastien Godard (sysstat <at> orange.fr)
+ */
+
+#ifndef _PCP_DEF_METRICS_H
+#define _PCP_DEF_METRICS_H
+
+/*
+ ***************************************************************************
+ * Prototypes for functions used to define PCP metrics.
+ ***************************************************************************
+ */
+
+void pcp_def_cpu_metrics(struct activity *);
+void pcp_def_pcsw_metrics(void);
+void pcp_def_queue_metrics(void);
+
+#endif /* _PCP_DEF_METRICS_H */
#include <string.h>
#include "sadf.h"
+#include "pcp_def_metrics.h"
#ifdef USE_NLS
#include <locale.h>
unsigned int id_seq[])
{
#ifdef HAVE_PCP
- int i, n, p;
- int first = TRUE;
- char buf[64];
- pmInDom indom;
+ int i, p;
if (action & F_BEGIN) {
- for (n = 0; n < NR_ACT; n++) {
- if (!id_seq[n])
+ for (i = 0; i < NR_ACT; i++) {
+ if (!id_seq[i])
continue; /* Activity not in file */
- p = get_activity_position(act, id_seq[n], EXIT_IF_NOT_FOUND);
+ p = get_activity_position(act, id_seq[i], EXIT_IF_NOT_FOUND);
if (!IS_SELECTED(act[p]->options))
continue; /* Activity not selected */
switch (act[p]->id) {
case A_CPU:
- for (i = 0; (i < act[p]->nr_ini) && (i < act[p]->bitmap->b_size + 1); i++) {
-
- /*
- * Should current CPU (including CPU "all") be displayed?
- * NB: Offline not tested (they may be turned off and on within
- * the same file.
- */
- if (!(act[p]->bitmap->b_array[i >> 3] & (1 << (i & 0x07))))
- /* CPU not selected */
- continue;
-
- if (!i) {
- /* This is CPU "all" */
- pmiAddMetric("kernel.all.cpu.user",
- PM_IN_NULL, PM_TYPE_FLOAT, PM_INDOM_NULL, PM_SEM_INSTANT,
- pmiUnits(0, 0, 0, 0, 0, 0));
- pmiAddMetric("kernel.all.cpu.nice",
- PM_IN_NULL, PM_TYPE_FLOAT, PM_INDOM_NULL, PM_SEM_INSTANT,
- pmiUnits(0, 0, 0, 0, 0, 0));
- pmiAddMetric("kernel.all.cpu.sys",
- PM_IN_NULL, PM_TYPE_FLOAT, PM_INDOM_NULL, PM_SEM_INSTANT,
- pmiUnits(0, 0, 0, 0, 0, 0));
- pmiAddMetric("kernel.all.cpu.idle",
- PM_IN_NULL, PM_TYPE_FLOAT, PM_INDOM_NULL, PM_SEM_INSTANT,
- pmiUnits(0, 0, 0, 0, 0, 0));
- pmiAddMetric("kernel.all.cpu.iowait",
- PM_IN_NULL, PM_TYPE_FLOAT, PM_INDOM_NULL, PM_SEM_INSTANT,
- pmiUnits(0, 0, 0, 0, 0, 0));
- pmiAddMetric("kernel.all.cpu.steal",
- PM_IN_NULL, PM_TYPE_FLOAT, PM_INDOM_NULL, PM_SEM_INSTANT,
- pmiUnits(0, 0, 0, 0, 0, 0));
- pmiAddMetric("kernel.all.cpu.hardirq",
- PM_IN_NULL, PM_TYPE_FLOAT, PM_INDOM_NULL, PM_SEM_INSTANT,
- pmiUnits(0, 0, 0, 0, 0, 0));
- pmiAddMetric("kernel.all.cpu.softirq",
- PM_IN_NULL, PM_TYPE_FLOAT, PM_INDOM_NULL, PM_SEM_INSTANT,
- pmiUnits(0, 0, 0, 0, 0, 0));
- pmiAddMetric("kernel.all.cpu.guest",
- PM_IN_NULL, PM_TYPE_FLOAT, PM_INDOM_NULL, PM_SEM_INSTANT,
- pmiUnits(0, 0, 0, 0, 0, 0));
- pmiAddMetric("kernel.all.cpu.guest_nice",
- PM_IN_NULL, PM_TYPE_FLOAT, PM_INDOM_NULL, PM_SEM_INSTANT,
- pmiUnits(0, 0, 0, 0, 0, 0));
- }
- else {
- if (first) {
- first = FALSE;
- indom = pmInDom_build(0, 0);
- pmiAddMetric("kernel.percpu.cpu.user",
- PM_IN_NULL, PM_TYPE_FLOAT, indom, PM_SEM_INSTANT,
- pmiUnits(0, 0, 0, 0, 0, 0));
- pmiAddMetric("kernel.percpu.cpu.nice",
- PM_IN_NULL, PM_TYPE_FLOAT, indom, PM_SEM_INSTANT,
- pmiUnits(0, 0, 0, 0, 0, 0));
- pmiAddMetric("kernel.percpu.cpu.sys",
- PM_IN_NULL, PM_TYPE_FLOAT, indom, PM_SEM_INSTANT,
- pmiUnits(0, 0, 0, 0, 0, 0));
- pmiAddMetric("kernel.percpu.cpu.idle",
- PM_IN_NULL, PM_TYPE_FLOAT, indom, PM_SEM_INSTANT,
- pmiUnits(0, 0, 0, 0, 0, 0));
- pmiAddMetric("kernel.percpu.cpu.iowait",
- PM_IN_NULL, PM_TYPE_FLOAT, indom, PM_SEM_INSTANT,
- pmiUnits(0, 0, 0, 0, 0, 0));
- pmiAddMetric("kernel.percpu.cpu.steal",
- PM_IN_NULL, PM_TYPE_FLOAT, indom, PM_SEM_INSTANT,
- pmiUnits(0, 0, 0, 0, 0, 0));
- pmiAddMetric("kernel.percpu.cpu.hardirq",
- PM_IN_NULL, PM_TYPE_FLOAT, indom, PM_SEM_INSTANT,
- pmiUnits(0, 0, 0, 0, 0, 0));
- pmiAddMetric("kernel.percpu.cpu.softirq",
- PM_IN_NULL, PM_TYPE_FLOAT, indom, PM_SEM_INSTANT,
- pmiUnits(0, 0, 0, 0, 0, 0));
- pmiAddMetric("kernel.percpu.cpu.guest",
- PM_IN_NULL, PM_TYPE_FLOAT, indom, PM_SEM_INSTANT,
- pmiUnits(0, 0, 0, 0, 0, 0));
- pmiAddMetric("kernel.percpu.cpu.guest_nice",
- PM_IN_NULL, PM_TYPE_FLOAT, indom, PM_SEM_INSTANT,
- pmiUnits(0, 0, 0, 0, 0, 0));
- }
- sprintf(buf, "cpu%d", i - 1);
- pmiAddInstance(indom, buf, i - 1);
- }
- }
+ pcp_def_cpu_metrics(act[p]);
break;
case A_PCSW:
- pmiAddMetric("kernel.all.pswitch",
- PM_IN_NULL, PM_TYPE_FLOAT, PM_INDOM_NULL, PM_SEM_INSTANT,
- pmiUnits(0, -1, 1, 0, PM_TIME_SEC, PM_COUNT_ONE));
- pmiAddMetric("kernel.all.proc",
- PM_IN_NULL, PM_TYPE_FLOAT, PM_INDOM_NULL, PM_SEM_INSTANT,
- pmiUnits(0, -1, 1, 0, PM_TIME_SEC, PM_COUNT_ONE));
+ pcp_def_pcsw_metrics();
break;
case A_QUEUE:
- pmiAddMetric("proc.runq.runnable",
- PM_IN_NULL, PM_TYPE_U64, PM_INDOM_NULL, PM_SEM_INSTANT,
- pmiUnits(0, 0, 1, 0, 0, PM_COUNT_ONE));
- pmiAddMetric("proc.nprocs",
- PM_IN_NULL, PM_TYPE_U64, PM_INDOM_NULL, PM_SEM_INSTANT,
- pmiUnits(0, 0, 1, 0, 0, PM_COUNT_ONE));
- pmiAddMetric("proc.blocked",
- PM_IN_NULL, PM_TYPE_U64, PM_INDOM_NULL, PM_SEM_INSTANT,
- pmiUnits(0, 0, 1, 0, 0, PM_COUNT_ONE));
- indom = pmInDom_build(0, 1);
- pmiAddMetric("kernel.all.load",
- PM_IN_NULL, PM_TYPE_FLOAT, indom, PM_SEM_INSTANT,
- pmiUnits(0, 0, 0, 0, 0, 0));
- pmiAddInstance(indom, "1 min", 0);
- pmiAddInstance(indom, "5 min", 1);
- pmiAddInstance(indom, "15 min", 2);
+ pcp_def_queue_metrics();
break;
}
}