From: Sebastien GODARD Date: Sat, 6 Apr 2019 07:58:04 +0000 (+0200) Subject: sadf: PCP: Add all interrupts statistics to PCP archive X-Git-Tag: v12.1.4~15 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=8cfeb323a1330461693d11979880939202ab8d16;p=sysstat sadf: PCP: Add all interrupts statistics to PCP archive Signed-off-by: Sebastien GODARD --- diff --git a/pcp_def_metrics.c b/pcp_def_metrics.c index 0b6f782..3959f37 100644 --- a/pcp_def_metrics.c +++ b/pcp_def_metrics.c @@ -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 */ } diff --git a/pcp_def_metrics.h b/pcp_def_metrics.h index 853317c..21e3a99 100644 --- a/pcp_def_metrics.h +++ b/pcp_def_metrics.h @@ -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 */ diff --git a/pcp_stats.c b/pcp_stats.c index caf1f5d..653a041 100644 --- a/pcp_stats.c +++ b/pcp_stats.c @@ -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 */ }