*
* Copyright(c) 2016 Intel Corporation. All rights reserved.
*
- * Permission is hereby granted, free of charge, to any person obtaining a copy of
- * this software and associated documentation files (the "Software"), to deal in
- * the Software without restriction, including without limitation the rights to
- * use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies
- * of the Software, and to permit persons to whom the Software is furnished to do
- * so, subject to the following conditions:
+ * Permission is hereby granted, free of charge, to any person obtaining a copy
+ * of this software and associated documentation files (the "Software"), to deal
+ * in the Software without restriction, including without limitation the rights
+ * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+ * copies of the Software, and to permit persons to whom the Software is
+ * furnished to do so, subject to the following conditions:
*
- * The above copyright notice and this permission notice shall be included in all
- * copies or substantial portions of the Software.
+ * The above copyright notice and this permission notice shall be included in
+ * all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* Serhiy Pshyk <serhiyx.pshyk@intel.com>
**/
-#include <pqos.h>
-
#include "common.h"
+#include "collectd.h"
+
+#include <pqos.h>
#define RDT_PLUGIN "intel_rdt"
uint64_t cores[RDT_MAX_CORES] = {0};
char value[DATA_MAX_NAME_LEN];
- if ((item->values[j].value.string == NULL) || (strlen(item->values[j].value.string) == 0))
+ if ((item->values[j].value.string == NULL) ||
+ (strlen(item->values[j].value.string) == 0))
continue;
sstrncpy(value, item->values[j].value.string, sizeof(value));
DEBUG(RDT_PLUGIN ": Core groups [%d]:", item->values_num);
for (int j = 0; j < item->values_num; j++) {
if (item->values[j].type != OCONFIG_TYPE_STRING) {
- ERROR(RDT_PLUGIN ": given core group value is not a string [idx=%d]",
- j);
+ ERROR(RDT_PLUGIN ": given core group value is not a string [idx=%d]", j);
return (-EINVAL);
}
DEBUG(RDT_PLUGIN ": [%d]: %s", j, item->values[j].value.string);
}
n = oconfig_to_cgroups(item, g_rdt->cgroups, RDT_MAX_CORES,
- g_rdt->pqos_cpu->num_cores-1);
+ g_rdt->pqos_cpu->num_cores - 1);
if (n < 0) {
rdt_free_cgroups();
ERROR(RDT_PLUGIN ": Error parsing core groups configuration.");
n = rdt_default_cgroups();
if (n < 0) {
rdt_free_cgroups();
- ERROR(RDT_PLUGIN
- ": Error creating default core groups configuration.");
+ ERROR(RDT_PLUGIN ": Error creating default core groups configuration.");
return n;
}
INFO(RDT_PLUGIN
return (0);
}
+static void rdt_pqos_log(void *context, const size_t size, const char *msg) {
+ DEBUG(RDT_PLUGIN ": %s", msg);
+}
+
static int rdt_preinit(void) {
int ret;
return (-ENOMEM);
}
- /* In case previous instance of the application was not closed properly
- * call fini and ignore return code. */
- pqos_fini();
+ struct pqos_config pqos = {.fd_log = -1,
+ .callback_log = rdt_pqos_log,
+ .context_log = NULL,
+ .verbose = 0};
- /* TODO:
- * stdout should not be used here. Will be reworked when support of log
- * callback is added to PQoS library.
- */
- ret = pqos_init(&(struct pqos_config){.fd_log = STDOUT_FILENO});
+ ret = pqos_init(&pqos);
if (ret != PQOS_RETVAL_OK) {
ERROR(RDT_PLUGIN ": Error initializing PQoS library!");
goto rdt_preinit_error1;
goto rdt_preinit_error2;
}
- ret = pqos_cap_get_type(g_rdt->pqos_cap, PQOS_CAP_TYPE_MON,
- &g_rdt->cap_mon);
+ ret = pqos_cap_get_type(g_rdt->pqos_cap, PQOS_CAP_TYPE_MON, &g_rdt->cap_mon);
if (ret == PQOS_RETVAL_PARAM) {
ERROR(RDT_PLUGIN ": Error retrieving monitoring capabilities.");
goto rdt_preinit_error2;
goto rdt_preinit_error2;
}
+ /* Reset pqos monitoring groups registers */
+ pqos_mon_reset();
+
return (0);
rdt_preinit_error2:
#endif /* COLLECT_DEBUG */
} else {
- ERROR(RDT_PLUGIN ": Unknown configuration parameter \"%s\".",
- child->key);
+ ERROR(RDT_PLUGIN ": Unknown configuration parameter \"%s\".", child->key);
}
}
}
static void rdt_submit_derive(char *cgroup, char *type, char *type_instance,
- derive_t value) {
+ derive_t value) {
value_list_t vl = VALUE_LIST_INIT;
- vl.values = &(value_t) { .derive = value };
+ vl.values = &(value_t){.derive = value};
vl.values_len = 1;
sstrncpy(vl.plugin, RDT_PLUGIN, sizeof(vl.plugin));
}
static void rdt_submit_gauge(char *cgroup, char *type, char *type_instance,
- gauge_t value) {
+ gauge_t value) {
value_list_t vl = VALUE_LIST_INIT;
- vl.values = &(value_t) { .gauge = value };
+ vl.values = &(value_t){.gauge = value};
vl.values_len = 1;
sstrncpy(vl.plugin, RDT_PLUGIN, sizeof(vl.plugin));
rdt_submit_gauge(g_rdt->cgroups[i].desc, "ipc", NULL, pv->ipc);
if (g_rdt->cgroups[i].events & mbm_events) {
- rdt_submit_derive(g_rdt->cgroups[i].desc, "memory_bandwidth",
- "local", pv->mbm_local_delta);
- rdt_submit_derive(g_rdt->cgroups[i].desc, "memory_bandwidth",
- "remote", pv->mbm_remote_delta);
+ rdt_submit_derive(g_rdt->cgroups[i].desc, "memory_bandwidth", "local",
+ pv->mbm_local_delta);
+ rdt_submit_derive(g_rdt->cgroups[i].desc, "memory_bandwidth", "remote",
+ pv->mbm_remote_delta);
}
}