{"action":"created","issue":{"url":"https://api.github.com/repos/jupyterhub/jupyterhub/issues/680","repository_url":"https://api.github.com/repos/jupyterhub/jupyterhub","labels_url":"https://api.github.com/repos/jupyterhub/jupyterhub/issues/680/labels{/name}","comments_url":"https://api.github.com/repos/jupyterhub/jupyterhub/issues/680/comments","events_url":"https://api.github.com/repos/jupyterhub/jupyterhub/issues/680/events","html_url":"https://github.com/jupyterhub/jupyterhub/issues/680","id":169383476,"number":680,"title":"Killing notebook after a particular timeout for each users","user":{"login":"dvigneshwer","id":5075497,"avatar_url":"https://avatars.githubusercontent.com/u/5075497?v=3","gravatar_id":"","url":"https://api.github.com/users/dvigneshwer","html_url":"https://github.com/dvigneshwer","followers_url":"https://api.github.com/users/dvigneshwer/followers","following_url":"https://api.github.com/users/dvigneshwer/following{/other_user}","gists_url":"https://api.github.com/users/dvigneshwer/gists{/gist_id}","starred_url":"https://api.github.com/users/dvigneshwer/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/dvigneshwer/subscriptions","organizations_url":"https://api.github.com/users/dvigneshwer/orgs","repos_url":"https://api.github.com/users/dvigneshwer/repos","events_url":"https://api.github.com/users/dvigneshwer/events{/privacy}","received_events_url":"https://api.github.com/users/dvigneshwer/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":2,"created_at":"2016-08-04T14:08:54Z","updated_at":"2016-08-05T11:22:44Z","closed_at":null,"body":"**Aim :** To kill or shutdown the idle notebooks after a particular time for each users\r\n\r\nThe cull service uses the api to get the user active and checks for a particular timeout in a for loop, is it possible to edit the script to get all the details of the running notebook and apply a particular time out for them.\r\n\r\nIn that case what is the api to get the running notebooks like we can see the running notebooks in the notebook server.\r\n\r\nLet me know if there is already any implementation available on this."},"comment":{"url":"https://api.github.com/repos/jupyterhub/jupyterhub/issues/comments/237826638","html_url":"https://github.com/jupyterhub/jupyterhub/issues/680#issuecomment-237826638","issue_url":"https://api.github.com/repos/jupyterhub/jupyterhub/issues/680","id":237826638,"user":{"login":"dvigneshwer","id":5075497,"avatar_url":"https://avatars.githubusercontent.com/u/5075497?v=3","gravatar_id":"","url":"https://api.github.com/users/dvigneshwer","html_url":"https://github.com/dvigneshwer","followers_url":"https://api.github.com/users/dvigneshwer/followers","following_url":"https://api.github.com/users/dvigneshwer/following{/other_user}","gists_url":"https://api.github.com/users/dvigneshwer/gists{/gist_id}","starred_url":"https://api.github.com/users/dvigneshwer/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/dvigneshwer/subscriptions","organizations_url":"https://api.github.com/users/dvigneshwer/orgs","repos_url":"https://api.github.com/users/dvigneshwer/repos","events_url":"https://api.github.com/users/dvigneshwer/events{/privacy}","received_events_url":"https://api.github.com/users/dvigneshwer/received_events","type":"User","site_admin":false},"created_at":"2016-08-05T11:22:44Z","updated_at":"2016-08-05T11:22:44Z","body":"@minrk I need little more details, let me brief you through what all I tried.\r\n\r\nI had used postman for checking the working of jupyterhub api,\r\n\r\nFrom the cull service python code,\r\n```\r\n\r\nauth_header = {\r\n            'Authorization': 'token %s' % api_token\r\n        }\r\n    req = HTTPRequest(url=url + '/api/users',\r\n        headers=auth_header,\r\n    )\r\n```\r\nBased on above code reference I tried,\r\n\r\nGenerated the jupyterhub token,\r\n![image](https://cloud.githubusercontent.com/assets/5075497/17434953/22789c82-5b2b-11e6-879d-57e03dd56fbc.png)\r\n\r\n`GET https://IP_ADDR:8000/api/users`\r\n\r\nGot the following response,\r\n```\r\n[\r\n  {\r\n    \"last_activity\": \"2016-08-05T11:01:38.125000\",\r\n    \"pending\": null,\r\n    \"name\": \"user1\",\r\n    \"server\": \"/user/user1\",\r\n    \"admin\": true\r\n  },\r\n  {\r\n    \"last_activity\": \"2016-08-04T13:57:56.468502\",\r\n    \"pending\": null,\r\n    \"name\": \"user2\",\r\n    \"server\": null,\r\n    \"admin\": false\r\n  },\r\n  {\r\n    \"last_activity\": \"2016-08-04T13:57:56.727200\",\r\n    \"pending\": null,\r\n    \"name\": \"user3\",\r\n    \"server\": null,\r\n    \"admin\": false\r\n  },\r\n  {\r\n    \"last_activity\": \"2016-08-04T13:57:55.905478\",\r\n    \"pending\": null,\r\n    \"name\": \"user4\",\r\n    \"server\": null,\r\n    \"admin\": true\r\n  }\r\n]\r\n```\r\n\r\nWhat will will be the api command for each user /api/sessions ?\r\n\r\nI tried and failed with,\r\n```\r\nhttps://IP_ADDR:8000/user/user1/tree/api/session\r\nhttps://IP_ADDR:8000/user/user1/api/session\r\n```\r\n\r\nAlgorithm for the code would be as follows,\r\n\r\nStep 1 : For each user\r\nStep 1.1 : Check for a new session and start timer \r\nStep 2 : If the timer exceeds a particular time out kill the notebook\r\n\r\nThis code must run in a while loop for ever and guess should use multi process lib to spawn multiple note book monitoring script for each users.\r\n\r\nLet me know your feedbacks.   \r\n\r\nThanks for the support and patience."}}
{"actor":{"display_login":"dvigneshwer"}}