* @indom PCP domain for interrupts metrics.
***************************************************************************
*/
-void pcp_def_percpu_int_metrics(struct activity *a, pmInDom indom)
+void pcp_def_percpu_int_metrics(struct activity *a, int cpu)
{
- int inst = 1;
- char name[64];
+#ifdef HAVE_PCP
+ char buf[64];
struct sa_item *list = a->item_list;
+ static pmInDom indom = PM_INDOM_NULL;
+ static int inst;
- /* Create per-CPU metrics for A_IRQ */
- while (list != NULL) {
- snprintf(name, sizeof(name), "kernel.percpu.interrupts.%s", list->item_name);
- name[sizeof(name) - 1] = '\0';
-
- /* Metric name cannot contain digits :-( Translate them to characters instead */
- replace_digits(name);
+ if (indom == PM_INDOM_NULL) {
+ /* Create domain */
+ indom = pmInDom_build(60, 40);
- pmiAddMetric(name,
- pmiID(60, 4, inst++), PM_TYPE_U64, indom, PM_SEM_COUNTER,
+ /* Create metric */
+ pmiAddMetric("kernel.percpu.interrupts",
+ pmiID(60, 4, 1), PM_TYPE_U32, indom, PM_SEM_COUNTER,
pmiUnits(0, 0, 1, 0, 0, PM_COUNT_ONE));
+ }
+
+ /* Create instance for each interrupt for the current CPU */
+ while (list != NULL) {
+ snprintf(buf, sizeof(buf), "%s::cpu%d", list->item_name, cpu);
+ buf[sizeof(buf) - 1] = '\0';
+
+ pmiAddInstance(indom, buf, inst++);
list = list->next;
}
+#endif /* HAVE_PCP */
}
/*
else if (a->id == A_IRQ) {
/* Create per-CPU interrupts metrics */
- pcp_def_percpu_int_metrics(a, indom);
+ pcp_def_percpu_int_metrics(a, i - 1);
}
first = FALSE;
}
{
#ifdef HAVE_PCP
int i, c;
- char buf[64], cpuno[64], name[64];
+ char buf[64], name[64];
struct stats_irq *stc_cpu_irq, *stc_cpuall_irq;
unsigned char masked_cpu_bitmap[BITMAP_SIZE(NR_CPUS)] = {0};
}
else {
/* This is a particular CPU */
- sprintf(cpuno, "cpu%d", c - 1);
-
- snprintf(name, sizeof(name), "kernel.percpu.interrupts.%s",
- stc_cpuall_irq->irq_name);
+ snprintf(name, sizeof(name), "%s::cpu%d",
+ stc_cpuall_irq->irq_name, c - 1);
name[sizeof(name) - 1] = '\0';
- /* Metric name cannot contain digits */
- replace_digits(name);
-
- pmiPutValue(name, cpuno, buf);
+ pmiPutValue("kernel.percpu.interrupts", name, buf);
}
}
}
}
}
}
-
-/*
- ***************************************************************************
- * Replace digits in a string with letters ('0' -> 'a', etc.
- ***************************************************************************
- */
-void replace_digits(char name[])
-{
- int i;
-
- for (i = 0; i < strlen(name); i++) {
- if ((name[i] >= '0') && (name[i] <= '9')) {
- name[i] += 'a' - '0';
- }
- }
-}