{"action":"created","comment":{"url":"https://api.github.com/repos/librenms/librenms/pulls/comments/51558415","id":51558415,"diff_hunk":"@@ -1366,3 +1366,69 @@ function dnslookup($device,$type=false,$return=false) {\n     $record = dns_get_record($device['hostname'],$type);\n     return $record[0][$return];\n }//end dnslookup\n+\n+\n+/**\n+ * Reursive Filter Iterator to iterate directories and locate .rrd files.\n+ *\n+ * @method boolean isDir()\n+ *\n+**/\n+\n+class RRDRecursiveFilterIterator extends \\RecursiveFilterIterator {\n+\n+    public function accept() {\n+        $filename = $this->current()->getFilename();\n+        if ($filename[0] === '.') {\n+            // Ignore hidden files and directories\n+            return false;\n+        }\n+        if ($this->isDir()) {\n+            // We want to search into directories\n+            return true;\n+        }\n+        // Matches files with .rrd in the filename.\n+        // We are only searching rrd folder, but there could be other files and we don't want to cause a stink.\n+        return strpos($filename, '.rrd') !== false;\n+    }\n+}\n+\n+/**\n+ * Run rrdtool info on a file path\n+ *\n+ * @param string $path Path to pass to rrdtool info\n+ * @param string $stdOutput Variable to recieve the output of STDOUT\n+ * @param string $stdError Variable to recieve the output of STDERR\n+ *\n+ * @return int exit code\n+ *\n+**/\n+\n+function rrdtest($path, &$stdOutput, &$stdError) {\n+    global $config;\n+    //rrdtool info <escaped rrd path>\n+    $command = $config['rrdtool'].' info '.escapeshellarg($path);\n+    $process = proc_open(\n+        $command,\n+        array (\n+            0 => array('pipe', 'r'),\n+            1 => array('pipe', 'w'),\n+            2 => array('pipe', 'w'),\n+        ),\n+        $pipes\n+    );\n+\n+    if (!is_resource($process)) {\n+        throw new \\RuntimeException('Could not create a valid process');\n+    }\n+\n+    $status = proc_get_status($process);\n+    while($status['running']) {","path":"includes/functions.php","position":61,"original_position":61,"commit_id":"028b4300ba8c41ede3faadce7555a3f81c910f9f","original_commit_id":"f2bad9816b920dccf57b602a10d1a2fc5935d5ff","user":{"login":"khobbits","id":428811,"avatar_url":"https://avatars.githubusercontent.com/u/428811?v=3","gravatar_id":"","url":"https://api.github.com/users/khobbits","html_url":"https://github.com/khobbits","followers_url":"https://api.github.com/users/khobbits/followers","following_url":"https://api.github.com/users/khobbits/following{/other_user}","gists_url":"https://api.github.com/users/khobbits/gists{/gist_id}","starred_url":"https://api.github.com/users/khobbits/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/khobbits/subscriptions","organizations_url":"https://api.github.com/users/khobbits/orgs","repos_url":"https://api.github.com/users/khobbits/repos","events_url":"https://api.github.com/users/khobbits/events{/privacy}","received_events_url":"https://api.github.com/users/khobbits/received_events","type":"User","site_admin":false},"body":"Did a couple of benchmarks here:\r\nAnything below 2ms increases the cpu usage time without speeding up the process. \r\nAnything above 3ms increases run time without significantly decreasing cpu usage time.","created_at":"2016-02-02T11:52:48Z","updated_at":"2016-02-02T11:52:48Z","html_url":"https://github.com/librenms/librenms/pull/2908#discussion_r51558415","pull_request_url":"https://api.github.com/repos/librenms/librenms/pulls/2908","_links":{"self":{"href":"https://api.github.com/repos/librenms/librenms/pulls/comments/51558415"},"html":{"href":"https://github.com/librenms/librenms/pull/2908#discussion_r51558415"},"pull_request":{"href":"https://api.github.com/repos/librenms/librenms/pulls/2908"}}},"pull_request":{"url":"https://api.github.com/repos/librenms/librenms/pulls/2908","id":57922136,"html_url":"https://github.com/librenms/librenms/pull/2908","diff_url":"https://github.com/librenms/librenms/pull/2908.diff","patch_url":"https://github.com/librenms/librenms/pull/2908.patch","issue_url":"https://api.github.com/repos/librenms/librenms/issues/2908","number":2908,"state":"open","locked":false,"title":"Add ./validate.php -m rrdcheck","user":{"login":"khobbits","id":428811,"avatar_url":"https://avatars.githubusercontent.com/u/428811?v=3","gravatar_id":"","url":"https://api.github.com/users/khobbits","html_url":"https://github.com/khobbits","followers_url":"https://api.github.com/users/khobbits/followers","following_url":"https://api.github.com/users/khobbits/following{/other_user}","gists_url":"https://api.github.com/users/khobbits/gists{/gist_id}","starred_url":"https://api.github.com/users/khobbits/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/khobbits/subscriptions","organizations_url":"https://api.github.com/users/khobbits/orgs","repos_url":"https://api.github.com/users/khobbits/repos","events_url":"https://api.github.com/users/khobbits/events{/privacy}","received_events_url":"https://api.github.com/users/khobbits/received_events","type":"User","site_admin":false},"body":"This adds a little tool to list unreadable rrd files in your rrd folder.\r\n```\r\nScanning 9656 rrd files in /opt/librenms/rrd...\r\n[FAIL]    Error parsing \"/opt/librenms/rrd/nexus-c/port-5.rrd\" RRD ERROR: '/opt/librenms/rrd/nexus-c/port-5.rrd.old' is not an RRD file\r\n[FAIL]    Error parsing \"/opt/librenms/rrd/nexus-c/ucd_diskio-dm-1.rrd\" RRD ERROR: mmaping file '/opt/librenms/rrd/nexus-c/ucd_diskio-dm-1.rrd': Invalid argument\r\n[FAIL]    Error parsing \"/opt/librenms/rrd/nexus-c/ucd_diskio-dm-0.rrd\" RRD ERROR: mmaping file '/opt/librenms/rrd/nexus-c/ucd_diskio-dm-0.rrd': Invalid argument\r\nStatus: 9656/9656 - Complete\r\n```","created_at":"2016-02-02T00:17:44Z","updated_at":"2016-02-02T11:52:48Z","closed_at":null,"merged_at":null,"merge_commit_sha":"40e00795db52eebd0f7b67d3c836222df96e614d","assignee":null,"milestone":null,"commits_url":"https://api.github.com/repos/librenms/librenms/pulls/2908/commits","review_comments_url":"https://api.github.com/repos/librenms/librenms/pulls/2908/comments","review_comment_url":"https://api.github.com/repos/librenms/librenms/pulls/comments{/number}","comments_url":"https://api.github.com/repos/librenms/librenms/issues/2908/comments","statuses_url":"https://api.github.com/repos/librenms/librenms/statuses/028b4300ba8c41ede3faadce7555a3f81c910f9f","head":{"label":"khobbits:master","ref":"master","sha":"028b4300ba8c41ede3faadce7555a3f81c910f9f","user":{"login":"khobbits","id":428811,"avatar_url":"https://avatars.githubusercontent.com/u/428811?v=3","gravatar_id":"","url":"https://api.github.com/users/khobbits","html_url":"https://github.com/khobbits","followers_url":"https://api.github.com/users/khobbits/followers","following_url":"https://api.github.com/users/khobbits/following{/other_user}","gists_url":"https://api.github.com/users/khobbits/gists{/gist_id}","starred_url":"https://api.github.com/users/khobbits/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/khobbits/subscriptions","organizations_url":"https://api.github.com/users/khobbits/orgs","repos_url":"https://api.github.com/users/khobbits/repos","events_url":"https://api.github.com/users/khobbits/events{/privacy}","received_events_url":"https://api.github.com/users/khobbits/received_events","type":"User","site_admin":false},"repo":{"id":45480410,"name":"librenms","full_name":"khobbits/librenms","owner":{"login":"khobbits","id":428811,"avatar_url":"https://avatars.githubusercontent.com/u/428811?v=3","gravatar_id":"","url":"https://api.github.com/users/khobbits","html_url":"https://github.com/khobbits","followers_url":"https://api.github.com/users/khobbits/followers","following_url":"https://api.github.com/users/khobbits/following{/other_user}","gists_url":"https://api.github.com/users/khobbits/gists{/gist_id}","starred_url":"https://api.github.com/users/khobbits/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/khobbits/subscriptions","organizations_url":"https://api.github.com/users/khobbits/orgs","repos_url":"https://api.github.com/users/khobbits/repos","events_url":"https://api.github.com/users/khobbits/events{/privacy}","received_events_url":"https://api.github.com/users/khobbits/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/khobbits/librenms","description":"Community-based GPL-licensed network monitoring system","fork":true,"url":"https://api.github.com/repos/khobbits/librenms","forks_url":"https://api.github.com/repos/khobbits/librenms/forks","keys_url":"https://api.github.com/repos/khobbits/librenms/keys{/key_id}","collaborators_url":"https://api.github.com/repos/khobbits/librenms/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/khobbits/librenms/teams","hooks_url":"https://api.github.com/repos/khobbits/librenms/hooks","issue_events_url":"https://api.github.com/repos/khobbits/librenms/issues/events{/number}","events_url":"https://api.github.com/repos/khobbits/librenms/events","assignees_url":"https://api.github.com/repos/khobbits/librenms/assignees{/user}","branches_url":"https://api.github.com/repos/khobbits/librenms/branches{/branch}","tags_url":"https://api.github.com/repos/khobbits/librenms/tags","blobs_url":"https://api.github.com/repos/khobbits/librenms/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/khobbits/librenms/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/khobbits/librenms/git/refs{/sha}","trees_url":"https://api.github.com/repos/khobbits/librenms/git/trees{/sha}","statuses_url":"https://api.github.com/repos/khobbits/librenms/statuses/{sha}","languages_url":"https://api.github.com/repos/khobbits/librenms/languages","stargazers_url":"https://api.github.com/repos/khobbits/librenms/stargazers","contributors_url":"https://api.github.com/repos/khobbits/librenms/contributors","subscribers_url":"https://api.github.com/repos/khobbits/librenms/subscribers","subscription_url":"https://api.github.com/repos/khobbits/librenms/subscription","commits_url":"https://api.github.com/repos/khobbits/librenms/commits{/sha}","git_commits_url":"https://api.github.com/repos/khobbits/librenms/git/commits{/sha}","comments_url":"https://api.github.com/repos/khobbits/librenms/comments{/number}","issue_comment_url":"https://api.github.com/repos/khobbits/librenms/issues/comments{/number}","contents_url":"https://api.github.com/repos/khobbits/librenms/contents/{+path}","compare_url":"https://api.github.com/repos/khobbits/librenms/compare/{base}...{head}","merges_url":"https://api.github.com/repos/khobbits/librenms/merges","archive_url":"https://api.github.com/repos/khobbits/librenms/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/khobbits/librenms/downloads","issues_url":"https://api.github.com/repos/khobbits/librenms/issues{/number}","pulls_url":"https://api.github.com/repos/khobbits/librenms/pulls{/number}","milestones_url":"https://api.github.com/repos/khobbits/librenms/milestones{/number}","notifications_url":"https://api.github.com/repos/khobbits/librenms/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/khobbits/librenms/labels{/name}","releases_url":"https://api.github.com/repos/khobbits/librenms/releases{/id}","deployments_url":"https://api.github.com/repos/khobbits/librenms/deployments","created_at":"2015-11-03T16:41:59Z","updated_at":"2016-02-01T23:31:54Z","pushed_at":"2016-02-02T11:36:50Z","git_url":"git://github.com/khobbits/librenms.git","ssh_url":"git@github.com:khobbits/librenms.git","clone_url":"https://github.com/khobbits/librenms.git","svn_url":"https://github.com/khobbits/librenms","homepage":"http://www.librenms.org/","size":65501,"stargazers_count":0,"watchers_count":0,"language":"JavaScript","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":"librenms:master","ref":"master","sha":"cf55f4efd646456eac595d00af1069602bd1b156","user":{"login":"librenms","id":5791783,"avatar_url":"https://avatars.githubusercontent.com/u/5791783?v=3","gravatar_id":"","url":"https://api.github.com/users/librenms","html_url":"https://github.com/librenms","followers_url":"https://api.github.com/users/librenms/followers","following_url":"https://api.github.com/users/librenms/following{/other_user}","gists_url":"https://api.github.com/users/librenms/gists{/gist_id}","starred_url":"https://api.github.com/users/librenms/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/librenms/subscriptions","organizations_url":"https://api.github.com/users/librenms/orgs","repos_url":"https://api.github.com/users/librenms/repos","events_url":"https://api.github.com/users/librenms/events{/privacy}","received_events_url":"https://api.github.com/users/librenms/received_events","type":"Organization","site_admin":false},"repo":{"id":13914116,"name":"librenms","full_name":"librenms/librenms","owner":{"login":"librenms","id":5791783,"avatar_url":"https://avatars.githubusercontent.com/u/5791783?v=3","gravatar_id":"","url":"https://api.github.com/users/librenms","html_url":"https://github.com/librenms","followers_url":"https://api.github.com/users/librenms/followers","following_url":"https://api.github.com/users/librenms/following{/other_user}","gists_url":"https://api.github.com/users/librenms/gists{/gist_id}","starred_url":"https://api.github.com/users/librenms/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/librenms/subscriptions","organizations_url":"https://api.github.com/users/librenms/orgs","repos_url":"https://api.github.com/users/librenms/repos","events_url":"https://api.github.com/users/librenms/events{/privacy}","received_events_url":"https://api.github.com/users/librenms/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/librenms/librenms","description":"Community-based GPL-licensed network monitoring system","fork":false,"url":"https://api.github.com/repos/librenms/librenms","forks_url":"https://api.github.com/repos/librenms/librenms/forks","keys_url":"https://api.github.com/repos/librenms/librenms/keys{/key_id}","collaborators_url":"https://api.github.com/repos/librenms/librenms/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/librenms/librenms/teams","hooks_url":"https://api.github.com/repos/librenms/librenms/hooks","issue_events_url":"https://api.github.com/repos/librenms/librenms/issues/events{/number}","events_url":"https://api.github.com/repos/librenms/librenms/events","assignees_url":"https://api.github.com/repos/librenms/librenms/assignees{/user}","branches_url":"https://api.github.com/repos/librenms/librenms/branches{/branch}","tags_url":"https://api.github.com/repos/librenms/librenms/tags","blobs_url":"https://api.github.com/repos/librenms/librenms/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/librenms/librenms/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/librenms/librenms/git/refs{/sha}","trees_url":"https://api.github.com/repos/librenms/librenms/git/trees{/sha}","statuses_url":"https://api.github.com/repos/librenms/librenms/statuses/{sha}","languages_url":"https://api.github.com/repos/librenms/librenms/languages","stargazers_url":"https://api.github.com/repos/librenms/librenms/stargazers","contributors_url":"https://api.github.com/repos/librenms/librenms/contributors","subscribers_url":"https://api.github.com/repos/librenms/librenms/subscribers","subscription_url":"https://api.github.com/repos/librenms/librenms/subscription","commits_url":"https://api.github.com/repos/librenms/librenms/commits{/sha}","git_commits_url":"https://api.github.com/repos/librenms/librenms/git/commits{/sha}","comments_url":"https://api.github.com/repos/librenms/librenms/comments{/number}","issue_comment_url":"https://api.github.com/repos/librenms/librenms/issues/comments{/number}","contents_url":"https://api.github.com/repos/librenms/librenms/contents/{+path}","compare_url":"https://api.github.com/repos/librenms/librenms/compare/{base}...{head}","merges_url":"https://api.github.com/repos/librenms/librenms/merges","archive_url":"https://api.github.com/repos/librenms/librenms/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/librenms/librenms/downloads","issues_url":"https://api.github.com/repos/librenms/librenms/issues{/number}","pulls_url":"https://api.github.com/repos/librenms/librenms/pulls{/number}","milestones_url":"https://api.github.com/repos/librenms/librenms/milestones{/number}","notifications_url":"https://api.github.com/repos/librenms/librenms/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/librenms/librenms/labels{/name}","releases_url":"https://api.github.com/repos/librenms/librenms/releases{/id}","deployments_url":"https://api.github.com/repos/librenms/librenms/deployments","created_at":"2013-10-28T01:37:13Z","updated_at":"2016-02-02T06:43:43Z","pushed_at":"2016-02-02T11:39:10Z","git_url":"git://github.com/librenms/librenms.git","ssh_url":"git@github.com:librenms/librenms.git","clone_url":"https://github.com/librenms/librenms.git","svn_url":"https://github.com/librenms/librenms","homepage":"http://www.librenms.org/","size":88967,"stargazers_count":315,"watchers_count":315,"language":"JavaScript","has_issues":true,"has_downloads":true,"has_wiki":false,"has_pages":false,"forks_count":210,"mirror_url":null,"open_issues_count":274,"forks":210,"open_issues":274,"watchers":315,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/librenms/librenms/pulls/2908"},"html":{"href":"https://github.com/librenms/librenms/pull/2908"},"issue":{"href":"https://api.github.com/repos/librenms/librenms/issues/2908"},"comments":{"href":"https://api.github.com/repos/librenms/librenms/issues/2908/comments"},"review_comments":{"href":"https://api.github.com/repos/librenms/librenms/pulls/2908/comments"},"review_comment":{"href":"https://api.github.com/repos/librenms/librenms/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/librenms/librenms/pulls/2908/commits"},"statuses":{"href":"https://api.github.com/repos/librenms/librenms/statuses/028b4300ba8c41ede3faadce7555a3f81c910f9f"}}}}