{"action":"created","comment":{"url":"https://api.github.com/repos/prometheus/node_exporter/pulls/comments/34409409","id":34409409,"diff_hunk":"@@ -0,0 +1,239 @@\n+// +build !nodiskstats\n+\n+package collector\n+\n+import (\n+\t\"errors\"\n+\t\"fmt\"\n+\n+\t\"github.com/prometheus/client_golang/prometheus\"\n+)\n+\n+/*\n+#cgo LDFLAGS: -ldevstat -lkvm\n+#include <devstat.h>\n+#include <fcntl.h>\n+#include <libgeom.h>\n+#include <limits.h>\n+#include <stdio.h>\n+#include <stdlib.h>\n+#include <string.h>\n+\n+typedef struct {\n+\tuint64_t\tread;\n+\tuint64_t\twrite;\n+\tuint64_t\tfree;\n+} Bytes;\n+\n+typedef struct {\n+\tuint64_t\tother;\n+\tuint64_t\tread;\n+\tuint64_t\twrite;\n+\tuint64_t\tfree;\n+} Transfers;\n+\n+typedef struct {\n+\tdouble\t\tother;\n+\tdouble\t\tread;\n+\tdouble\t\twrite;\n+\tdouble\t\tfree;\n+} Duration;\n+\n+typedef struct {\n+\tchar\t\tdevice[DEVSTAT_NAME_LEN];\n+\tint\t\tunit;\n+\tBytes\t\tbytes;\n+\tTransfers\ttransfers;\n+\tDuration\tduration;\n+\tlong\t\tbusyTime;\n+\tuint64_t\tblocks;\n+} Stats;\n+\n+int _get_ndevs() {\n+\tstruct statinfo current;\n+\tint num_devices;\n+\n+\tcurrent.dinfo = (struct devinfo *)calloc(1, sizeof(struct devinfo));\n+\tif (current.dinfo == NULL)\n+\t\treturn -2;\n+\n+\tdevstat_checkversion(NULL);\n+\n+\tif (devstat_getdevs(NULL, &current) == -1)\n+\t\treturn -1;\n+\n+\treturn current.dinfo->numdevs;\n+}\n+\n+Stats _get_stats(int i) {\n+\tstruct statinfo current;\n+\tint num_devices;\n+\n+\tcurrent.dinfo = (struct devinfo *)calloc(1, sizeof(struct devinfo));\n+\tdevstat_getdevs(NULL, &current);\n+\n+\tnum_devices = current.dinfo->numdevs;\n+\tStats stats;\n+\tuint64_t bytes_read, bytes_write, bytes_free;\n+\tuint64_t transfers_other, transfers_read, transfers_write, transfers_free;\n+\tlong double duration_other, duration_read, duration_write, duration_free;\n+\tlong double busy_time;\n+\tuint64_t blocks;\n+\n+\tstrcpy(stats.device, current.dinfo->devices[i].device_name);\n+\tstats.unit = current.dinfo->devices[i].unit_number;\n+\tdevstat_compute_statistics(&current.dinfo->devices[i],\n+\t\tNULL,\n+\t\t1.0,\n+\t\tDSM_TOTAL_BYTES_READ, &bytes_read,\n+\t\tDSM_TOTAL_BYTES_WRITE, &bytes_write,\n+\t\tDSM_TOTAL_BYTES_FREE, &bytes_free,\n+\t\tDSM_TOTAL_TRANSFERS_OTHER, &transfers_other,\n+\t\tDSM_TOTAL_TRANSFERS_READ, &transfers_read,\n+\t\tDSM_TOTAL_TRANSFERS_WRITE, &transfers_write,\n+\t\tDSM_TOTAL_TRANSFERS_FREE, &transfers_free,\n+\t\tDSM_TOTAL_DURATION_OTHER, &duration_other,\n+\t\tDSM_TOTAL_DURATION_READ, &duration_read,\n+\t\tDSM_TOTAL_DURATION_WRITE, &duration_write,\n+\t\tDSM_TOTAL_DURATION_FREE, &duration_free,\n+\t\tDSM_TOTAL_BUSY_TIME, &busy_time,\n+\t\tDSM_TOTAL_BLOCKS, &blocks,\n+\t\tDSM_NONE);\n+\n+\tstats.bytes.read = bytes_read;\n+\tstats.bytes.write = bytes_write;\n+\tstats.bytes.free = bytes_free;\n+\tstats.transfers.other = transfers_other;\n+\tstats.transfers.read = transfers_read;\n+\tstats.transfers.write = transfers_write;\n+\tstats.transfers.free = transfers_free;\n+\tstats.duration.other = duration_other;\n+\tstats.duration.read = duration_read;\n+\tstats.duration.write = duration_write;\n+\tstats.duration.free = duration_free;\n+\tstats.busyTime = busy_time;\n+\tstats.blocks = blocks;\n+\n+\treturn stats;\n+}\n+*/\n+import \"C\"\n+\n+const (\n+\tdevstatSubsystem = \"devstat\"\n+)\n+\n+type devstatCollector struct {\n+\tbytes     *prometheus.GaugeVec\n+\ttransfers *prometheus.GaugeVec\n+\tduration  *prometheus.GaugeVec\n+\tbusyTime  *prometheus.GaugeVec\n+\tblocks    *prometheus.GaugeVec\n+}\n+\n+func init() {\n+\tFactories[\"devstat\"] = NewDevstatCollector\n+}\n+\n+// device stats.\n+func NewDevstatCollector() (Collector, error) {\n+\t//var diskLabelNames = []string{\"device\"}\n+\t//var ioType = []string{\"type\"}\n+\n+\treturn &devstatCollector{\n+\t\t// Docs from https://www.kernel.org/doc/Documentation/iostats.txt\n+\t\tbytes: prometheus.NewGaugeVec(","path":"collector/devstat_freebsd.go","position":145,"original_position":145,"commit_id":"ba8b756898f32c0de8690626e956dce047356dee","original_commit_id":"a044aaee3110714f2e8aedbc5765d48ee3ddb4b2","user":{"login":"juliusv","id":538008,"avatar_url":"https://avatars.githubusercontent.com/u/538008?v=3","gravatar_id":"","url":"https://api.github.com/users/juliusv","html_url":"https://github.com/juliusv","followers_url":"https://api.github.com/users/juliusv/followers","following_url":"https://api.github.com/users/juliusv/following{/other_user}","gists_url":"https://api.github.com/users/juliusv/gists{/gist_id}","starred_url":"https://api.github.com/users/juliusv/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/juliusv/subscriptions","organizations_url":"https://api.github.com/users/juliusv/orgs","repos_url":"https://api.github.com/users/juliusv/repos","events_url":"https://api.github.com/users/juliusv/events{/privacy}","received_events_url":"https://api.github.com/users/juliusv/received_events","type":"User","site_admin":false},"body":"Hmm yes, it reads like that. I still don't really get what \"free\" means as a counter in the context of device transactions though? Do you? :)","created_at":"2015-07-11T04:02:18Z","updated_at":"2015-07-11T04:02:18Z","html_url":"https://github.com/prometheus/node_exporter/pull/88#discussion_r34409409","pull_request_url":"https://api.github.com/repos/prometheus/node_exporter/pulls/88","_links":{"self":{"href":"https://api.github.com/repos/prometheus/node_exporter/pulls/comments/34409409"},"html":{"href":"https://github.com/prometheus/node_exporter/pull/88#discussion_r34409409"},"pull_request":{"href":"https://api.github.com/repos/prometheus/node_exporter/pulls/88"}}},"pull_request":{"url":"https://api.github.com/repos/prometheus/node_exporter/pulls/88","id":38340915,"html_url":"https://github.com/prometheus/node_exporter/pull/88","diff_url":"https://github.com/prometheus/node_exporter/pull/88.diff","patch_url":"https://github.com/prometheus/node_exporter/pull/88.patch","issue_url":"https://api.github.com/repos/prometheus/node_exporter/issues/88","number":88,"state":"open","locked":false,"title":"Add support for FreeBSD","user":{"login":"siavashs","id":113189,"avatar_url":"https://avatars.githubusercontent.com/u/113189?v=3","gravatar_id":"","url":"https://api.github.com/users/siavashs","html_url":"https://github.com/siavashs","followers_url":"https://api.github.com/users/siavashs/followers","following_url":"https://api.github.com/users/siavashs/following{/other_user}","gists_url":"https://api.github.com/users/siavashs/gists{/gist_id}","starred_url":"https://api.github.com/users/siavashs/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/siavashs/subscriptions","organizations_url":"https://api.github.com/users/siavashs/orgs","repos_url":"https://api.github.com/users/siavashs/repos","events_url":"https://api.github.com/users/siavashs/events{/privacy}","received_events_url":"https://api.github.com/users/siavashs/received_events","type":"User","site_admin":false},"body":"This PR adds support for FreeBSD and build constraints.\r\nThere are 3 group of collectors now: general, linux and freebsd.\r\n\r\nNote: In order to build and test on FreeBSD one would need go and gmake packages:\r\n```\r\n# pkg install go gmake\r\n# cd node_exporter\r\n# gmake\r\n```","created_at":"2015-06-23T14:13:46Z","updated_at":"2015-07-11T04:02:18Z","closed_at":null,"merged_at":null,"merge_commit_sha":"e046a41ff51b833bf34f665ff7de03b1f18bc1b8","assignee":null,"milestone":null,"commits_url":"https://api.github.com/repos/prometheus/node_exporter/pulls/88/commits","review_comments_url":"https://api.github.com/repos/prometheus/node_exporter/pulls/88/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/88/comments","statuses_url":"https://api.github.com/repos/prometheus/node_exporter/statuses/ba8b756898f32c0de8690626e956dce047356dee","head":{"label":"siavashs:freebsd","ref":"freebsd","sha":"ba8b756898f32c0de8690626e956dce047356dee","user":{"login":"siavashs","id":113189,"avatar_url":"https://avatars.githubusercontent.com/u/113189?v=3","gravatar_id":"","url":"https://api.github.com/users/siavashs","html_url":"https://github.com/siavashs","followers_url":"https://api.github.com/users/siavashs/followers","following_url":"https://api.github.com/users/siavashs/following{/other_user}","gists_url":"https://api.github.com/users/siavashs/gists{/gist_id}","starred_url":"https://api.github.com/users/siavashs/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/siavashs/subscriptions","organizations_url":"https://api.github.com/users/siavashs/orgs","repos_url":"https://api.github.com/users/siavashs/repos","events_url":"https://api.github.com/users/siavashs/events{/privacy}","received_events_url":"https://api.github.com/users/siavashs/received_events","type":"User","site_admin":false},"repo":{"id":35420511,"name":"node_exporter","full_name":"siavashs/node_exporter","owner":{"login":"siavashs","id":113189,"avatar_url":"https://avatars.githubusercontent.com/u/113189?v=3","gravatar_id":"","url":"https://api.github.com/users/siavashs","html_url":"https://github.com/siavashs","followers_url":"https://api.github.com/users/siavashs/followers","following_url":"https://api.github.com/users/siavashs/following{/other_user}","gists_url":"https://api.github.com/users/siavashs/gists{/gist_id}","starred_url":"https://api.github.com/users/siavashs/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/siavashs/subscriptions","organizations_url":"https://api.github.com/users/siavashs/orgs","repos_url":"https://api.github.com/users/siavashs/repos","events_url":"https://api.github.com/users/siavashs/events{/privacy}","received_events_url":"https://api.github.com/users/siavashs/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/siavashs/node_exporter","description":"Exporter for machine metrics","fork":true,"url":"https://api.github.com/repos/siavashs/node_exporter","forks_url":"https://api.github.com/repos/siavashs/node_exporter/forks","keys_url":"https://api.github.com/repos/siavashs/node_exporter/keys{/key_id}","collaborators_url":"https://api.github.com/repos/siavashs/node_exporter/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/siavashs/node_exporter/teams","hooks_url":"https://api.github.com/repos/siavashs/node_exporter/hooks","issue_events_url":"https://api.github.com/repos/siavashs/node_exporter/issues/events{/number}","events_url":"https://api.github.com/repos/siavashs/node_exporter/events","assignees_url":"https://api.github.com/repos/siavashs/node_exporter/assignees{/user}","branches_url":"https://api.github.com/repos/siavashs/node_exporter/branches{/branch}","tags_url":"https://api.github.com/repos/siavashs/node_exporter/tags","blobs_url":"https://api.github.com/repos/siavashs/node_exporter/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/siavashs/node_exporter/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/siavashs/node_exporter/git/refs{/sha}","trees_url":"https://api.github.com/repos/siavashs/node_exporter/git/trees{/sha}","statuses_url":"https://api.github.com/repos/siavashs/node_exporter/statuses/{sha}","languages_url":"https://api.github.com/repos/siavashs/node_exporter/languages","stargazers_url":"https://api.github.com/repos/siavashs/node_exporter/stargazers","contributors_url":"https://api.github.com/repos/siavashs/node_exporter/contributors","subscribers_url":"https://api.github.com/repos/siavashs/node_exporter/subscribers","subscription_url":"https://api.github.com/repos/siavashs/node_exporter/subscription","commits_url":"https://api.github.com/repos/siavashs/node_exporter/commits{/sha}","git_commits_url":"https://api.github.com/repos/siavashs/node_exporter/git/commits{/sha}","comments_url":"https://api.github.com/repos/siavashs/node_exporter/comments{/number}","issue_comment_url":"https://api.github.com/repos/siavashs/node_exporter/issues/comments{/number}","contents_url":"https://api.github.com/repos/siavashs/node_exporter/contents/{+path}","compare_url":"https://api.github.com/repos/siavashs/node_exporter/compare/{base}...{head}","merges_url":"https://api.github.com/repos/siavashs/node_exporter/merges","archive_url":"https://api.github.com/repos/siavashs/node_exporter/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/siavashs/node_exporter/downloads","issues_url":"https://api.github.com/repos/siavashs/node_exporter/issues{/number}","pulls_url":"https://api.github.com/repos/siavashs/node_exporter/pulls{/number}","milestones_url":"https://api.github.com/repos/siavashs/node_exporter/milestones{/number}","notifications_url":"https://api.github.com/repos/siavashs/node_exporter/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/siavashs/node_exporter/labels{/name}","releases_url":"https://api.github.com/repos/siavashs/node_exporter/releases{/id}","created_at":"2015-05-11T11:44:32Z","updated_at":"2015-05-11T11:44:33Z","pushed_at":"2015-06-24T12:45:51Z","git_url":"git://github.com/siavashs/node_exporter.git","ssh_url":"git@github.com:siavashs/node_exporter.git","clone_url":"https://github.com/siavashs/node_exporter.git","svn_url":"https://github.com/siavashs/node_exporter","homepage":"http://prometheus.io/","size":352,"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":"a9f5316bb3cb7b90a6f9214109cc66aa3e98b813","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}","created_at":"2013-04-18T14:44:52Z","updated_at":"2015-07-08T21:56:42Z","pushed_at":"2015-07-10T08:57:13Z","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":2896,"stargazers_count":45,"watchers_count":45,"language":"Go","has_issues":true,"has_downloads":true,"has_wiki":false,"has_pages":false,"forks_count":24,"mirror_url":null,"open_issues_count":15,"forks":24,"open_issues":15,"watchers":45,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/prometheus/node_exporter/pulls/88"},"html":{"href":"https://github.com/prometheus/node_exporter/pull/88"},"issue":{"href":"https://api.github.com/repos/prometheus/node_exporter/issues/88"},"comments":{"href":"https://api.github.com/repos/prometheus/node_exporter/issues/88/comments"},"review_comments":{"href":"https://api.github.com/repos/prometheus/node_exporter/pulls/88/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/88/commits"},"statuses":{"href":"https://api.github.com/repos/prometheus/node_exporter/statuses/ba8b756898f32c0de8690626e956dce047356dee"}}}}