{"action":"created","comment":{"url":"https://api.github.com/repos/prometheus/node_exporter/pulls/comments/57543475","id":57543475,"diff_hunk":"@@ -0,0 +1,114 @@\n+package collector\n+\n+// +build linux freebsd\n+// +build !nozfs\n+\n+import (\n+\t\"errors\"\n+\t\"strings\"\n+\n+\t\"github.com/prometheus/client_golang/prometheus\"\n+\t\"github.com/prometheus/common/log\"\n+)\n+\n+type zfsMetricValue int\n+\n+const zfsErrorValue = zfsMetricValue(-1)\n+\n+var zfsNotAvailableError = errors.New(\"ZFS / ZFS statistics are not available\")\n+\n+type zfsSysctl string\n+type zfsSubsystemName string\n+\n+const (\n+\tarc            = zfsSubsystemName(\"zfsArc\")\n+\tzpoolSubsystem = zfsSubsystemName(\"zfsPool\")\n+)\n+\n+// Metrics\n+\n+type zfsMetric struct {\n+\tsubsystem zfsSubsystemName // The Prometheus subsystem name.\n+\tname      string           // The Prometheus name of the metric.\n+\tsysctl    zfsSysctl        // The sysctl of the ZFS metric.\n+}\n+\n+type datasetMetric struct {\n+\tsubsystem zfsSubsystemName\n+\tname      string\n+}\n+\n+// Collector\n+\n+func init() {\n+\tFactories[\"zfs\"] = NewZFSCollector\n+}\n+\n+type zfsCollector struct {\n+\tzfsMetrics []zfsMetric\n+}\n+\n+func NewZFSCollector() (Collector, error) {\n+\treturn &zfsCollector{}, nil\n+}\n+\n+func (c *zfsCollector) Update(ch chan<- prometheus.Metric) (err error) {\n+","path":"collector/zfs.go","position":56,"original_position":56,"commit_id":"a102306835b0ee6397ae383e01a76ad35c2c8736","original_commit_id":"a102306835b0ee6397ae383e01a76ad35c2c8736","user":{"login":"mdlayher","id":1926905,"avatar_url":"https://avatars.githubusercontent.com/u/1926905?v=3","gravatar_id":"","url":"https://api.github.com/users/mdlayher","html_url":"https://github.com/mdlayher","followers_url":"https://api.github.com/users/mdlayher/followers","following_url":"https://api.github.com/users/mdlayher/following{/other_user}","gists_url":"https://api.github.com/users/mdlayher/gists{/gist_id}","starred_url":"https://api.github.com/users/mdlayher/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/mdlayher/subscriptions","organizations_url":"https://api.github.com/users/mdlayher/orgs","repos_url":"https://api.github.com/users/mdlayher/repos","events_url":"https://api.github.com/users/mdlayher/events{/privacy}","received_events_url":"https://api.github.com/users/mdlayher/received_events","type":"User","site_admin":false},"body":"I've noticed you sometimes add extra whitespace at the beginning or end of function blocks.  To me, it looks a little bit messy.  However, I'm not a member of the Prometheus project, so I will defer to their stylistic preferences.","created_at":"2016-03-28T04:04:47Z","updated_at":"2016-03-28T04:04:47Z","html_url":"https://github.com/prometheus/node_exporter/pull/213#discussion_r57543475","pull_request_url":"https://api.github.com/repos/prometheus/node_exporter/pulls/213","_links":{"self":{"href":"https://api.github.com/repos/prometheus/node_exporter/pulls/comments/57543475"},"html":{"href":"https://github.com/prometheus/node_exporter/pull/213#discussion_r57543475"},"pull_request":{"href":"https://api.github.com/repos/prometheus/node_exporter/pulls/213"}}},"pull_request":{"url":"https://api.github.com/repos/prometheus/node_exporter/pulls/213","id":62642610,"html_url":"https://github.com/prometheus/node_exporter/pull/213","diff_url":"https://github.com/prometheus/node_exporter/pull/213.diff","patch_url":"https://github.com/prometheus/node_exporter/pull/213.patch","issue_url":"https://api.github.com/repos/prometheus/node_exporter/issues/213","number":213,"state":"open","locked":false,"title":"Add a collector for ZFS, currently focussed on ARC stats.","user":{"login":"problame","id":956573,"avatar_url":"https://avatars.githubusercontent.com/u/956573?v=3","gravatar_id":"","url":"https://api.github.com/users/problame","html_url":"https://github.com/problame","followers_url":"https://api.github.com/users/problame/followers","following_url":"https://api.github.com/users/problame/following{/other_user}","gists_url":"https://api.github.com/users/problame/gists{/gist_id}","starred_url":"https://api.github.com/users/problame/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/problame/subscriptions","organizations_url":"https://api.github.com/users/problame/orgs","repos_url":"https://api.github.com/users/problame/repos","events_url":"https://api.github.com/users/problame/events{/privacy}","received_events_url":"https://api.github.com/users/problame/received_events","type":"User","site_admin":false},"body":"It is tested on **FreeBSD 10.2-RELEASE** and Linux (**ZFS on Linux 0.6.5.4**).\r\nIt does *not* require root privileges to run on either of the above systems.\r\n\r\nOn FreeBSD, Solaris, etc. ZFS metrics are exposed through **sysctls**.\r\nZFS on Linux exposes the same metrics through **procfs** `/proc/spl/...`.\r\n\r\nIn addition to sysctl metrics, **computed metrics** are exposed by\r\nthe collector, which are based on several sysctl values.\r\nThere is some conditional logic involved in computing these metrics\r\nwhich cannot be easily mapped to PromQL.\r\n\r\nNot all 92 ARC sysctls are exposed right now but this can be changed\r\nwith one additional LOC each.\r\n\r\n**Questions about behavior:**\r\n\r\n1. What should happen if `-collectors.enabled zfs` is set but the stats cannot be found (e.g. because the kernel module is not loaded).<br>Currently node_exporter terminates with an error message.\r\n2. If the behavior described above is not desired, should the collector determine at runtime whether data is available?\r\n\r\n    2.1. Should it expose no metrics if no data is available?\r\n    2.2. Could the `zfs` collector be enabled by default if it does nothing on a non-ZFS system?","created_at":"2016-03-12T14:27:08Z","updated_at":"2016-03-28T04:04:47Z","closed_at":null,"merged_at":null,"merge_commit_sha":"40a2559eeb5cd1b34796502d6b569b54a221363c","assignee":null,"milestone":null,"commits_url":"https://api.github.com/repos/prometheus/node_exporter/pulls/213/commits","review_comments_url":"https://api.github.com/repos/prometheus/node_exporter/pulls/213/comments","review_comment_url":"https://api.github.com/repos/prometheus/node_exporter/pulls/comments{/number}","comments_url":"https://api.github.com/repos/prometheus/node_exporter/issues/213/comments","statuses_url":"https://api.github.com/repos/prometheus/node_exporter/statuses/a102306835b0ee6397ae383e01a76ad35c2c8736","head":{"label":"problame:master","ref":"master","sha":"a102306835b0ee6397ae383e01a76ad35c2c8736","user":{"login":"problame","id":956573,"avatar_url":"https://avatars.githubusercontent.com/u/956573?v=3","gravatar_id":"","url":"https://api.github.com/users/problame","html_url":"https://github.com/problame","followers_url":"https://api.github.com/users/problame/followers","following_url":"https://api.github.com/users/problame/following{/other_user}","gists_url":"https://api.github.com/users/problame/gists{/gist_id}","starred_url":"https://api.github.com/users/problame/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/problame/subscriptions","organizations_url":"https://api.github.com/users/problame/orgs","repos_url":"https://api.github.com/users/problame/repos","events_url":"https://api.github.com/users/problame/events{/privacy}","received_events_url":"https://api.github.com/users/problame/received_events","type":"User","site_admin":false},"repo":{"id":51827852,"name":"node_exporter","full_name":"problame/node_exporter","owner":{"login":"problame","id":956573,"avatar_url":"https://avatars.githubusercontent.com/u/956573?v=3","gravatar_id":"","url":"https://api.github.com/users/problame","html_url":"https://github.com/problame","followers_url":"https://api.github.com/users/problame/followers","following_url":"https://api.github.com/users/problame/following{/other_user}","gists_url":"https://api.github.com/users/problame/gists{/gist_id}","starred_url":"https://api.github.com/users/problame/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/problame/subscriptions","organizations_url":"https://api.github.com/users/problame/orgs","repos_url":"https://api.github.com/users/problame/repos","events_url":"https://api.github.com/users/problame/events{/privacy}","received_events_url":"https://api.github.com/users/problame/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/problame/node_exporter","description":"Exporter for machine metrics","fork":true,"url":"https://api.github.com/repos/problame/node_exporter","forks_url":"https://api.github.com/repos/problame/node_exporter/forks","keys_url":"https://api.github.com/repos/problame/node_exporter/keys{/key_id}","collaborators_url":"https://api.github.com/repos/problame/node_exporter/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/problame/node_exporter/teams","hooks_url":"https://api.github.com/repos/problame/node_exporter/hooks","issue_events_url":"https://api.github.com/repos/problame/node_exporter/issues/events{/number}","events_url":"https://api.github.com/repos/problame/node_exporter/events","assignees_url":"https://api.github.com/repos/problame/node_exporter/assignees{/user}","branches_url":"https://api.github.com/repos/problame/node_exporter/branches{/branch}","tags_url":"https://api.github.com/repos/problame/node_exporter/tags","blobs_url":"https://api.github.com/repos/problame/node_exporter/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/problame/node_exporter/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/problame/node_exporter/git/refs{/sha}","trees_url":"https://api.github.com/repos/problame/node_exporter/git/trees{/sha}","statuses_url":"https://api.github.com/repos/problame/node_exporter/statuses/{sha}","languages_url":"https://api.github.com/repos/problame/node_exporter/languages","stargazers_url":"https://api.github.com/repos/problame/node_exporter/stargazers","contributors_url":"https://api.github.com/repos/problame/node_exporter/contributors","subscribers_url":"https://api.github.com/repos/problame/node_exporter/subscribers","subscription_url":"https://api.github.com/repos/problame/node_exporter/subscription","commits_url":"https://api.github.com/repos/problame/node_exporter/commits{/sha}","git_commits_url":"https://api.github.com/repos/problame/node_exporter/git/commits{/sha}","comments_url":"https://api.github.com/repos/problame/node_exporter/comments{/number}","issue_comment_url":"https://api.github.com/repos/problame/node_exporter/issues/comments{/number}","contents_url":"https://api.github.com/repos/problame/node_exporter/contents/{+path}","compare_url":"https://api.github.com/repos/problame/node_exporter/compare/{base}...{head}","merges_url":"https://api.github.com/repos/problame/node_exporter/merges","archive_url":"https://api.github.com/repos/problame/node_exporter/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/problame/node_exporter/downloads","issues_url":"https://api.github.com/repos/problame/node_exporter/issues{/number}","pulls_url":"https://api.github.com/repos/problame/node_exporter/pulls{/number}","milestones_url":"https://api.github.com/repos/problame/node_exporter/milestones{/number}","notifications_url":"https://api.github.com/repos/problame/node_exporter/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/problame/node_exporter/labels{/name}","releases_url":"https://api.github.com/repos/problame/node_exporter/releases{/id}","deployments_url":"https://api.github.com/repos/problame/node_exporter/deployments","created_at":"2016-02-16T10:31:04Z","updated_at":"2016-02-16T10:31:06Z","pushed_at":"2016-03-16T22:48:06Z","git_url":"git://github.com/problame/node_exporter.git","ssh_url":"git@github.com:problame/node_exporter.git","clone_url":"https://github.com/problame/node_exporter.git","svn_url":"https://github.com/problame/node_exporter","homepage":"http://prometheus.io/","size":1187,"stargazers_count":0,"watchers_count":0,"language":"Go","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":"prometheus:master","ref":"master","sha":"bce2e0c51393be4fa8e96b3c2843623135ee4d0f","user":{"login":"prometheus","id":3380462,"avatar_url":"https://avatars.githubusercontent.com/u/3380462?v=3","gravatar_id":"","url":"https://api.github.com/users/prometheus","html_url":"https://github.com/prometheus","followers_url":"https://api.github.com/users/prometheus/followers","following_url":"https://api.github.com/users/prometheus/following{/other_user}","gists_url":"https://api.github.com/users/prometheus/gists{/gist_id}","starred_url":"https://api.github.com/users/prometheus/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/prometheus/subscriptions","organizations_url":"https://api.github.com/users/prometheus/orgs","repos_url":"https://api.github.com/users/prometheus/repos","events_url":"https://api.github.com/users/prometheus/events{/privacy}","received_events_url":"https://api.github.com/users/prometheus/received_events","type":"Organization","site_admin":false},"repo":{"id":9524057,"name":"node_exporter","full_name":"prometheus/node_exporter","owner":{"login":"prometheus","id":3380462,"avatar_url":"https://avatars.githubusercontent.com/u/3380462?v=3","gravatar_id":"","url":"https://api.github.com/users/prometheus","html_url":"https://github.com/prometheus","followers_url":"https://api.github.com/users/prometheus/followers","following_url":"https://api.github.com/users/prometheus/following{/other_user}","gists_url":"https://api.github.com/users/prometheus/gists{/gist_id}","starred_url":"https://api.github.com/users/prometheus/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/prometheus/subscriptions","organizations_url":"https://api.github.com/users/prometheus/orgs","repos_url":"https://api.github.com/users/prometheus/repos","events_url":"https://api.github.com/users/prometheus/events{/privacy}","received_events_url":"https://api.github.com/users/prometheus/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/prometheus/node_exporter","description":"Exporter for machine metrics","fork":false,"url":"https://api.github.com/repos/prometheus/node_exporter","forks_url":"https://api.github.com/repos/prometheus/node_exporter/forks","keys_url":"https://api.github.com/repos/prometheus/node_exporter/keys{/key_id}","collaborators_url":"https://api.github.com/repos/prometheus/node_exporter/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/prometheus/node_exporter/teams","hooks_url":"https://api.github.com/repos/prometheus/node_exporter/hooks","issue_events_url":"https://api.github.com/repos/prometheus/node_exporter/issues/events{/number}","events_url":"https://api.github.com/repos/prometheus/node_exporter/events","assignees_url":"https://api.github.com/repos/prometheus/node_exporter/assignees{/user}","branches_url":"https://api.github.com/repos/prometheus/node_exporter/branches{/branch}","tags_url":"https://api.github.com/repos/prometheus/node_exporter/tags","blobs_url":"https://api.github.com/repos/prometheus/node_exporter/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/prometheus/node_exporter/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/prometheus/node_exporter/git/refs{/sha}","trees_url":"https://api.github.com/repos/prometheus/node_exporter/git/trees{/sha}","statuses_url":"https://api.github.com/repos/prometheus/node_exporter/statuses/{sha}","languages_url":"https://api.github.com/repos/prometheus/node_exporter/languages","stargazers_url":"https://api.github.com/repos/prometheus/node_exporter/stargazers","contributors_url":"https://api.github.com/repos/prometheus/node_exporter/contributors","subscribers_url":"https://api.github.com/repos/prometheus/node_exporter/subscribers","subscription_url":"https://api.github.com/repos/prometheus/node_exporter/subscription","commits_url":"https://api.github.com/repos/prometheus/node_exporter/commits{/sha}","git_commits_url":"https://api.github.com/repos/prometheus/node_exporter/git/commits{/sha}","comments_url":"https://api.github.com/repos/prometheus/node_exporter/comments{/number}","issue_comment_url":"https://api.github.com/repos/prometheus/node_exporter/issues/comments{/number}","contents_url":"https://api.github.com/repos/prometheus/node_exporter/contents/{+path}","compare_url":"https://api.github.com/repos/prometheus/node_exporter/compare/{base}...{head}","merges_url":"https://api.github.com/repos/prometheus/node_exporter/merges","archive_url":"https://api.github.com/repos/prometheus/node_exporter/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/prometheus/node_exporter/downloads","issues_url":"https://api.github.com/repos/prometheus/node_exporter/issues{/number}","pulls_url":"https://api.github.com/repos/prometheus/node_exporter/pulls{/number}","milestones_url":"https://api.github.com/repos/prometheus/node_exporter/milestones{/number}","notifications_url":"https://api.github.com/repos/prometheus/node_exporter/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/prometheus/node_exporter/labels{/name}","releases_url":"https://api.github.com/repos/prometheus/node_exporter/releases{/id}","deployments_url":"https://api.github.com/repos/prometheus/node_exporter/deployments","created_at":"2013-04-18T14:44:52Z","updated_at":"2016-03-27T23:17:24Z","pushed_at":"2016-03-16T22:48:07Z","git_url":"git://github.com/prometheus/node_exporter.git","ssh_url":"git@github.com:prometheus/node_exporter.git","clone_url":"https://github.com/prometheus/node_exporter.git","svn_url":"https://github.com/prometheus/node_exporter","homepage":"http://prometheus.io/","size":1164,"stargazers_count":129,"watchers_count":129,"language":"Go","has_issues":true,"has_downloads":true,"has_wiki":false,"has_pages":false,"forks_count":83,"mirror_url":null,"open_issues_count":15,"forks":83,"open_issues":15,"watchers":129,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/prometheus/node_exporter/pulls/213"},"html":{"href":"https://github.com/prometheus/node_exporter/pull/213"},"issue":{"href":"https://api.github.com/repos/prometheus/node_exporter/issues/213"},"comments":{"href":"https://api.github.com/repos/prometheus/node_exporter/issues/213/comments"},"review_comments":{"href":"https://api.github.com/repos/prometheus/node_exporter/pulls/213/comments"},"review_comment":{"href":"https://api.github.com/repos/prometheus/node_exporter/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/prometheus/node_exporter/pulls/213/commits"},"statuses":{"href":"https://api.github.com/repos/prometheus/node_exporter/statuses/a102306835b0ee6397ae383e01a76ad35c2c8736"}}}}