]> granicus.if.org Git - sysstat/commitdiff
sadf: PCP: Add all interrupts statistics to PCP archive
authorSebastien GODARD <sysstat@users.noreply.github.com>
Sat, 6 Apr 2019 07:58:04 +0000 (09:58 +0200)
committerSebastien GODARD <sysstat@users.noreply.github.com>
Sat, 6 Apr 2019 07:58:04 +0000 (09:58 +0200)
Signed-off-by: Sebastien GODARD <sysstat@users.noreply.github.com>
pcp_def_metrics.c
pcp_def_metrics.h
pcp_stats.c

index 0b6f7822ee3a987664add2a9995e6aca8c517bf1..3959f3750f09194d477d2ae9e9852c688e65fcf9 100644 (file)
@@ -177,11 +177,34 @@ void pcp_def_pcsw_metrics(void)
 void pcp_def_irq_metrics(struct activity *a)
 {
 #ifdef HAVE_PCP
-       if (a->bitmap->b_array[0] & 1) {
-               /* Interrupt "sum" */
-               pmiAddMetric("kernel.all.intr",
-                            PM_IN_NULL, PM_TYPE_FLOAT, PM_INDOM_NULL, PM_SEM_INSTANT,
-                            pmiUnits(0, -1, 1, 0, PM_TIME_SEC, PM_COUNT_ONE));
+       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 interrupt (including int "sum") be displayed? */
+               if (a->bitmap->b_array[i >> 3] & (1 << (i & 0x07))) {
+
+                       if (!i) {
+                               /* Interrupt "sum" */
+                               pmiAddMetric("kernel.all.intr",
+                                            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 (first) {
+                                       indom = pmInDom_build(0, PM_INDOM_INT);
+
+                                       pmiAddMetric("kernel.all.int.count",
+                                                    PM_IN_NULL, PM_TYPE_FLOAT, indom, PM_SEM_INSTANT,
+                                                    pmiUnits(0, -1, 1, 0, PM_TIME_SEC, PM_COUNT_ONE));
+                                       first = FALSE;
+                               }
+                               sprintf(buf, "int%d", i - 1);
+                               pmiAddInstance(indom, buf, i - 1);
+                       }
+               }
        }
 #endif /* HAVE_PCP */
 }
index 853317ca915b0b7154b4f588d0d25cc131c01733..21e3a99fdae57f0e95ae3e52254ff389dfdbc4ff 100644 (file)
@@ -45,6 +45,7 @@ void pcp_def_net_udp6_metrics(void);
 #define PM_INDOM_QUEUE         1
 #define PM_INDOM_NET_DEV       2
 #define PM_INDOM_SERIAL                3
+#define PM_INDOM_INT           4
 
 
 #endif /* _PCP_DEF_METRICS_H */
index caf1f5d924c8b43ba0131383b90fe56ea0fbf07e..653a041a47ddf46ae51eb78336f7a27192ae3637 100644 (file)
@@ -226,14 +226,32 @@ __print_funct_t pcp_print_irq_stats(struct activity *a, int curr, unsigned long
                                    struct record_header *record_hdr)
 {
 #ifdef HAVE_PCP
-       char buf[64];
-       struct stats_irq
-               *sic = (struct stats_irq *) a->buf[curr],
-               *sip = (struct stats_irq *) a->buf[!curr];
+       char buf[64], intno[64];
+       int i;
+       struct stats_irq *sic, *sip;
 
-       snprintf(buf, sizeof(buf), "%f",
-                S_VALUE(sip->irq_nr, sic->irq_nr, itv));
-       pmiPutValue("kernel.all.intr", NULL, buf);
+       for (i = 0; (i < a->nr[curr]) && (i < a->bitmap->b_size + 1); i++) {
+
+               sic = (struct stats_irq *) ((char *) a->buf[curr]  + i * a->msize);
+               sip = (struct stats_irq *) ((char *) a->buf[!curr] + i * a->msize);
+
+               /* Should current interrupt (including int "sum") be displayed? */
+               if (a->bitmap->b_array[i >> 3] & (1 << (i & 0x07))) {
+
+                       if (!i) {
+                               /* This is interrupt "sum" */
+                               snprintf(buf, sizeof(buf), "%f",
+                                        S_VALUE(sip->irq_nr, sic->irq_nr, itv));
+                               pmiPutValue("kernel.all.intr", NULL, buf);
+                       }
+                       else {
+                               sprintf(intno, "int%d", i - 1);
+                               snprintf(buf, sizeof(buf), "%f",
+                                        S_VALUE(sip->irq_nr, sic->irq_nr, itv));
+                               pmiPutValue("kernel.all.int.count", intno, buf);
+                       }
+               }
+       }
 #endif /* HAVE_PCP */
 }