{"action":"created","comment":{"url":"https://api.github.com/repos/apache/flink/pulls/comments/29744552","id":29744552,"diff_hunk":"@@ -1894,6 +1895,49 @@ object TaskManager {\n       override def getValue: Double =\n         ManagementFactory.getOperatingSystemMXBean().getSystemLoadAverage()\n     })\n+    \n+    // Preprocessing steps for registering cpuLoad\n+    // dummy initialisation\n+    var fetchCPULoad:(Any) => Double = (obj:Any) => -1\n+\n+    // define the fetchCPULoad method as per the fetched getProcessCpuLoad method\n+    getMethodToFetchCPULoad() match {\n+      case Some(method) => fetchCPULoad = (obj:Any) => method.asInstanceOf[Method].invoke(obj).\n+        asInstanceOf[Double]\n+      // Log getProcessCpuLoad method not available for Java 6\n+      case None => LOG.warn(\"getProcessCpuLoad method not available in the Operating System Bean\" +\n+        \"implementation for this Java runtime environment\\n\" + Thread.currentThread().getStackTrace)\n+    }\n+\n+    metricRegistry.register(\"cpuLoad\", new Gauge[Double] {\n+      override def getValue: Double = {\n+        try{\n+          val osMXBean = ManagementFactory.getOperatingSystemMXBean().\n+            asInstanceOf[com.sun.management.OperatingSystemMXBean]\n+          fetchCPULoad(osMXBean)\n+        } catch {\n+          case t: Throwable => {\n+            LOG.warn(\"Error retrieving CPU Load through OperatingSystemMXBean\", t)\n+            -1\n+          }\n+        }\n+      }\n+    })\n     metricRegistry\n   }\n+\n+  /**\n+   * Fetches getProcessCpuLoad method if available in the\n+   *  OperatingSystemMXBean implementation else returns None\n+   * @return\n+   */\n+  private def getMethodToFetchCPULoad(): Option[Method] = {\n+    val methodsList = classOf[com.sun.management.OperatingSystemMXBean].getMethods()\n+    val method = methodsList.filter(_.getName == \"getProcessCpuLoad\")","path":"flink-runtime/src/main/scala/org/apache/flink/runtime/taskmanager/TaskManager.scala","position":50,"original_position":50,"commit_id":"9e93b75047c7962f573659bcd11e997bba9f721f","original_commit_id":"9e93b75047c7962f573659bcd11e997bba9f721f","user":{"login":"tillrohrmann","id":5756858,"avatar_url":"https://avatars.githubusercontent.com/u/5756858?v=3","gravatar_id":"","url":"https://api.github.com/users/tillrohrmann","html_url":"https://github.com/tillrohrmann","followers_url":"https://api.github.com/users/tillrohrmann/followers","following_url":"https://api.github.com/users/tillrohrmann/following{/other_user}","gists_url":"https://api.github.com/users/tillrohrmann/gists{/gist_id}","starred_url":"https://api.github.com/users/tillrohrmann/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/tillrohrmann/subscriptions","organizations_url":"https://api.github.com/users/tillrohrmann/orgs","repos_url":"https://api.github.com/users/tillrohrmann/repos","events_url":"https://api.github.com/users/tillrohrmann/events{/privacy}","received_events_url":"https://api.github.com/users/tillrohrmann/received_events","type":"User","site_admin":false},"body":"Shortcut: use `headOption` to obtain result.","created_at":"2015-05-06T09:25:05Z","updated_at":"2015-05-06T09:25:05Z","html_url":"https://github.com/apache/flink/pull/553#discussion_r29744552","pull_request_url":"https://api.github.com/repos/apache/flink/pulls/553","_links":{"self":{"href":"https://api.github.com/repos/apache/flink/pulls/comments/29744552"},"html":{"href":"https://github.com/apache/flink/pull/553#discussion_r29744552"},"pull_request":{"href":"https://api.github.com/repos/apache/flink/pulls/553"}}},"pull_request":{"url":"https://api.github.com/repos/apache/flink/pulls/553","id":32371398,"html_url":"https://github.com/apache/flink/pull/553","diff_url":"https://github.com/apache/flink/pull/553.diff","patch_url":"https://github.com/apache/flink/pull/553.patch","issue_url":"https://api.github.com/repos/apache/flink/issues/553","number":553,"state":"open","locked":false,"title":"[FLINK-1792] TM Monitoring: CPU utilization, hide graphs by default and show summary only","user":{"login":"bhatsachin","id":4468933,"avatar_url":"https://avatars.githubusercontent.com/u/4468933?v=3","gravatar_id":"","url":"https://api.github.com/users/bhatsachin","html_url":"https://github.com/bhatsachin","followers_url":"https://api.github.com/users/bhatsachin/followers","following_url":"https://api.github.com/users/bhatsachin/following{/other_user}","gists_url":"https://api.github.com/users/bhatsachin/gists{/gist_id}","starred_url":"https://api.github.com/users/bhatsachin/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/bhatsachin/subscriptions","organizations_url":"https://api.github.com/users/bhatsachin/orgs","repos_url":"https://api.github.com/users/bhatsachin/repos","events_url":"https://api.github.com/users/bhatsachin/events{/privacy}","received_events_url":"https://api.github.com/users/bhatsachin/received_events","type":"User","site_admin":false},"body":"Added CPU Load % using another implementation of the OperatingSystemMXBean (https://docs.oracle.com/javase/7/docs/jre/api/management/extension/com/sun/management/OperatingSystemMXBean.html) and its method getProcessCpuLoad(). \r\nAdded show/hide button for detailed graph and summary for the metrics. Currently, the summary is being generated for the previous 10 minutes by default.  ","created_at":"2015-03-31T22:12:02Z","updated_at":"2015-05-06T09:25:05Z","closed_at":null,"merged_at":null,"merge_commit_sha":"bea4b5d570b9c3fb30fe725fb55a8f6590286e4e","assignee":null,"milestone":null,"commits_url":"https://api.github.com/repos/apache/flink/pulls/553/commits","review_comments_url":"https://api.github.com/repos/apache/flink/pulls/553/comments","review_comment_url":"https://api.github.com/repos/apache/flink/pulls/comments{/number}","comments_url":"https://api.github.com/repos/apache/flink/issues/553/comments","statuses_url":"https://api.github.com/repos/apache/flink/statuses/9e93b75047c7962f573659bcd11e997bba9f721f","head":{"label":"bhatsachin:dev-bhatsachin-flink-1792","ref":"dev-bhatsachin-flink-1792","sha":"9e93b75047c7962f573659bcd11e997bba9f721f","user":{"login":"bhatsachin","id":4468933,"avatar_url":"https://avatars.githubusercontent.com/u/4468933?v=3","gravatar_id":"","url":"https://api.github.com/users/bhatsachin","html_url":"https://github.com/bhatsachin","followers_url":"https://api.github.com/users/bhatsachin/followers","following_url":"https://api.github.com/users/bhatsachin/following{/other_user}","gists_url":"https://api.github.com/users/bhatsachin/gists{/gist_id}","starred_url":"https://api.github.com/users/bhatsachin/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/bhatsachin/subscriptions","organizations_url":"https://api.github.com/users/bhatsachin/orgs","repos_url":"https://api.github.com/users/bhatsachin/repos","events_url":"https://api.github.com/users/bhatsachin/events{/privacy}","received_events_url":"https://api.github.com/users/bhatsachin/received_events","type":"User","site_admin":false},"repo":{"id":32088063,"name":"flink","full_name":"bhatsachin/flink","owner":{"login":"bhatsachin","id":4468933,"avatar_url":"https://avatars.githubusercontent.com/u/4468933?v=3","gravatar_id":"","url":"https://api.github.com/users/bhatsachin","html_url":"https://github.com/bhatsachin","followers_url":"https://api.github.com/users/bhatsachin/followers","following_url":"https://api.github.com/users/bhatsachin/following{/other_user}","gists_url":"https://api.github.com/users/bhatsachin/gists{/gist_id}","starred_url":"https://api.github.com/users/bhatsachin/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/bhatsachin/subscriptions","organizations_url":"https://api.github.com/users/bhatsachin/orgs","repos_url":"https://api.github.com/users/bhatsachin/repos","events_url":"https://api.github.com/users/bhatsachin/events{/privacy}","received_events_url":"https://api.github.com/users/bhatsachin/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/bhatsachin/flink","description":"Mirror of Apache Flink","fork":true,"url":"https://api.github.com/repos/bhatsachin/flink","forks_url":"https://api.github.com/repos/bhatsachin/flink/forks","keys_url":"https://api.github.com/repos/bhatsachin/flink/keys{/key_id}","collaborators_url":"https://api.github.com/repos/bhatsachin/flink/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/bhatsachin/flink/teams","hooks_url":"https://api.github.com/repos/bhatsachin/flink/hooks","issue_events_url":"https://api.github.com/repos/bhatsachin/flink/issues/events{/number}","events_url":"https://api.github.com/repos/bhatsachin/flink/events","assignees_url":"https://api.github.com/repos/bhatsachin/flink/assignees{/user}","branches_url":"https://api.github.com/repos/bhatsachin/flink/branches{/branch}","tags_url":"https://api.github.com/repos/bhatsachin/flink/tags","blobs_url":"https://api.github.com/repos/bhatsachin/flink/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/bhatsachin/flink/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/bhatsachin/flink/git/refs{/sha}","trees_url":"https://api.github.com/repos/bhatsachin/flink/git/trees{/sha}","statuses_url":"https://api.github.com/repos/bhatsachin/flink/statuses/{sha}","languages_url":"https://api.github.com/repos/bhatsachin/flink/languages","stargazers_url":"https://api.github.com/repos/bhatsachin/flink/stargazers","contributors_url":"https://api.github.com/repos/bhatsachin/flink/contributors","subscribers_url":"https://api.github.com/repos/bhatsachin/flink/subscribers","subscription_url":"https://api.github.com/repos/bhatsachin/flink/subscription","commits_url":"https://api.github.com/repos/bhatsachin/flink/commits{/sha}","git_commits_url":"https://api.github.com/repos/bhatsachin/flink/git/commits{/sha}","comments_url":"https://api.github.com/repos/bhatsachin/flink/comments{/number}","issue_comment_url":"https://api.github.com/repos/bhatsachin/flink/issues/comments{/number}","contents_url":"https://api.github.com/repos/bhatsachin/flink/contents/{+path}","compare_url":"https://api.github.com/repos/bhatsachin/flink/compare/{base}...{head}","merges_url":"https://api.github.com/repos/bhatsachin/flink/merges","archive_url":"https://api.github.com/repos/bhatsachin/flink/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/bhatsachin/flink/downloads","issues_url":"https://api.github.com/repos/bhatsachin/flink/issues{/number}","pulls_url":"https://api.github.com/repos/bhatsachin/flink/pulls{/number}","milestones_url":"https://api.github.com/repos/bhatsachin/flink/milestones{/number}","notifications_url":"https://api.github.com/repos/bhatsachin/flink/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/bhatsachin/flink/labels{/name}","releases_url":"https://api.github.com/repos/bhatsachin/flink/releases{/id}","created_at":"2015-03-12T16:31:59Z","updated_at":"2015-03-12T16:32:08Z","pushed_at":"2015-05-05T15:56:57Z","git_url":"git://github.com/bhatsachin/flink.git","ssh_url":"git@github.com:bhatsachin/flink.git","clone_url":"https://github.com/bhatsachin/flink.git","svn_url":"https://github.com/bhatsachin/flink","homepage":null,"size":47348,"stargazers_count":0,"watchers_count":0,"language":"Java","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":"apache:master","ref":"master","sha":"ae867efd3246a4eac636cb5d5c86e59b96e3040a","user":{"login":"apache","id":47359,"avatar_url":"https://avatars.githubusercontent.com/u/47359?v=3","gravatar_id":"","url":"https://api.github.com/users/apache","html_url":"https://github.com/apache","followers_url":"https://api.github.com/users/apache/followers","following_url":"https://api.github.com/users/apache/following{/other_user}","gists_url":"https://api.github.com/users/apache/gists{/gist_id}","starred_url":"https://api.github.com/users/apache/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/apache/subscriptions","organizations_url":"https://api.github.com/users/apache/orgs","repos_url":"https://api.github.com/users/apache/repos","events_url":"https://api.github.com/users/apache/events{/privacy}","received_events_url":"https://api.github.com/users/apache/received_events","type":"Organization","site_admin":false},"repo":{"id":20587599,"name":"flink","full_name":"apache/flink","owner":{"login":"apache","id":47359,"avatar_url":"https://avatars.githubusercontent.com/u/47359?v=3","gravatar_id":"","url":"https://api.github.com/users/apache","html_url":"https://github.com/apache","followers_url":"https://api.github.com/users/apache/followers","following_url":"https://api.github.com/users/apache/following{/other_user}","gists_url":"https://api.github.com/users/apache/gists{/gist_id}","starred_url":"https://api.github.com/users/apache/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/apache/subscriptions","organizations_url":"https://api.github.com/users/apache/orgs","repos_url":"https://api.github.com/users/apache/repos","events_url":"https://api.github.com/users/apache/events{/privacy}","received_events_url":"https://api.github.com/users/apache/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/apache/flink","description":"Mirror of Apache Flink","fork":false,"url":"https://api.github.com/repos/apache/flink","forks_url":"https://api.github.com/repos/apache/flink/forks","keys_url":"https://api.github.com/repos/apache/flink/keys{/key_id}","collaborators_url":"https://api.github.com/repos/apache/flink/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/apache/flink/teams","hooks_url":"https://api.github.com/repos/apache/flink/hooks","issue_events_url":"https://api.github.com/repos/apache/flink/issues/events{/number}","events_url":"https://api.github.com/repos/apache/flink/events","assignees_url":"https://api.github.com/repos/apache/flink/assignees{/user}","branches_url":"https://api.github.com/repos/apache/flink/branches{/branch}","tags_url":"https://api.github.com/repos/apache/flink/tags","blobs_url":"https://api.github.com/repos/apache/flink/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/apache/flink/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/apache/flink/git/refs{/sha}","trees_url":"https://api.github.com/repos/apache/flink/git/trees{/sha}","statuses_url":"https://api.github.com/repos/apache/flink/statuses/{sha}","languages_url":"https://api.github.com/repos/apache/flink/languages","stargazers_url":"https://api.github.com/repos/apache/flink/stargazers","contributors_url":"https://api.github.com/repos/apache/flink/contributors","subscribers_url":"https://api.github.com/repos/apache/flink/subscribers","subscription_url":"https://api.github.com/repos/apache/flink/subscription","commits_url":"https://api.github.com/repos/apache/flink/commits{/sha}","git_commits_url":"https://api.github.com/repos/apache/flink/git/commits{/sha}","comments_url":"https://api.github.com/repos/apache/flink/comments{/number}","issue_comment_url":"https://api.github.com/repos/apache/flink/issues/comments{/number}","contents_url":"https://api.github.com/repos/apache/flink/contents/{+path}","compare_url":"https://api.github.com/repos/apache/flink/compare/{base}...{head}","merges_url":"https://api.github.com/repos/apache/flink/merges","archive_url":"https://api.github.com/repos/apache/flink/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/apache/flink/downloads","issues_url":"https://api.github.com/repos/apache/flink/issues{/number}","pulls_url":"https://api.github.com/repos/apache/flink/pulls{/number}","milestones_url":"https://api.github.com/repos/apache/flink/milestones{/number}","notifications_url":"https://api.github.com/repos/apache/flink/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/apache/flink/labels{/name}","releases_url":"https://api.github.com/repos/apache/flink/releases{/id}","created_at":"2014-06-07T07:00:10Z","updated_at":"2015-05-06T03:34:30Z","pushed_at":"2015-05-05T21:03:56Z","git_url":"git://github.com/apache/flink.git","ssh_url":"git@github.com:apache/flink.git","clone_url":"https://github.com/apache/flink.git","svn_url":"https://github.com/apache/flink","homepage":null,"size":3089501,"stargazers_count":383,"watchers_count":383,"language":"Java","has_issues":false,"has_downloads":true,"has_wiki":false,"has_pages":false,"forks_count":233,"mirror_url":"git://git.apache.org/incubator-flink.git","open_issues_count":41,"forks":233,"open_issues":41,"watchers":383,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/apache/flink/pulls/553"},"html":{"href":"https://github.com/apache/flink/pull/553"},"issue":{"href":"https://api.github.com/repos/apache/flink/issues/553"},"comments":{"href":"https://api.github.com/repos/apache/flink/issues/553/comments"},"review_comments":{"href":"https://api.github.com/repos/apache/flink/pulls/553/comments"},"review_comment":{"href":"https://api.github.com/repos/apache/flink/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/apache/flink/pulls/553/commits"},"statuses":{"href":"https://api.github.com/repos/apache/flink/statuses/9e93b75047c7962f573659bcd11e997bba9f721f"}}}}