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.

173 lines
5.3 KiB

10 years ago
10 years ago
10 years ago
10 years ago
  1. {% extends "base.html" %}
  2. {% load staticfiles %}
  3. {% block title %}Documentation - healthchecks.io{% endblock %}
  4. {% block content %}
  5. <div class="row"><div class="col-sm-12">
  6. <h2>Summary</h2>
  7. <p>
  8. Each check you create in <a href="{% url 'hc-index' %}">My Checks</a>
  9. page has an unique "ping" URL. Whenever you access this URL,
  10. the "Last Ping" value of corresponding check is updated.
  11. </p>
  12. <p>When a certain amount of time passes since last received ping, the
  13. check is considered "late", and Health Checks sends an email alert.
  14. It is all very simple, really.</p>
  15. <h2>Executing a Ping</h2>
  16. <p>
  17. At the end of your batch job, add a bit of code to request
  18. your ping URL.
  19. </p>
  20. <ul>
  21. <li>HTTP and HTTPS protocols both are fine</li>
  22. <li>Request method can be GET, POST or HEAD</li>
  23. <li>Both IPv4 and IPv6 work</li>
  24. <li>It does not matter what request headers you send</li>
  25. <li>You can leave request body empty or put anything in it, it's all good</li>
  26. </ul>
  27. <p>The response will have status code "200 OK" and response body will be a
  28. short and simple string "OK".</p>
  29. <p>
  30. Here are examples of executing pings from different environments.
  31. </p>
  32. <h3>Crontab</h3>
  33. <p>
  34. When using cron, probably the easiest is to append a <code>curl</code>
  35. or <code>wget</code> call after your command. The scheduled time comes,
  36. and your command runs. After it completes, the healthchecks.io check
  37. gets pinged.
  38. </p>
  39. {% include "front/snippets/crontab.html" %}
  40. <p>With this simple modification, you monitor several failure
  41. scenarios:</p>
  42. <ul>
  43. <li>The whole machine has stopped working (power outage, janitor stumbles on wires, VPS provider problems, etc.) </li>
  44. <li>cron daemon is not running, or has invalid configuration</li>
  45. <li>cron does start your task, but the task exits with non-zero exit code</li>
  46. </ul>
  47. <p>Either way, when your task doesn't finish successfully, you will soon
  48. know about it.</p>
  49. <h3>Bash or a shell script</h3>
  50. <p>Both <code>curl</code> and <code>wget</code> examples accomplish the same
  51. thing: they fire off a HTTP GET method.</p>
  52. <p>
  53. If using <code>curl</code>, make sure it is installed on your target system.
  54. Ubuntu, for example, does not have curl installed out of the box.
  55. </p>
  56. {% include "front/snippets/bash.html" %}
  57. <h3>Python</h3>
  58. {% include "front/snippets/python.html" %}
  59. <h3>Node</h3>
  60. {% include "front/snippets/node.html" %}
  61. <h3>PHP</h3>
  62. {% include "front/snippets/php.html" %}
  63. <h3>Browser</h3>
  64. <p>
  65. healthchecks.io includes <code>Access-Control-Allow-Origin:*</code>
  66. CORS header in its ping responses, so cross-domain AJAX requests
  67. should work.
  68. </p>
  69. {% include "front/snippets/browser.html" %}
  70. <h3>Email</h3>
  71. <p>
  72. As an alternative to HTTP/HTTPS requests,
  73. you can "ping" this check by sending an
  74. email message to <a href="mailto:{{ check.email }}">{{ check.email }}</a>
  75. </p>
  76. <p>
  77. This is useful for end-to-end testing weekly email delivery.
  78. </p>
  79. <p>
  80. An example scenario: you have a cron job which runs weekly and
  81. sends weekly email reports to a list of e-mail addresses. You have already
  82. set up a check to get alerted when your cron job fails to run.
  83. But what you ultimately want to check is your emails <em>get sent and
  84. get delivered</em>.
  85. </p>
  86. <p>
  87. The solution: set up another check, and add its
  88. @hchk.io address to your list of recipient email addresses. Set its
  89. Period to 1 week. As long as your weekly email script runs correctly,
  90. the check will be regularly pinged and will stay up.
  91. </p>
  92. <h2>When Alerts Are Sent</h2>
  93. <p>
  94. Each check has a configurable <strong>Period</strong> parameter, with the default value of one day.
  95. For periodic tasks, this is the expected time gap between two runs.
  96. </p>
  97. <p>
  98. Additionally, each check has a <strong>Grace</strong> parameter, with default value of one hour.
  99. You can use this parameter to account for run time variance of tasks.
  100. For example, if a backup task completes in 50 seconds one day, and
  101. completes in 60 seconds the following day, you might not want to get
  102. alerted because the backups are 10 seconds late.
  103. </p>
  104. <p>Each check can be in one of the following states:</p>
  105. <table class="table">
  106. <tr>
  107. <td>
  108. <span class="glyphicon glyphicon-question-sign new"></span>
  109. </td>
  110. <td>
  111. <strong>New.</strong>
  112. A check that has been created, but has not received any pings yet.
  113. </td>
  114. </tr>
  115. <tr>
  116. <td>
  117. <span class="glyphicon glyphicon-ok-sign up"></span>
  118. </td>
  119. <td>
  120. <strong>Up.</strong>
  121. Time since last ping has not exceeded <strong>Period</strong>.
  122. </td>
  123. </tr>
  124. <tr>
  125. <td>
  126. <span class="glyphicon glyphicon-exclamation-sign grace"></span>
  127. </td>
  128. <td>
  129. <strong>Late.</strong>
  130. Time since last ping has exceeded <strong>Period</strong>,
  131. but has not yet exceeded <strong>Period</strong> + <strong>Grace</strong>.
  132. </td>
  133. </tr>
  134. <tr>
  135. <td>
  136. <span class="glyphicon glyphicon-exclamation-sign down"></span>
  137. </td>
  138. <td>
  139. <strong>Down.</strong>
  140. Time since last ping has exceeded <strong>Period</strong> + <strong>Grace</strong>.
  141. When check goes from "Late" to "Down", healthchecks.io
  142. sends you an alert.
  143. </td>
  144. </tr>
  145. </table>
  146. </div></div>
  147. {% endblock %}