You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

298 lines
9.3 KiB

10 years ago
9 years ago
9 years ago
9 years ago
9 years ago
10 years ago
10 years ago
10 years ago
update Readme with pip install dependencies pip install will fail when you cannot compile some of the dependencies. one is gcc the other is the Python.h ``` Building wheels for collected packages: rcssmin, rjsmin Running setup.py bdist_wheel for rcssmin ... error Complete output from command /home/ubuntu/webapps/hc-venv/bin/python3 -u -c "import setuptools, tokenize;__file__='/tmp/pip-install-ipfho29k/rcssmin/setup.py';f=getattr(tokenize, 'open', open)(__file__);code=f.read().replace('\r\n', '\n');f.close();exec(compile(code, __file__, 'exec'))" bdist_wheel -d /tmp/pip-wheel-u0q6mggl --python-tag cp36: running bdist_wheel running build running build_py creating build creating build/lib.linux-x86_64-3.6 copying ./rcssmin.py -> build/lib.linux-x86_64-3.6 running build_ext building '_rcssmin' extension creating build/temp.linux-x86_64-3.6 x86_64-linux-gnu-gcc -pthread -DNDEBUG -g -fwrapv -O2 -Wall -g -fstack-protector-strong -Wformat -Werror=format-security -Wdate-time -D_FORTIFY_SOURCE=2 -fPIC -DEXT_MODULE=_rcssmin -UEXT_PACKAGE -I_setup/include -I/usr/include/python3.6m -I/home/ubuntu/webapps/hc-venv/include/python3.6m -c rcssmin.c -o build/temp.linux-x86_64-3.6/rcssmin.o unable to execute 'x86_64-linux-gnu-gcc': No such file or directory error: command 'x86_64-linux-gnu-gcc' failed with exit status 1 ---------------------------------------- Failed building wheel for rcssmin Running setup.py clean for rcssmin Running setup.py bdist_wheel for rjsmin ... error Complete output from command /home/ubuntu/webapps/hc-venv/bin/python3 -u -c "import setuptools, tokenize;__file__='/tmp/pip-install-ipfho29k/rjsmin/setup.py';f=getattr(tokenize, 'open', open)(__file__);code=f.read().replace('\r\n', '\n');f.close();exec(compile(code, __file__, 'exec'))" bdist_wheel -d /tmp/pip-wheel-axnaq3w9 --python-tag cp36: running bdist_wheel running build running build_py creating build creating build/lib.linux-x86_64-3.6 copying ./rjsmin.py -> build/lib.linux-x86_64-3.6 running build_ext building '_rjsmin' extension creating build/temp.linux-x86_64-3.6 x86_64-linux-gnu-gcc -pthread -DNDEBUG -g -fwrapv -O2 -Wall -g -fstack-protector-strong -Wformat -Werror=format-security -Wdate-time -D_FORTIFY_SOURCE=2 -fPIC -DEXT_MODULE=_rjsmin -UEXT_PACKAGE -I_setup/include -I/usr/include/python3.6m -I/home/ubuntu/webapps/hc-venv/include/python3.6m -c rjsmin.c -o build/temp.linux-x86_64-3.6/rjsmin.o unable to execute 'x86_64-linux-gnu-gcc': No such file or directory error: command 'x86_64-linux-gnu-gcc' failed with exit status 1 ``` ``` Running setup.py bdist_wheel for rjsmin ... error Complete output from command /home/ubuntu/webapps/hc-venv/bin/python3 -u -c "import setuptools, tokenize;__file__='/tmp/pip-install-cfntw7bo/rjsmin/setup.py';f=getattr(tokenize, 'open', open)(__file__);code=f.read().replace('\r\n', '\n');f.close();exec(compile(code, __file__, 'exec'))" bdist_wheel -d /tmp/pip-wheel-ytqxu9_b --python-tag cp36: running bdist_wheel running build running build_py creating build creating build/lib.linux-x86_64-3.6 copying ./rjsmin.py -> build/lib.linux-x86_64-3.6 running build_ext building '_rjsmin' extension creating build/temp.linux-x86_64-3.6 x86_64-linux-gnu-gcc -pthread -DNDEBUG -g -fwrapv -O2 -Wall -g -fstack-protector-strong -Wformat -Werror=format-security -Wdate-time -D_FORTIFY_SOURCE=2 -fPIC -DEXT_MODULE=_rjsmin -UEXT_PACKAGE -I_setup/include -I/usr/include/python3.6m -I/home/ubuntu/webapps/hc-venv/include/python3.6m -c rjsmin.c -o build/temp.linux-x86_64-3.6/rjsmin.o In file included from rjsmin.c:18:0: _setup/include/cext.h:34:10: fatal error: Python.h: No such file or directory #include "Python.h" ^~~~~~~~~~ compilation terminated. ```
6 years ago
10 years ago
  1. # healthchecks
  2. [![Build Status](https://travis-ci.org/healthchecks/healthchecks.svg?branch=master)](https://travis-ci.org/healthchecks/healthchecks)
  3. [![Coverage Status](https://coveralls.io/repos/healthchecks/healthchecks/badge.svg?branch=master&service=github)](https://coveralls.io/github/healthchecks/healthchecks?branch=master)
  4. ![Screenshot of Welcome page](/static/img/welcome.png?raw=true "Welcome Page")
  5. ![Screenshot of My Checks page](/static/img/my_checks.png?raw=true "My Checks Page")
  6. ![Screenshot of Period/Grace dialog](/static/img/period_grace.png?raw=true "Period/Grace Dialog")
  7. ![Screenshot of Cron dialog](/static/img/cron.png?raw=true "Cron Dialog")
  8. ![Screenshot of Integrations page](/static/img/channels.png?raw=true "Integrations Page")
  9. healthchecks is a watchdog for your cron jobs. It's a web server that listens for pings from your cron jobs, plus a web interface.
  10. It is live here: [http://healthchecks.io/](http://healthchecks.io/)
  11. The building blocks are:
  12. * Python 3
  13. * Django 2
  14. * PostgreSQL or MySQL
  15. ## Setting Up for Development
  16. These are instructions for setting up healthchecks Django app
  17. in development environment.
  18. * install dependencies (Debian/Ubuntu)
  19. $ sudo apt-get update
  20. $ sudo apt-get install -y gcc python3-dev
  21. * prepare directory for project code and virtualenv:
  22. $ mkdir -p ~/webapps
  23. $ cd ~/webapps
  24. * prepare virtual environment
  25. (with virtualenv you get pip, we'll use it soon to install requirements):
  26. $ virtualenv --python=python3 hc-venv
  27. $ source hc-venv/bin/activate
  28. * check out project code:
  29. $ git clone https://github.com/healthchecks/healthchecks.git
  30. * install requirements (Django, ...) into virtualenv:
  31. $ pip install -r healthchecks/requirements.txt
  32. * healthchecks is configured to use a SQLite database by default. To use
  33. PostgreSQL or MySQL database, create and edit `hc/local_settings.py` file.
  34. There is a template you can copy and edit as needed:
  35. $ cd ~/webapps/healthchecks
  36. $ cp hc/local_settings.py.example hc/local_settings.py
  37. * create database tables and the superuser account:
  38. $ cd ~/webapps/healthchecks
  39. $ ./manage.py migrate
  40. $ ./manage.py createsuperuser
  41. * run development server:
  42. $ ./manage.py runserver
  43. The site should now be running at `http://localhost:8080`
  44. To log into Django administration site as a super user,
  45. visit `http://localhost:8080/admin`
  46. ## Configuration
  47. Site configuration is kept in `hc/settings.py`. Additional configuration
  48. is loaded from `hc/local_settings.py` file, if it exists. You
  49. can create this file (should be right next to `settings.py` in the filesystem)
  50. and override settings as needed.
  51. Some useful settings keys to override are:
  52. `SITE_ROOT` is used to build fully qualified URLs for pings, and for use in
  53. emails and notifications. Example:
  54. ```python
  55. SITE_ROOT = "https://my-monitoring-project.com"
  56. ```
  57. `SITE_NAME` has the default value of "Mychecks" and is used throughout
  58. the templates. Replace it with your own name to personalize your installation.
  59. Example:
  60. ```python
  61. SITE_NAME = "My Monitoring Project"
  62. ```
  63. `REGISTRATION_OPEN` controls whether site visitors can create new accounts.
  64. Set it to `False` if you are setting up a private healthchecks instance, but
  65. it needs to be publicly accessible (so, for example, your cloud services
  66. can send pings).
  67. If you close new user registration, you can still selectively invite users
  68. to your team account.
  69. ## Database Configuration
  70. Database configuration is stored in `hc/settings.py` and can be overriden
  71. in `hc/local_settings.py`. The default database engine is SQLite. To use
  72. PostgreSQL, create `hc/local_settings.py` if it does not exist, and put the
  73. following in it, changing it as neccessary:
  74. ```python
  75. DATABASES = {
  76. 'default': {
  77. 'ENGINE': 'django.db.backends.postgresql',
  78. 'NAME': 'your-database-name-here',
  79. 'USER': 'your-database-user-here',
  80. 'PASSWORD': 'your-database-password-here',
  81. 'TEST': {'CHARSET': 'UTF8'}
  82. }
  83. }
  84. ```
  85. For MySQL:
  86. ```python
  87. DATABASES = {
  88. 'default': {
  89. 'ENGINE': 'django.db.backends.mysql',
  90. 'NAME': 'your-database-name-here',
  91. 'USER': 'your-database-user-here',
  92. 'PASSWORD': 'your-database-password-here',
  93. 'TEST': {'CHARSET': 'UTF8'}
  94. }
  95. }
  96. ```
  97. You can also use `hc/local_settings.py` to read database
  98. configuration from environment variables like so:
  99. ```python
  100. import os
  101. DATABASES = {
  102. 'default': {
  103. 'ENGINE': os.environ['DB_ENGINE'],
  104. 'NAME': os.environ['DB_NAME'],
  105. 'USER': os.environ['DB_USER'],
  106. 'PASSWORD': os.environ['DB_PASSWORD'],
  107. 'TEST': {'CHARSET': 'UTF8'}
  108. }
  109. }
  110. ```
  111. ## Sending Emails
  112. healthchecks must be able to send email messages, so it can send out login
  113. links and alerts to users. Put your SMTP server configuration in
  114. `hc/local_settings.py` like so:
  115. ```python
  116. EMAIL_HOST = "your-smtp-server-here.com"
  117. EMAIL_PORT = 587
  118. EMAIL_HOST_USER = "username"
  119. EMAIL_HOST_PASSWORD = "password"
  120. EMAIL_USE_TLS = True
  121. ```
  122. For more information, have a look at Django documentation,
  123. [Sending Email](https://docs.djangoproject.com/en/1.10/topics/email/) section.
  124. ## Receiving Emails
  125. healthchecks comes with a `smtpd` management command, which starts up a
  126. SMTP listener service. With the command running, you can ping your
  127. checks by sending email messages
  128. to `[email protected]` email addresses.
  129. Start the SMTP listener on port 2525:
  130. $ ./manage.py smtpd --port 2525
  131. Send a test email:
  132. $ curl --url 'smtp://127.0.0.1:2525' \
  133. --mail-from '[email protected]' \
  134. --mail-rcpt '[email protected]' \
  135. -F '='
  136. ## Sending Status Notifications
  137. healtchecks comes with a `sendalerts` management command, which continuously
  138. polls database for any checks changing state, and sends out notifications as
  139. needed. Within an activated virtualenv, you can manually run
  140. the `sendalerts` command like so:
  141. $ ./manage.py sendalerts
  142. In a production setup, you will want to run this command from a process
  143. manager like [supervisor](http://supervisord.org/) or systemd.
  144. ## Database Cleanup
  145. With time and use the healthchecks database will grow in size. You may
  146. decide to prune old data: inactive user accounts, old checks not assigned
  147. to users, records of outgoing email messages and records of received pings.
  148. There are separate Django management commands for each task:
  149. * Remove old records from `api_ping` table. For each check, keep 100 most
  150. recent pings:
  151. ```
  152. $ ./manage.py prunepings
  153. ```
  154. * Remove checks older than 2 hours that are not assigned to users. Such
  155. checks are by-products of random visitors and robots loading the welcome
  156. page and never setting up an account:
  157. ```
  158. $ ./manage.py prunechecks
  159. ```
  160. * Remove old records of sent notifications. For each check, remove
  161. notifications that are older than the oldest stored ping for same check.
  162. ```
  163. $ ./manage.py prunenotifications
  164. ```
  165. * Remove user accounts that match either of these conditions:
  166. * Account was created more than 6 months ago, and user has never logged in.
  167. These can happen when user enters invalid email address when signing up.
  168. * Last login was more than 6 months ago, and the account has no checks.
  169. Assume the user doesn't intend to use the account any more and would
  170. probably *want* it removed.
  171. ```
  172. $ ./manage.py pruneusers
  173. ```
  174. When you first try these commands on your data, it is a good idea to
  175. test them on a copy of your database, not on the live database right away.
  176. In a production setup, you should also have regular, automated database
  177. backups set up.
  178. ## Integrations
  179. ### Discord
  180. To enable Discord integration, you will need to:
  181. * register a new application on https://discordapp.com/developers/applications/me
  182. * add a redirect URI to your Discord application. The URI format is
  183. `SITE_ROOT/integrations/add_discord/`. For example, if you are running a
  184. development server on `localhost:8000` then the redirect URI would be
  185. `http://localhost:8000/integrations/add_discord/`
  186. * Look up your Discord app's Client ID and Client Secret. Add them
  187. to your `hc/local_settings.py` file as `DISCORD_CLIENT_ID` and
  188. `DISCORD_CLIENT_SECRET` fields.
  189. ### Pushover
  190. To enable Pushover integration, you will need to:
  191. * register a new application on https://pushover.net/apps/build
  192. * enable subscriptions in your application and make sure to enable the URL
  193. subscription type
  194. * add the application token and subscription URL to `hc/local_settings.py`, as
  195. `PUSHOVER_API_TOKEN` and `PUSHOVER_SUBSCRIPTION_URL`
  196. ### Telegram
  197. * Create a Telegram bot by talking to the
  198. [BotFather](https://core.telegram.org/bots#6-botfather). Set the bot's name,
  199. description, user picture, and add a "/start" command.
  200. * After creating the bot you will have the bot's name and token. Add them
  201. to your `hc/local_settings.py` file as `TELEGRAM_BOT_NAME` and
  202. `TELEGRAM_TOKEN` fields.
  203. * Run `settelegramwebhook` management command. This command tells Telegram
  204. where to forward channel messages by invoking Telegram's
  205. [setWebhook](https://core.telegram.org/bots/api#setwebhook) API call:
  206. ```
  207. $ ./manage.py settelegramwebhook
  208. Done, Telegram's webhook set to: https://my-monitoring-project.com/integrations/telegram/bot/
  209. ```
  210. For this to work, your `SITE_ROOT` needs to be correct and use "https://"
  211. scheme.