.f_json_print = json_print_pwr_bat_stats,
.f_svg_print = svg_print_pwr_bat_stats,
.f_raw_print = raw_print_pwr_bat_stats,
- .f_pcp_print = NULL, // FIXME
+ .f_pcp_print = pcp_print_pwr_bat_stats,
.f_count_new = count_new_bat,
.item_list = NULL,
.desc = "Batteries capacity",
#endif /* HAVE_PCP */
}
+/*
+ * **************************************************************************
+ * Define PCP metrics for battery statistics.
+ *
+ * IN:
+ * @a Activity structure with statistics.
+ ***************************************************************************
+ */
+void pcp_def_pwr_bat_metrics(struct activity *a)
+{
+#ifdef HAVE_PCP
+ int inst = 0;
+ static pmInDom indom = PM_INDOM_NULL;
+ struct sa_item *list = a->item_list;
+
+ if (indom == PM_INDOM_NULL) {
+ /* Create domain */
+ indom = pmInDom_build(34, 4);
+
+ /* Create instances */
+ while (list != NULL) {
+ pmiAddInstance(indom, list->item_name, inst++);
+ list = list->next;
+ }
+ }
+
+ pmiAddMetric("power.bat.capacity",
+ pmiID(34, 4, 0), PM_TYPE_U32, indom, PM_SEM_INSTANT,
+ pmiUnits(0, 0, 0, 0, 0, 0));
+
+ pmiAddMetric("power.bat.status",
+ pmiID(34, 4, 2), PM_TYPE_STRING, indom, PM_SEM_DISCRETE,
+ pmiUnits(0, 0, 0, 0, 0, 0));
+#endif /* HAVE_PCP */
+}
+
/*
***************************************************************************
* Define PCP metrics for USB devices statistics.
void pcp_def_pwr_fan_metrics(struct activity *);
void pcp_def_pwr_temp_metrics(struct activity *);
void pcp_def_pwr_in_metrics(struct activity *);
+void pcp_def_pwr_bat_metrics(struct activity *);
void pcp_def_pwr_usb_metrics(struct activity *);
void pcp_def_filesystem_metrics(struct activity *);
void pcp_def_fchost_metrics(struct activity *);
#endif
extern uint64_t flags;
+extern char bat_status[][16];
#ifdef HAVE_PCP
#include <pcp/pmapi.h>
#endif /* HAVE_PCP */
}
+/*
+ * **************************************************************************
+ * Display batteries statistics in PCP format.
+ *
+ * IN:
+ * @a Activity structure with statistics.
+ * @curr Index in array for current sample statistics.
+ ***************************************************************************
+ */
+__print_funct_t pcp_print_pwr_bat_stats(struct activity *a, int curr)
+{
+#ifdef HAVE_PCP
+ int i;
+ struct stats_pwr_bat *spbc;
+ char buf[64], bat_name[16];
+
+ for (i = 0; i < a->nr[curr]; i++) {
+
+ spbc = (struct stats_pwr_bat *) ((char *) a->buf[curr] + i * a->msize);
+
+ snprintf(bat_name, sizeof(bat_name), "BAT%d", (int) spbc->bat_id);
+
+ snprintf(buf, sizeof(buf), "%u", (unsigned int) spbc->capacity);
+ pmiPutValue("power.bat.capacity", bat_name, buf);
+
+ /* Battery status code should not be greater than or equal to BAT_STS_NR */
+ if (spbc->status >= BAT_STS_NR) {
+ spbc->status = 0;
+ }
+
+ snprintf(buf, sizeof(buf), "%s", bat_status[(unsigned int) spbc->status]);
+ pmiPutValue("power.bat.status", bat_name, buf);
+ }
+#endif /* HAVE_PCP */
+}
+
/*
***************************************************************************
* Display huge pages statistics in PCP format.
(struct activity *, int);
__print_funct_t pcp_print_pwr_in_stats
(struct activity *, int);
+__print_funct_t pcp_print_pwr_bat_stats
+ (struct activity *, int);
__print_funct_t pcp_print_huge_stats
(struct activity *, int);
__print_funct_t pcp_print_pwr_usb_stats
pcp_def_pwr_in_metrics(act[p]);
break;
+ case A_PWR_BAT:
+ pcp_def_pwr_bat_metrics(act[p]);
+ break;
+
case A_PWR_USB:
pcp_def_pwr_usb_metrics(act[p]);
break;