\n\n# megaclite\n## Resource Manager for JupyterHub, also a moon.\n\n[](https://github.com/alivcor/segraph)\n[](https://github.com/alivcor/segraph)\n[](https://travis-ci.org/alivcor/megaclite)\n\n
\n\n
\n\n\nMegaclite provides monitoring, auditing & management for JupyterHub.\n\n:octocat: Link to GitHub Repo\n\n## Getting Started\n\nMegaclite provides the following functionalities:\n\n- A small label in the toolbar to display memory utilization (summed across all notebooks) on client side\n- Warning pop-up when user exhausts 75% of his/her memory limit on client-side.\n- Alert pop-up when user crosses his/her memory limit on client-side.\n- Kills kernel/session when user surpasses the limits.\n- Auditing on server-side.\n\nMake sure you have sudospawner up and running.\n\n### Prerequisites\n\nYou will need to have Sudospawner installed on your system. The megaclite extension was built with Python 3.6, and it is NOT made for Python 2.7, so is JupyterHub.\n\n```\npip install megaclite\n```\n\n### Installation\n\nThere are multiple ways to install megaclite on your system:\n\n#### Python Package Index\n\nmegaclite is now available at https://pypi.python.org/pypi/megaclite/0.1\n\n\n\n```\n1. Download the tar/zip from https://pypi.python.org/pypi/megaclite/0.1\n2. Move the package to your desired location / python version, and unzip the archive.\nOptionally, if you have a linux-based machine (Ubuntu/OSX):\n tar xvzf megaclite-0.x.tar.gz -C /path/to/desireddirectory\n3. Migrate to the megaclite folder, and run\n python setup.py install\n```\n\n#### Using pip\n\n```\npip install megaclite\n```\n\nTo upgrade,\n\n```\npip install --upgrade megaclite\n```\n\n\n## Using megaclite\n\nmegaclite bouples BEST with Sudospawner. You need a JupyterHub API Token to use megaclite.\n\n## Create an API token\n\nTo send requests using JupyterHub API, you must pass an API token with\nthe request.\n\nAs of version 0.6.0, the preferred way of\ngenerating an API token is:\n\n```bash\nopenssl rand -hex 32\n```\n\nThis `openssl` command generates a potential token that can then be\nadded to JupyterHub using `.api_tokens` configuration setting in\n`jupyterhub_config.py`.\n\nAlternatively, use the `jupyterhub token` command to generate a token\nfor a specific hub user by passing the 'username':\n\n```bash\njupyterhub token \n```\n\nThis command generates a random string to use as a token and registers\nit for the given user with the Hub's database.\n\nIn JupyterHub version 0.8.0, a TOKEN request page for\ngenerating an API token is available from the JupyterHub user interface:\n\n\n\n\n\n## Add API tokens to the config file\n\nYou may also add a dictionary of API tokens and usernames to the hub's\nconfiguration file, `jupyterhub_config.py` (note that\nthe **key** is the 'secret-token' while the **value** is the 'username'):\n\n```python\nc.JupyterHub.api_tokens = {\n 'secret-token': 'username',\n}\n```\n\n\n## Make the username an admin\n\nThis is required to be able to kill sessions in the event of user surpassing memory limits.\n\n\n```python\nc.JupyterHub.admin_users = {'username'}\n```\n\nNOTE: If you skip this, Megaclite will NOT be able to kill sessions.\n\n## Enabling the extension\n\ninstall both the serverextension and the toolbar button (nbextension) with:\n\n```bash\npip install megaclite\njupyter serverextension enable --py megaclite --sys-prefix\njupyter nbextension install --py megaclite --sys-prefix\njupyter nbextension enable --py megaclite --sys-prefix\n```\n\nYou can check that the install was successful with:\n```bash\njupyter nbextension list\njupyter serverextension list\n```\n\nYou may also enable it from the nbextensions-configurator UI.\n\n## See the magic unleash\n\n