{"action":"created","issue":{"url":"https://api.github.com/repos/c9s/goprocinfo/issues/28","labels_url":"https://api.github.com/repos/c9s/goprocinfo/issues/28/labels{/name}","comments_url":"https://api.github.com/repos/c9s/goprocinfo/issues/28/comments","events_url":"https://api.github.com/repos/c9s/goprocinfo/issues/28/events","html_url":"https://github.com/c9s/goprocinfo/issues/28","id":64290386,"number":28,"title":"Calculate cpu usage % of a process","user":{"login":"ghigt","id":2647865,"avatar_url":"https://avatars.githubusercontent.com/u/2647865?v=3","gravatar_id":"","url":"https://api.github.com/users/ghigt","html_url":"https://github.com/ghigt","followers_url":"https://api.github.com/users/ghigt/followers","following_url":"https://api.github.com/users/ghigt/following{/other_user}","gists_url":"https://api.github.com/users/ghigt/gists{/gist_id}","starred_url":"https://api.github.com/users/ghigt/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/ghigt/subscriptions","organizations_url":"https://api.github.com/users/ghigt/orgs","repos_url":"https://api.github.com/users/ghigt/repos","events_url":"https://api.github.com/users/ghigt/events{/privacy}","received_events_url":"https://api.github.com/users/ghigt/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":2,"created_at":"2015-03-25T14:55:51Z","updated_at":"2015-03-25T15:42:28Z","closed_at":null,"body":"Is there a more precise (better) way to do it than that?\r\n\r\n```go\r\npid, _ := strconv.ParseUint(os.Args[1], 10, 64)\r\n\r\nfor {\r\n\tp1, _ := linux.ReadProcess(pid, \"/proc\")\r\n\r\n\ttime.Sleep(time.Second)\r\n\r\n\tp2, _ := linux.ReadProcess(pid, \"/proc\")\r\n\r\n\tuser := int64(p2.Stat.Utime) + p2.Stat.Cutime - int64(p1.Stat.Utime) + p1.Stat.Cutime\r\n\tsyst := int64(p2.Stat.Stime) + p2.Stat.Cstime - int64(p1.Stat.Stime) + p1.Stat.Cstime\r\n\r\n\tfmt.Printf(\"%v: %v  \\r\", pid, user+syst)\r\n}\r\n```"},"comment":{"url":"https://api.github.com/repos/c9s/goprocinfo/issues/comments/86087545","html_url":"https://github.com/c9s/goprocinfo/issues/28#issuecomment-86087545","issue_url":"https://api.github.com/repos/c9s/goprocinfo/issues/28","id":86087545,"user":{"login":"ghigt","id":2647865,"avatar_url":"https://avatars.githubusercontent.com/u/2647865?v=3","gravatar_id":"","url":"https://api.github.com/users/ghigt","html_url":"https://github.com/ghigt","followers_url":"https://api.github.com/users/ghigt/followers","following_url":"https://api.github.com/users/ghigt/following{/other_user}","gists_url":"https://api.github.com/users/ghigt/gists{/gist_id}","starred_url":"https://api.github.com/users/ghigt/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/ghigt/subscriptions","organizations_url":"https://api.github.com/users/ghigt/orgs","repos_url":"https://api.github.com/users/ghigt/repos","events_url":"https://api.github.com/users/ghigt/events{/privacy}","received_events_url":"https://api.github.com/users/ghigt/received_events","type":"User","site_admin":false},"created_at":"2015-03-25T15:42:28Z","updated_at":"2015-03-25T15:42:28Z","body":"Thank you, I'll keep the keep yours :)"}}