X-Git-Url: https://git.octo.it/?a=blobdiff_plain;f=src%2Fturbostat.c;h=80650dff38539c781bf106a2cdcc462ceaaf3300;hb=da658a37ddd9421752903c4ff5f2aa83320387c5;hp=5ee45186ade3c2f7855886cdb183f9377e705107;hpb=f5809f75f6243584cb2f56a6d82f156cd4323768;p=collectd.git diff --git a/src/turbostat.c b/src/turbostat.c index 5ee45186..80650dff 100644 --- a/src/turbostat.c +++ b/src/turbostat.c @@ -41,23 +41,10 @@ #include "utils_time.h" #include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include #include +#ifdef HAVE_SYS_CAPABILITY_H #include +#endif /* HAVE_SYS_CAPABILITY_H */ #define PLUGIN_NAME "turbostat" @@ -184,10 +171,10 @@ static struct pkg_data { unsigned long long pc9; unsigned long long pc10; unsigned int package_id; - unsigned int energy_pkg; /* MSR_PKG_ENERGY_STATUS */ - unsigned int energy_dram; /* MSR_DRAM_ENERGY_STATUS */ - unsigned int energy_cores; /* MSR_PP0_ENERGY_STATUS */ - unsigned int energy_gfx; /* MSR_PP1_ENERGY_STATUS */ + uint32_t energy_pkg; /* MSR_PKG_ENERGY_STATUS */ + uint32_t energy_dram; /* MSR_DRAM_ENERGY_STATUS */ + uint32_t energy_cores; /* MSR_PP0_ENERGY_STATUS */ + uint32_t energy_gfx; /* MSR_PP1_ENERGY_STATUS */ unsigned int tcc_activation_temp; unsigned int pkg_temp_c; } *package_delta, *package_even, *package_odd; @@ -212,17 +199,17 @@ static _Bool initialized = 0; #define GET_PKG(pkg_base, pkg_no) (pkg_base + pkg_no) struct cpu_topology { - int package_id; - int core_id; + unsigned int package_id; + unsigned int core_id; _Bool first_core_in_package; _Bool first_thread_in_core; }; static struct topology { - int max_cpu_id; - int num_packages; - int num_cores; - int num_threads; + unsigned int max_cpu_id; + unsigned int num_packages; + unsigned int num_cores; + unsigned int num_threads; struct cpu_topology *cpus; } topology; @@ -249,7 +236,7 @@ static const int config_keys_num = STATIC_ARRAY_SIZE (config_keys); * Can change the scheduling affinity of the current process if multiple_read is 1 */ static int __attribute__((warn_unused_result)) -open_msr(int cpu, _Bool multiple_read) +open_msr(unsigned int cpu, _Bool multiple_read) { char pathname[32]; int fd; @@ -265,7 +252,7 @@ open_msr(int cpu, _Bool multiple_read) CPU_ZERO_S(cpu_affinity_setsize, cpu_affinity_set); CPU_SET_S(cpu, cpu_affinity_setsize, cpu_affinity_set); if (sched_setaffinity(0, cpu_affinity_setsize, cpu_affinity_set) == -1) { - ERROR("Turbostat plugin: Could not migrate to CPU %d", cpu); + ERROR("turbostat plugin: Could not migrate to CPU %d", cpu); return -1; } } @@ -273,7 +260,7 @@ open_msr(int cpu, _Bool multiple_read) ssnprintf(pathname, sizeof(pathname), "/dev/cpu/%d/msr", cpu); fd = open(pathname, O_RDONLY); if (fd < 0) { - ERROR("Turbostat plugin: failed to open %s", pathname); + ERROR("turbostat plugin: failed to open %s", pathname); return -1; } return fd; @@ -290,7 +277,7 @@ read_msr(int fd, off_t offset, unsigned long long *msr) retval = pread(fd, msr, sizeof *msr, offset); if (retval != sizeof *msr) { - ERROR("Turbostat plugin: MSR offset 0x%llx read failed", + ERROR("turbostat plugin: MSR offset 0x%llx read failed", (unsigned long long)offset); return -1; } @@ -301,8 +288,8 @@ read_msr(int fd, off_t offset, unsigned long long *msr) * Open a MSR device for reading, read the value asked for and close it. * This call will not affect the scheduling affinity of this thread. */ -static int __attribute__((warn_unused_result)) -get_msr(int cpu, off_t offset, unsigned long long *msr) +static ssize_t __attribute__((warn_unused_result)) +get_msr(unsigned int cpu, off_t offset, unsigned long long *msr) { ssize_t retval; int fd; @@ -331,7 +318,7 @@ get_msr(int cpu, off_t offset, unsigned long long *msr) static int __attribute__((warn_unused_result)) get_counters(struct thread_data *t, struct core_data *c, struct pkg_data *p) { - int cpu = t->cpu_id; + unsigned int cpu = t->cpu_id; unsigned long long msr; int msr_fd; int retval = 0; @@ -343,7 +330,7 @@ get_counters(struct thread_data *t, struct core_data *c, struct pkg_data *p) #define READ_MSR(msr, dst) \ do { \ if (read_msr(msr_fd, msr, dst)) { \ - ERROR("Turbostat plugin: Unable to read " #msr); \ + ERROR("turbostat plugin: Unable to read " #msr); \ retval = -1; \ goto out; \ } \ @@ -430,16 +417,6 @@ out: **********************************/ /* - * Do delta = new - old on 32bits cyclique intergers - */ -#define DELTA_WRAP32(delta, new, old) \ - if (new > old) { \ - delta = new - old; \ - } else { \ - delta = 0x100000000 + new - old; \ - } - -/* * Extract the evolution old->new in delta at a package level * (some are not new-delta, e.g. temperature) */ @@ -455,10 +432,10 @@ delta_package(struct pkg_data *delta, const struct pkg_data *new, const struct p delta->pc10 = new->pc10 - old->pc10; delta->pkg_temp_c = new->pkg_temp_c; - DELTA_WRAP32(delta->energy_pkg, new->energy_pkg, old->energy_pkg); - DELTA_WRAP32(delta->energy_cores, new->energy_cores, old->energy_cores); - DELTA_WRAP32(delta->energy_gfx, new->energy_gfx, old->energy_gfx); - DELTA_WRAP32(delta->energy_dram, new->energy_dram, old->energy_dram); + delta->energy_pkg = new->energy_pkg - old->energy_pkg; + delta->energy_cores = new->energy_cores - old->energy_cores; + delta->energy_gfx = new->energy_gfx - old->energy_gfx; + delta->energy_dram = new->energy_dram - old->energy_dram; } /* @@ -486,7 +463,7 @@ delta_thread(struct thread_data *delta, const struct thread_data *new, const str /* check for TSC < 1 Mcycles over interval */ if (delta->tsc < (1000 * 1000)) { - WARNING("Turbostat plugin: Insanely slow TSC rate, TSC stops " + WARNING("turbostat plugin: Insanely slow TSC rate, TSC stops " "in idle? You can disable all c-states by booting with" " 'idle=poll' or just the deep ones with" " 'processor.max_cstate=1'"); @@ -500,7 +477,7 @@ delta_thread(struct thread_data *delta, const struct thread_data *new, const str delta->mperf = new->mperf - old->mperf; } else { if (!aperf_mperf_unstable) { - WARNING("Turbostat plugin: APERF or MPERF went " + WARNING("turbostat plugin: APERF or MPERF went " "backwards. Frequency results do not cover " "the entire interval. Fix this by running " "Linux-2.6.30 or later."); @@ -523,7 +500,7 @@ delta_thread(struct thread_data *delta, const struct thread_data *new, const str } if (delta->mperf == 0) { - WARNING("Turbostat plugin: cpu%d MPERF 0!", old->cpu_id); + WARNING("turbostat plugin: cpu%d MPERF 0!", old->cpu_id); delta->mperf = 1; /* divide by 0 protection */ } @@ -583,17 +560,17 @@ submit_counters(struct thread_data *t, struct core_data *c, struct pkg_data *p) if (!aperf_mperf_unstable) turbostat_submit(name, "percent", "c1", 100.0 * t->c1/t->tsc); - turbostat_submit("Average", "frequency", name, 1.0 / 1000000 * t->aperf / interval_float); + turbostat_submit(name, "frequency", "average", 1.0 / 1000000 * t->aperf / interval_float); if ((!aperf_mperf_unstable) || (!(t->aperf > t->tsc || t->mperf > t->tsc))) - turbostat_submit("Buzy", "frequency", name, 1.0 * t->tsc / 1000000 * t->aperf / t->mperf / interval_float); + turbostat_submit(name, "frequency", "busy", 1.0 * t->tsc / 1000000 * t->aperf / t->mperf / interval_float); /* Sanity check (should stay stable) */ - turbostat_submit("TSC", "gauge", name, 1.0 * t->tsc / 1000000 / interval_float); + turbostat_submit(name, "gauge", "TSC", 1.0 * t->tsc / 1000000 / interval_float); /* SMI */ if (do_smi) - turbostat_submit(NULL, "current", name, t->smi_count); + turbostat_submit(name, "count", NULL, t->smi_count); /* submit per-core data only for 1st thread in core */ if (!(t->flags & CPU_IS_FIRST_THREAD_IN_CORE)) @@ -609,7 +586,7 @@ submit_counters(struct thread_data *t, struct core_data *c, struct pkg_data *p) turbostat_submit(name, "percent", "c7", 100.0 * c->c7/t->tsc); if (do_dts) - turbostat_submit(NULL, "temperature", name, c->core_temp_c); + turbostat_submit(name, "temperature", NULL, c->core_temp_c); /* submit per-package data only for 1st core in package */ if (!(t->flags & CPU_IS_FIRST_CORE_IN_PACKAGE)) @@ -618,7 +595,7 @@ submit_counters(struct thread_data *t, struct core_data *c, struct pkg_data *p) ssnprintf(name, sizeof(name), "pkg%02d", p->package_id); if (do_ptm) - turbostat_submit(NULL, "temperature", name, p->pkg_temp_c); + turbostat_submit(name, "temperature", NULL, p->pkg_temp_c); if (do_pkg_cstate & (1 << 2)) turbostat_submit(name, "percent", "pc2", 100.0 * p->pc2/t->tsc); @@ -637,13 +614,13 @@ submit_counters(struct thread_data *t, struct core_data *c, struct pkg_data *p) if (do_rapl) { if (do_rapl & RAPL_PKG) - turbostat_submit(name, "power", "Pkg_W", p->energy_pkg * rapl_energy_units / interval_float); + turbostat_submit(name, "power", "pkg", p->energy_pkg * rapl_energy_units / interval_float); if (do_rapl & RAPL_CORES) - turbostat_submit(name, "power", "Cor_W", p->energy_cores * rapl_energy_units / interval_float); + turbostat_submit(name, "power", "cores", p->energy_cores * rapl_energy_units / interval_float); if (do_rapl & RAPL_GFX) - turbostat_submit(name, "power", "GFX_W", p->energy_gfx * rapl_energy_units / interval_float); + turbostat_submit(name, "power", "GFX", p->energy_gfx * rapl_energy_units / interval_float); if (do_rapl & RAPL_DRAM) - turbostat_submit(name, "power", "RAM_W", p->energy_dram * rapl_energy_units / interval_float); + turbostat_submit(name, "power", "DRAM", p->energy_dram * rapl_energy_units / interval_float); } done: return 0; @@ -658,7 +635,7 @@ done: * Check if a given cpu id is in our compiled list of existing CPUs */ static int -cpu_is_not_present(int cpu) +cpu_is_not_present(unsigned int cpu) { return !CPU_ISSET_S(cpu, cpu_present_setsize, cpu_present_set); } @@ -673,7 +650,8 @@ static int __attribute__((warn_unused_result)) for_all_cpus(int (func)(struct thread_data *, struct core_data *, struct pkg_data *), struct thread_data *thread_base, struct core_data *core_base, struct pkg_data *pkg_base) { - int retval, pkg_no, core_no, thread_no; + int retval; + unsigned int pkg_no, core_no, thread_no; for (pkg_no = 0; pkg_no < topology.num_packages; ++pkg_no) { for (core_no = 0; core_no < topology.num_cores; ++core_no) { @@ -712,7 +690,8 @@ static int __attribute__((warn_unused_result)) for_all_cpus_delta(const struct thread_data *thread_new_base, const struct core_data *core_new_base, const struct pkg_data *pkg_new_base, const struct thread_data *thread_old_base, const struct core_data *core_old_base, const struct pkg_data *pkg_old_base) { - int retval, pkg_no, core_no, thread_no; + int retval; + unsigned int pkg_no, core_no, thread_no; for (pkg_no = 0; pkg_no < topology.num_packages; ++pkg_no) { for (core_no = 0; core_no < topology.num_cores; ++core_no) { @@ -815,7 +794,7 @@ set_temperature_target(struct thread_data *t, struct core_data *c, struct pkg_da guess: p->tcc_activation_temp = TJMAX_DEFAULT; - WARNING("Turbostat plugin: cpu%d: Guessing tjMax %d C," + WARNING("turbostat plugin: cpu%d: Guessing tjMax %d C," " Please use TCCActivationTemp to specify it.", t->cpu_id, p->tcc_activation_temp); @@ -840,7 +819,7 @@ probe_cpu() max_level = ebx = ecx = edx = 0; __get_cpuid(0, &max_level, &ebx, &ecx, &edx); if (ebx != 0x756e6547 && edx != 0x49656e69 && ecx != 0x6c65746e) { - ERROR("Turbostat plugin: Unsupported CPU (not Intel)"); + ERROR("turbostat plugin: Unsupported CPU (not Intel)"); return -1; } @@ -863,7 +842,7 @@ probe_cpu() if (family == 6 || family == 0xf) model += ((fms >> 16) & 0xf) << 4; if (!(edx & (1 << 5))) { - ERROR("Turbostat plugin: Unsupported CPU (no MSR support)"); + ERROR("turbostat plugin: Unsupported CPU (no MSR support)"); return -1; } @@ -884,7 +863,7 @@ probe_cpu() do_dts = eax & (1 << 0); do_ptm = eax & (1 << 6); if (!(ecx & (1 << 0))) { - ERROR("Turbostat plugin: Unsupported CPU (No APERF)"); + ERROR("turbostat plugin: Unsupported CPU (No APERF)"); return -1; } @@ -994,7 +973,7 @@ probe_cpu() do_rapl = 0; } } else { - ERROR("Turbostat plugin: Unsupported CPU (family: %#x, " + ERROR("turbostat plugin: Unsupported CPU (family: %#x, " "model: %#x)", family, model); return -1; } @@ -1047,17 +1026,17 @@ parse_int_file(const char *fmt, ...) len = vsnprintf(path, sizeof(path), fmt, args); va_end(args); if (len < 0 || len >= PATH_MAX) { - ERROR("Turbostat plugin: path truncated: '%s'", path); + ERROR("turbostat plugin: path truncated: '%s'", path); return -1; } filep = fopen(path, "r"); if (!filep) { - ERROR("Turbostat plugin: Failed to open '%s'", path); + ERROR("turbostat plugin: Failed to open '%s'", path); return -1; } if (fscanf(filep, "%d", &value) != 1) { - ERROR("Turbostat plugin: Failed to parse number from '%s'", path); + ERROR("turbostat plugin: Failed to parse number from '%s'", path); return -1; } fclose(filep); @@ -1065,7 +1044,7 @@ parse_int_file(const char *fmt, ...) } static int -get_threads_on_core(int cpu) +get_threads_on_core(unsigned int cpu) { char path[80]; FILE *filep; @@ -1076,7 +1055,7 @@ get_threads_on_core(int cpu) ssnprintf(path, sizeof(path), "/sys/devices/system/cpu/cpu%d/topology/thread_siblings_list", cpu); filep = fopen(path, "r"); if (!filep) { - ERROR("Turbostat plugin: Failed to open '%s'", path); + ERROR("turbostat plugin: Failed to open '%s'", path); return -1; } /* @@ -1099,21 +1078,21 @@ get_threads_on_core(int cpu) * return max_cpu number */ static int __attribute__((warn_unused_result)) -for_all_proc_cpus(int (func)(int)) +for_all_proc_cpus(int (func)(unsigned int)) { FILE *fp; - int cpu_num; + unsigned int cpu_num; int retval; fp = fopen("/proc/stat", "r"); if (!fp) { - ERROR("Turbostat plugin: Failed to open /proc/stat"); + ERROR("turbostat plugin: Failed to open /proc/stat"); return -1; } retval = fscanf(fp, "cpu %*d %*d %*d %*d %*d %*d %*d %*d %*d %*d\n"); if (retval != 0) { - ERROR("Turbostat plugin: Failed to parse /proc/stat"); + ERROR("turbostat plugin: Failed to parse /proc/stat"); fclose(fp); return -1; } @@ -1137,7 +1116,7 @@ for_all_proc_cpus(int (func)(int)) * Update the stored topology.max_cpu_id */ static int -update_max_cpu_id(int cpu) +update_max_cpu_id(unsigned int cpu) { if (topology.max_cpu_id < cpu) topology.max_cpu_id = cpu; @@ -1145,7 +1124,7 @@ update_max_cpu_id(int cpu) } static int -mark_cpu_present(int cpu) +mark_cpu_present(unsigned int cpu) { CPU_SET_S(cpu, cpu_present_setsize, cpu_present_set); return 0; @@ -1155,7 +1134,7 @@ static int __attribute__((warn_unused_result)) allocate_cpu_set(cpu_set_t ** set, size_t * size) { *set = CPU_ALLOC(topology.max_cpu_id + 1); if (*set == NULL) { - ERROR("Turbostat plugin: Unable to allocate CPU state"); + ERROR("turbostat plugin: Unable to allocate CPU state"); return -1; } *size = CPU_ALLOC_SIZE(topology.max_cpu_id + 1); @@ -1169,10 +1148,10 @@ allocate_cpu_set(cpu_set_t ** set, size_t * size) { static int __attribute__((warn_unused_result)) topology_probe() { - int i; + unsigned int i; int ret; - int max_package_id, max_core_id, max_thread_id; - max_package_id = max_core_id = max_thread_id = 0; + unsigned int max_package_id, max_core_id, max_threads; + max_package_id = max_core_id = max_threads = 0; /* Clean topology */ free(topology.cpus); @@ -1184,7 +1163,7 @@ topology_probe() topology.cpus = calloc(1, (topology.max_cpu_id + 1) * sizeof(struct cpu_topology)); if (topology.cpus == NULL) { - ERROR("Turbostat plugin: Unable to allocate memory for CPU topology"); + ERROR("turbostat plugin: Unable to allocate memory for CPU topology"); return -1; } @@ -1207,11 +1186,11 @@ topology_probe() * find max_core_id, max_package_id */ for (i = 0; i <= topology.max_cpu_id; ++i) { - int num_threads; + unsigned int num_threads; struct cpu_topology *cpu = &topology.cpus[i]; if (cpu_is_not_present(i)) { - WARNING("Turbostat plugin: cpu%d NOT PRESENT", i); + WARNING("turbostat plugin: cpu%d NOT PRESENT", i); continue; } @@ -1219,7 +1198,7 @@ topology_probe() if (ret < 0) goto err; else - cpu->package_id = ret; + cpu->package_id = (unsigned int) ret; if (cpu->package_id > max_package_id) max_package_id = cpu->package_id; @@ -1227,35 +1206,35 @@ topology_probe() if (ret < 0) goto err; else - cpu->core_id = ret; + cpu->core_id = (unsigned int) ret; if (cpu->core_id > max_core_id) max_core_id = cpu->core_id; ret = parse_int_file("/sys/devices/system/cpu/cpu%d/topology/core_siblings_list", i); if (ret < 0) goto err; - else if (ret == i) + else if ((unsigned int) ret == i) cpu->first_core_in_package = 1; ret = get_threads_on_core(i); if (ret < 0) goto err; else - num_threads = ret; - if (num_threads > max_thread_id) - max_thread_id = num_threads; + num_threads = (unsigned int) ret; + if (num_threads > max_threads) + max_threads = num_threads; ret = parse_int_file("/sys/devices/system/cpu/cpu%d/topology/thread_siblings_list", i); if (ret < 0) goto err; - else if (ret == i) + else if ((unsigned int) ret == i) cpu->first_thread_in_core = 1; - DEBUG("Turbostat plugin: cpu %d pkg %d core %d\n", + DEBUG("turbostat plugin: cpu %d pkg %d core %d\n", i, cpu->package_id, cpu->core_id); } /* Num is max + 1 (need to count 0) */ topology.num_packages = max_package_id + 1; topology.num_cores = max_core_id + 1; - topology.num_threads = max_thread_id + 1; + topology.num_threads = max_threads; return 0; err: @@ -1271,8 +1250,8 @@ err: static int allocate_counters(struct thread_data **threads, struct core_data **cores, struct pkg_data **packages) { - int i; - int total_threads, total_cores; + unsigned int i; + unsigned int total_threads, total_cores; total_threads = topology.num_threads * topology.num_cores * topology.num_packages; *threads = calloc(total_threads, sizeof(struct thread_data)); @@ -1280,23 +1259,17 @@ allocate_counters(struct thread_data **threads, struct core_data **cores, struct goto err; for (i = 0; i < total_threads; ++i) - (*threads)[i].cpu_id = -1; + (*threads)[i].cpu_id = topology.max_cpu_id + 1; total_cores = topology.num_cores * topology.num_packages; *cores = calloc(total_cores, sizeof(struct core_data)); if (*cores == NULL) goto err_clean_threads; - for (i = 0; i < total_cores; ++i) - (*cores)[i].core_id = -1; - *packages = calloc(topology.num_packages, sizeof(struct pkg_data)); if (*packages == NULL) goto err_clean_cores; - for (i = 0; i < topology.num_packages; i++) - (*packages)[i].package_id = i; - return 0; err_clean_cores: @@ -1304,13 +1277,13 @@ err_clean_cores: err_clean_threads: free(*threads); err: - ERROR("Turbostat plugin: Failled to allocate memory for counters"); + ERROR("turbostat plugin: Failled to allocate memory for counters"); return -1; } static void init_counter(struct thread_data *thread_base, struct core_data *core_base, - struct pkg_data *pkg_base, int cpu_id) + struct pkg_data *pkg_base, unsigned int cpu_id) { struct thread_data *t; struct core_data *c; @@ -1334,7 +1307,7 @@ init_counter(struct thread_data *thread_base, struct core_data *core_base, static void initialize_counters(void) { - int cpu_id; + unsigned int cpu_id; for (cpu_id = 0; cpu_id <= topology.max_cpu_id; ++cpu_id) { if (cpu_is_not_present(cpu_id)) @@ -1436,7 +1409,7 @@ turbostat_read(void) if ((ret = setup_all_buffers()) < 0) return ret; if (for_all_proc_cpus(cpu_is_not_present)) { - ERROR("Turbostat plugin: CPU appeared just after " + ERROR("turbostat plugin: CPU appeared just after " "initialization"); return -1; } @@ -1444,7 +1417,7 @@ turbostat_read(void) /* Saving the scheduling affinity, as it will be modified by get_counters */ if (sched_getaffinity(0, cpu_saved_affinity_setsize, cpu_saved_affinity_set) != 0) { - ERROR("Turbostat plugin: Unable to save the CPU affinity"); + ERROR("turbostat plugin: Unable to save the CPU affinity"); return -1; } @@ -1492,27 +1465,36 @@ out: static int check_permissions(void) { +#ifdef HAVE_SYS_CAPABILITY_H struct __user_cap_header_struct cap_header_data; cap_user_header_t cap_header = &cap_header_data; struct __user_cap_data_struct cap_data_data; cap_user_data_t cap_data = &cap_data_data; int ret = 0; +#endif /* HAVE_SYS_CAPABILITY_H */ if (getuid() == 0) { /* We have everything we need */ return 0; +#ifndef HAVE_SYS_CAPABILITY_H + } else { + ERROR("turbostat plugin: Initialization failed: this plugin " + "requires collectd to run as root"); + return -1; + } +#else /* HAVE_SYS_CAPABILITY_H */ } /* check for CAP_SYS_RAWIO */ cap_header->pid = getpid(); cap_header->version = _LINUX_CAPABILITY_VERSION; if (capget(cap_header, cap_data) < 0) { - ERROR("Turbostat plugin: capget failed"); + ERROR("turbostat plugin: capget failed"); return -1; } if ((cap_data->effective & (1 << CAP_SYS_RAWIO)) == 0) { - WARNING("Turbostat plugin: Collectd doesn't have the " + WARNING("turbostat plugin: Collectd doesn't have the " "CAP_SYS_RAWIO capability. If you don't want to run " "collectd as root, try running \"setcap " "cap_sys_rawio=ep\" on collectd binary"); @@ -1520,7 +1502,7 @@ check_permissions(void) } if (euidaccess("/dev/cpu/0/msr", R_OK)) { - WARNING("Turbostat plugin: Collectd cannot open" + WARNING("turbostat plugin: Collectd cannot open" "/dev/cpu/0/msr. If you don't want to run collectd as " "root, you need to change the ownership (chown) and " "permissions on /dev/cpu/*/msr to allow such access"); @@ -1528,11 +1510,12 @@ check_permissions(void) } if (ret != 0) - ERROR("Turbostat plugin: Initialization failed: this plugin " + ERROR("turbostat plugin: Initialization failed: this plugin " "requires collectd to either to run as root or give " "collectd a special capability (CAP_SYS_RAWIO) and read " "access to /dev/cpu/*/msr (see previous warnings)"); return ret; +#endif /* HAVE_SYS_CAPABILITY_H */ } static int @@ -1542,7 +1525,7 @@ turbostat_init(void) int ret; if (stat("/dev/cpu/0/msr", &sb)) { - ERROR("Turbostat plugin: Initialization failed: /dev/cpu/0/msr" + ERROR("turbostat plugin: Initialization failed: /dev/cpu/0/msr" " does not exist while the CPU supports MSR. You may be " "missing the corresponding kernel module, please try '# " "modprobe msr'"); @@ -1572,7 +1555,7 @@ turbostat_config(const char *key, const char *value) if (strcasecmp("CoreCstates", key) == 0) { tmp_val = strtoul(value, &end, 0); if (*end != '\0' || tmp_val > UINT_MAX) { - ERROR("Turbostat plugin: Invalid CoreCstates '%s'", + ERROR("turbostat plugin: Invalid CoreCstates '%s'", value); return -1; } @@ -1581,7 +1564,7 @@ turbostat_config(const char *key, const char *value) } else if (strcasecmp("PackageCstates", key) == 0) { tmp_val = strtoul(value, &end, 0); if (*end != '\0' || tmp_val > UINT_MAX) { - ERROR("Turbostat plugin: Invalid PackageCstates '%s'", + ERROR("turbostat plugin: Invalid PackageCstates '%s'", value); return -1; } @@ -1599,7 +1582,7 @@ turbostat_config(const char *key, const char *value) } else if (strcasecmp("RunningAveragePowerLimit", key) == 0) { tmp_val = strtoul(value, &end, 0); if (*end != '\0' || tmp_val > UINT_MAX) { - ERROR("Turbostat plugin: Invalid RunningAveragePowerLimit '%s'", + ERROR("turbostat plugin: Invalid RunningAveragePowerLimit '%s'", value); return -1; } @@ -1608,13 +1591,13 @@ turbostat_config(const char *key, const char *value) } else if (strcasecmp("TCCActivationTemp", key) == 0) { tmp_val = strtoul(value, &end, 0); if (*end != '\0' || tmp_val > UINT_MAX) { - ERROR("Turbostat plugin: Invalid TCCActivationTemp '%s'", + ERROR("turbostat plugin: Invalid TCCActivationTemp '%s'", value); return -1; } tcc_activation_temp = (unsigned int) tmp_val; } else { - ERROR("Turbostat plugin: Invalid configuration option '%s'", + ERROR("turbostat plugin: Invalid configuration option '%s'", key); return -1; }