X-Git-Url: https://git.verplant.org/?a=blobdiff_plain;f=src%2Fcpufreq.c;h=b1037c38bc25abbe8702059bfba8a1dc3177c998;hb=1a7050de376608268d11293d4e5faa3fb8516c5a;hp=46e8659882381443dc8dc482b008fa2e6e1a2e72;hpb=838af4cdc6c8674ed3e14a95fea172118c707a85;p=collectd.git diff --git a/src/cpufreq.c b/src/cpufreq.c index 46e86598..b1037c38 100644 --- a/src/cpufreq.c +++ b/src/cpufreq.c @@ -26,30 +26,10 @@ #define MODULE_NAME "cpufreq" -#if defined(KERNEL_LINUX) -# define CPUFREQ_HAVE_READ 1 -#else -# define CPUFREQ_HAVE_READ 0 -#endif - -static data_source_t data_source[1] = -{ - {"value", DS_TYPE_GAUGE, 0, NAN} -}; - -static data_set_t data_set = -{ - "cpufreq", 1, data_source -}; - -#if CPUFREQ_HAVE_READ -#ifdef KERNEL_LINUX static int num_cpu = 0; -#endif static int cpufreq_init (void) { -#ifdef KERNEL_LINUX int status; char filename[256]; @@ -74,7 +54,6 @@ static int cpufreq_init (void) if (num_cpu == 0) plugin_unregister_read ("cpufreq"); -#endif /* defined(KERNEL_LINUX) */ return (0); } /* int cpufreq_init */ @@ -99,7 +78,6 @@ static void cpufreq_submit (int cpu_num, double value) static int cpufreq_read (void) { -#ifdef KERNEL_LINUX int status; unsigned long long val; int i = 0; @@ -117,38 +95,43 @@ static int cpufreq_read (void) if ((fp = fopen (filename, "r")) == NULL) { - WARNING ("cpufreq: fopen: %s", strerror (errno)); + char errbuf[1024]; + WARNING ("cpufreq: fopen (%s): %s", filename, + sstrerror (errno, errbuf, + sizeof (errbuf))); return (-1); } if (fgets (buffer, 16, fp) == NULL) { - WARNING ("cpufreq: fgets: %s", strerror (errno)); + char errbuf[1024]; + WARNING ("cpufreq: fgets: %s", + sstrerror (errno, errbuf, + sizeof (errbuf))); fclose (fp); return (-1); } if (fclose (fp)) - WARNING ("cpufreq: fclose: %s", strerror (errno)); + { + char errbuf[1024]; + WARNING ("cpufreq: fclose: %s", + sstrerror (errno, errbuf, + sizeof (errbuf))); + } + /* You're seeing correctly: The file is reporting kHz values.. */ val = atoll (buffer) * 1000; cpufreq_submit (i, val); } -#endif /* defined(KERNEL_LINUX) */ return (0); } /* int cpufreq_read */ -#endif /* CPUFREQ_HAVE_READ */ -#undef BUFSIZE void module_register (void) { - plugin_register_data_set (&data_set); - -#if CPUFREQ_HAVE_READ plugin_register_init ("cpufreq", cpufreq_init); plugin_register_read ("cpufreq", cpufreq_read); -#endif /* CPUFREQ_HAVE_READ */ }