{"action":"created","comment":{"url":"https://api.github.com/repos/collectd/collectd/pulls/comments/70942729","id":70942729,"diff_hunk":"@@ -18,28 +18,125 @@\n  *\n  * Authors:\n  *   Peter Holik <peter at holik.at>\n+ *   Igor Solovyov <igor dot solovyov at gmail dot com>\n  **/\n \n+/**\n+ * For quite a while, Linux kernel exposes the current CPU frequency via\n+ * \"/sys/devices/system/cpu/cpuX/cpufreq/scaling_cur_freq\" file.\n+ *\n+ * Nevertheless, in CentOS 7.1 it was observed that kernel doesn't provide the file anymore, with\n+ * the employed intel_pstate CPU frequency driver.\n+ *\n+ * The issue above has been fixed in https://github.com/torvalds/linux/commit/c034b02e213d271b98c45c4a7b54af8f69aaac1e .\n+ * But up to now with for example, CentOS 7.2, the fix has not been back-ported yet.\n+ *\n+ * Note that there is another \"cpuinfo_cur_freq\" file under \"/sys/devices/system/cpu/cpuX/cpufreq/\" directory.\n+ * This file exposes not exactly the same thing as \"scaling_cur_freq\" does, but close by nature.\n+ * More details: http://www.pantz.org/software/cpufreq/usingcpufreqonlinux.html\n+ *\n+ * Overall it is better to have a workaround for monitoring some CPU frequency on even with kernels that lack\n+ * the aforementioned fix.\n+ *\n+ * Also, an optional parameter \"Path\" is introduced to specify alternative CPU frequency path.\n+ * Example:\n+ * <Plugin cpufreq>\n+ *     Path \"/sys/devices/system/cpu/cpu%d/cpufreq/cpuinfo_cur_freq\"\n+ * </Plugin>\n+ *\n+ * Note, \"%d\" has to be used only once as CPU index placeholder.\n+**/\n+\n #include \"collectd.h\"\n #include \"common.h\"\n #include \"plugin.h\"\n \n #define MODULE_NAME \"cpufreq\"\n+#define MAX_STR_L 256\n \n static int num_cpu = 0;\n \n+static char const * freq_fname_def = \"/sys/devices/system/cpu/cpu%d/cpufreq/\"\n+\t\t\t\t\t\t\t\t\t \"scaling_cur_freq\";\n+static char freq_fname[MAX_STR_L] = {0};\n+\n+static const char *config_keys[] =\n+{\n+\t\"Path\"\n+};\n+static int config_keys_num = STATIC_ARRAY_SIZE (config_keys);\n+\n+int check_format (char const * src)\n+{\n+\tint pc = -2;\n+\tint d = -2;\n+\tchar const * p;\n+\n+\tfor (p=src; *p; ++p) {\n+\t\tswitch (*p) {\n+\t\t\tcase '%':\n+\t\t\t\tif (-2 != pc) return 0;\n+\t\t\t\tpc=p-src;\n+\t\t\t\tbreak;\n+\n+\t\t\tcase 'd':\n+\t\t\t\tif (pc+1 == p-src) d=p-src;\n+\t\t\t\tbreak;\n+\t\t}\n+\t}\n+\n+\treturn pc+1==d;\n+} /* check_format */\n+\n+static int cpufreq_config (char const * key, char const * value)","path":"src/cpufreq.c","position":74,"original_position":74,"commit_id":"1ceb7f76bb3f95fc5f719bcae14dcadf3e1eeef8","original_commit_id":"1ceb7f76bb3f95fc5f719bcae14dcadf3e1eeef8","user":{"login":"rubenk","id":47338,"avatar_url":"https://avatars.githubusercontent.com/u/47338?v=3","gravatar_id":"","url":"https://api.github.com/users/rubenk","html_url":"https://github.com/rubenk","followers_url":"https://api.github.com/users/rubenk/followers","following_url":"https://api.github.com/users/rubenk/following{/other_user}","gists_url":"https://api.github.com/users/rubenk/gists{/gist_id}","starred_url":"https://api.github.com/users/rubenk/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/rubenk/subscriptions","organizations_url":"https://api.github.com/users/rubenk/orgs","repos_url":"https://api.github.com/users/rubenk/repos","events_url":"https://api.github.com/users/rubenk/events{/privacy}","received_events_url":"https://api.github.com/users/rubenk/received_events","type":"User","site_admin":false},"body":"const char please.","created_at":"2016-07-15T09:07:52Z","updated_at":"2016-07-15T09:07:52Z","html_url":"https://github.com/collectd/collectd/pull/1771#discussion_r70942729","pull_request_url":"https://api.github.com/repos/collectd/collectd/pulls/1771","_links":{"self":{"href":"https://api.github.com/repos/collectd/collectd/pulls/comments/70942729"},"html":{"href":"https://github.com/collectd/collectd/pull/1771#discussion_r70942729"},"pull_request":{"href":"https://api.github.com/repos/collectd/collectd/pulls/1771"}}},"pull_request":{"url":"https://api.github.com/repos/collectd/collectd/pulls/1771","id":74676542,"html_url":"https://github.com/collectd/collectd/pull/1771","diff_url":"https://github.com/collectd/collectd/pull/1771.diff","patch_url":"https://github.com/collectd/collectd/pull/1771.patch","issue_url":"https://api.github.com/repos/collectd/collectd/issues/1771","number":1771,"state":"open","locked":false,"title":"cpufreq plugin now can obtain CPU frequency on \"broken\" kernels (obse…","user":{"login":"igsol","id":14091049,"avatar_url":"https://avatars.githubusercontent.com/u/14091049?v=3","gravatar_id":"","url":"https://api.github.com/users/igsol","html_url":"https://github.com/igsol","followers_url":"https://api.github.com/users/igsol/followers","following_url":"https://api.github.com/users/igsol/following{/other_user}","gists_url":"https://api.github.com/users/igsol/gists{/gist_id}","starred_url":"https://api.github.com/users/igsol/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/igsol/subscriptions","organizations_url":"https://api.github.com/users/igsol/orgs","repos_url":"https://api.github.com/users/igsol/repos","events_url":"https://api.github.com/users/igsol/events{/privacy}","received_events_url":"https://api.github.com/users/igsol/received_events","type":"User","site_admin":false},"body":"cpufreq plugin now can obtain CPU frequency on \"broken\" kernels (observed in CentOS 7.1, 7.2) where \"/sys/devices/system/cpu/cpuX/cpufreq/scaling_cur_freq\" file is absent.\r\n\r\nThe fix relative to #624.","created_at":"2016-06-21T20:07:56Z","updated_at":"2016-07-15T09:07:52Z","closed_at":null,"merged_at":null,"merge_commit_sha":"c6235431d97e47f4bcb18458429be33b0de4f6ec","assignee":null,"assignees":[],"milestone":null,"commits_url":"https://api.github.com/repos/collectd/collectd/pulls/1771/commits","review_comments_url":"https://api.github.com/repos/collectd/collectd/pulls/1771/comments","review_comment_url":"https://api.github.com/repos/collectd/collectd/pulls/comments{/number}","comments_url":"https://api.github.com/repos/collectd/collectd/issues/1771/comments","statuses_url":"https://api.github.com/repos/collectd/collectd/statuses/1ceb7f76bb3f95fc5f719bcae14dcadf3e1eeef8","head":{"label":"igsol:cpufreq_alternative_path","ref":"cpufreq_alternative_path","sha":"1ceb7f76bb3f95fc5f719bcae14dcadf3e1eeef8","user":{"login":"igsol","id":14091049,"avatar_url":"https://avatars.githubusercontent.com/u/14091049?v=3","gravatar_id":"","url":"https://api.github.com/users/igsol","html_url":"https://github.com/igsol","followers_url":"https://api.github.com/users/igsol/followers","following_url":"https://api.github.com/users/igsol/following{/other_user}","gists_url":"https://api.github.com/users/igsol/gists{/gist_id}","starred_url":"https://api.github.com/users/igsol/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/igsol/subscriptions","organizations_url":"https://api.github.com/users/igsol/orgs","repos_url":"https://api.github.com/users/igsol/repos","events_url":"https://api.github.com/users/igsol/events{/privacy}","received_events_url":"https://api.github.com/users/igsol/received_events","type":"User","site_admin":false},"repo":{"id":59792892,"name":"collectd","full_name":"igsol/collectd","owner":{"login":"igsol","id":14091049,"avatar_url":"https://avatars.githubusercontent.com/u/14091049?v=3","gravatar_id":"","url":"https://api.github.com/users/igsol","html_url":"https://github.com/igsol","followers_url":"https://api.github.com/users/igsol/followers","following_url":"https://api.github.com/users/igsol/following{/other_user}","gists_url":"https://api.github.com/users/igsol/gists{/gist_id}","starred_url":"https://api.github.com/users/igsol/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/igsol/subscriptions","organizations_url":"https://api.github.com/users/igsol/orgs","repos_url":"https://api.github.com/users/igsol/repos","events_url":"https://api.github.com/users/igsol/events{/privacy}","received_events_url":"https://api.github.com/users/igsol/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/igsol/collectd","description":"The system statistics collection daemon. Mirror of the canonical repository (updated automatically). Please send Pull Requests here!","fork":true,"url":"https://api.github.com/repos/igsol/collectd","forks_url":"https://api.github.com/repos/igsol/collectd/forks","keys_url":"https://api.github.com/repos/igsol/collectd/keys{/key_id}","collaborators_url":"https://api.github.com/repos/igsol/collectd/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/igsol/collectd/teams","hooks_url":"https://api.github.com/repos/igsol/collectd/hooks","issue_events_url":"https://api.github.com/repos/igsol/collectd/issues/events{/number}","events_url":"https://api.github.com/repos/igsol/collectd/events","assignees_url":"https://api.github.com/repos/igsol/collectd/assignees{/user}","branches_url":"https://api.github.com/repos/igsol/collectd/branches{/branch}","tags_url":"https://api.github.com/repos/igsol/collectd/tags","blobs_url":"https://api.github.com/repos/igsol/collectd/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/igsol/collectd/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/igsol/collectd/git/refs{/sha}","trees_url":"https://api.github.com/repos/igsol/collectd/git/trees{/sha}","statuses_url":"https://api.github.com/repos/igsol/collectd/statuses/{sha}","languages_url":"https://api.github.com/repos/igsol/collectd/languages","stargazers_url":"https://api.github.com/repos/igsol/collectd/stargazers","contributors_url":"https://api.github.com/repos/igsol/collectd/contributors","subscribers_url":"https://api.github.com/repos/igsol/collectd/subscribers","subscription_url":"https://api.github.com/repos/igsol/collectd/subscription","commits_url":"https://api.github.com/repos/igsol/collectd/commits{/sha}","git_commits_url":"https://api.github.com/repos/igsol/collectd/git/commits{/sha}","comments_url":"https://api.github.com/repos/igsol/collectd/comments{/number}","issue_comment_url":"https://api.github.com/repos/igsol/collectd/issues/comments{/number}","contents_url":"https://api.github.com/repos/igsol/collectd/contents/{+path}","compare_url":"https://api.github.com/repos/igsol/collectd/compare/{base}...{head}","merges_url":"https://api.github.com/repos/igsol/collectd/merges","archive_url":"https://api.github.com/repos/igsol/collectd/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/igsol/collectd/downloads","issues_url":"https://api.github.com/repos/igsol/collectd/issues{/number}","pulls_url":"https://api.github.com/repos/igsol/collectd/pulls{/number}","milestones_url":"https://api.github.com/repos/igsol/collectd/milestones{/number}","notifications_url":"https://api.github.com/repos/igsol/collectd/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/igsol/collectd/labels{/name}","releases_url":"https://api.github.com/repos/igsol/collectd/releases{/id}","deployments_url":"https://api.github.com/repos/igsol/collectd/deployments","created_at":"2016-05-27T00:55:08Z","updated_at":"2016-05-27T00:55:11Z","pushed_at":"2016-06-21T19:59:26Z","git_url":"git://github.com/igsol/collectd.git","ssh_url":"git@github.com:igsol/collectd.git","clone_url":"https://github.com/igsol/collectd.git","svn_url":"https://github.com/igsol/collectd","homepage":"http://collectd.org/","size":13932,"stargazers_count":0,"watchers_count":0,"language":"C","has_issues":false,"has_downloads":true,"has_wiki":false,"has_pages":false,"forks_count":0,"mirror_url":null,"open_issues_count":0,"forks":0,"open_issues":0,"watchers":0,"default_branch":"master"}},"base":{"label":"collectd:master","ref":"master","sha":"37fe166fd6124adeaa91bc26b0a5e34cbdf25114","user":{"login":"collectd","id":1027481,"avatar_url":"https://avatars.githubusercontent.com/u/1027481?v=3","gravatar_id":"","url":"https://api.github.com/users/collectd","html_url":"https://github.com/collectd","followers_url":"https://api.github.com/users/collectd/followers","following_url":"https://api.github.com/users/collectd/following{/other_user}","gists_url":"https://api.github.com/users/collectd/gists{/gist_id}","starred_url":"https://api.github.com/users/collectd/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/collectd/subscriptions","organizations_url":"https://api.github.com/users/collectd/orgs","repos_url":"https://api.github.com/users/collectd/repos","events_url":"https://api.github.com/users/collectd/events{/privacy}","received_events_url":"https://api.github.com/users/collectd/received_events","type":"Organization","site_admin":false},"repo":{"id":3208640,"name":"collectd","full_name":"collectd/collectd","owner":{"login":"collectd","id":1027481,"avatar_url":"https://avatars.githubusercontent.com/u/1027481?v=3","gravatar_id":"","url":"https://api.github.com/users/collectd","html_url":"https://github.com/collectd","followers_url":"https://api.github.com/users/collectd/followers","following_url":"https://api.github.com/users/collectd/following{/other_user}","gists_url":"https://api.github.com/users/collectd/gists{/gist_id}","starred_url":"https://api.github.com/users/collectd/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/collectd/subscriptions","organizations_url":"https://api.github.com/users/collectd/orgs","repos_url":"https://api.github.com/users/collectd/repos","events_url":"https://api.github.com/users/collectd/events{/privacy}","received_events_url":"https://api.github.com/users/collectd/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/collectd/collectd","description":"The system statistics collection daemon. Mirror of the canonical repository (updated automatically). Please send Pull Requests here!","fork":false,"url":"https://api.github.com/repos/collectd/collectd","forks_url":"https://api.github.com/repos/collectd/collectd/forks","keys_url":"https://api.github.com/repos/collectd/collectd/keys{/key_id}","collaborators_url":"https://api.github.com/repos/collectd/collectd/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/collectd/collectd/teams","hooks_url":"https://api.github.com/repos/collectd/collectd/hooks","issue_events_url":"https://api.github.com/repos/collectd/collectd/issues/events{/number}","events_url":"https://api.github.com/repos/collectd/collectd/events","assignees_url":"https://api.github.com/repos/collectd/collectd/assignees{/user}","branches_url":"https://api.github.com/repos/collectd/collectd/branches{/branch}","tags_url":"https://api.github.com/repos/collectd/collectd/tags","blobs_url":"https://api.github.com/repos/collectd/collectd/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/collectd/collectd/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/collectd/collectd/git/refs{/sha}","trees_url":"https://api.github.com/repos/collectd/collectd/git/trees{/sha}","statuses_url":"https://api.github.com/repos/collectd/collectd/statuses/{sha}","languages_url":"https://api.github.com/repos/collectd/collectd/languages","stargazers_url":"https://api.github.com/repos/collectd/collectd/stargazers","contributors_url":"https://api.github.com/repos/collectd/collectd/contributors","subscribers_url":"https://api.github.com/repos/collectd/collectd/subscribers","subscription_url":"https://api.github.com/repos/collectd/collectd/subscription","commits_url":"https://api.github.com/repos/collectd/collectd/commits{/sha}","git_commits_url":"https://api.github.com/repos/collectd/collectd/git/commits{/sha}","comments_url":"https://api.github.com/repos/collectd/collectd/comments{/number}","issue_comment_url":"https://api.github.com/repos/collectd/collectd/issues/comments{/number}","contents_url":"https://api.github.com/repos/collectd/collectd/contents/{+path}","compare_url":"https://api.github.com/repos/collectd/collectd/compare/{base}...{head}","merges_url":"https://api.github.com/repos/collectd/collectd/merges","archive_url":"https://api.github.com/repos/collectd/collectd/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/collectd/collectd/downloads","issues_url":"https://api.github.com/repos/collectd/collectd/issues{/number}","pulls_url":"https://api.github.com/repos/collectd/collectd/pulls{/number}","milestones_url":"https://api.github.com/repos/collectd/collectd/milestones{/number}","notifications_url":"https://api.github.com/repos/collectd/collectd/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/collectd/collectd/labels{/name}","releases_url":"https://api.github.com/repos/collectd/collectd/releases{/id}","deployments_url":"https://api.github.com/repos/collectd/collectd/deployments","created_at":"2012-01-18T13:07:51Z","updated_at":"2016-07-14T14:57:32Z","pushed_at":"2016-07-15T08:56:14Z","git_url":"git://github.com/collectd/collectd.git","ssh_url":"git@github.com:collectd/collectd.git","clone_url":"https://github.com/collectd/collectd.git","svn_url":"https://github.com/collectd/collectd","homepage":"http://collectd.org/","size":27122,"stargazers_count":1195,"watchers_count":1195,"language":"C","has_issues":true,"has_downloads":true,"has_wiki":false,"has_pages":false,"forks_count":682,"mirror_url":null,"open_issues_count":383,"forks":682,"open_issues":383,"watchers":1195,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/collectd/collectd/pulls/1771"},"html":{"href":"https://github.com/collectd/collectd/pull/1771"},"issue":{"href":"https://api.github.com/repos/collectd/collectd/issues/1771"},"comments":{"href":"https://api.github.com/repos/collectd/collectd/issues/1771/comments"},"review_comments":{"href":"https://api.github.com/repos/collectd/collectd/pulls/1771/comments"},"review_comment":{"href":"https://api.github.com/repos/collectd/collectd/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/collectd/collectd/pulls/1771/commits"},"statuses":{"href":"https://api.github.com/repos/collectd/collectd/statuses/1ceb7f76bb3f95fc5f719bcae14dcadf3e1eeef8"}}}}
{"actor":{"display_login":"rubenk"}}