Browse Source

Syntax highlighting for PHP examples.

pull/405/head
Pēteris Caune 4 years ago
parent
commit
556e8c67c5
No known key found for this signature in database GPG Key ID: E28D7679E9A9EDE2
20 changed files with 72 additions and 72 deletions
  1. +1
    -1
      hc/front/management/commands/pygmentize.py
  2. +1
    -1
      hc/front/management/commands/render_docs.py
  3. +22
    -22
      templates/docs/api.html
  4. +3
    -3
      templates/docs/attaching_logs.html
  5. +4
    -4
      templates/docs/bash.html
  6. +1
    -1
      templates/docs/cloning_checks.html
  7. +1
    -1
      templates/docs/configuring_prometheus.html
  8. +1
    -1
      templates/docs/csharp.html
  9. +9
    -9
      templates/docs/http_api.html
  10. +2
    -2
      templates/docs/javascript.html
  11. +1
    -1
      templates/docs/measuring_script_run_time.html
  12. +3
    -3
      templates/docs/monitoring_cron_jobs.html
  13. +6
    -6
      templates/docs/php.html
  14. +5
    -5
      templates/docs/powershell.html
  15. +3
    -3
      templates/docs/powershell.md
  16. +3
    -3
      templates/docs/python.html
  17. +2
    -2
      templates/docs/reliability_tips.html
  18. +1
    -1
      templates/docs/ruby.html
  19. +2
    -2
      templates/docs/signalling_failures.html
  20. +1
    -1
      templates/front/snippets/php.html

+ 1
- 1
hc/front/management/commands/pygmentize.py View File

@ -40,7 +40,7 @@ class Command(BaseCommand):
_process("python_requests_fail", lexers.PythonLexer()) _process("python_requests_fail", lexers.PythonLexer())
_process("python_requests_start", lexers.PythonLexer()) _process("python_requests_start", lexers.PythonLexer())
_process("python_requests_payload", lexers.PythonLexer()) _process("python_requests_payload", lexers.PythonLexer())
_process("php", lexers.PhpLexer())
_process("php", lexers.PhpLexer(startinline=True))
_process("powershell", lexers.shell.PowerShellLexer()) _process("powershell", lexers.shell.PowerShellLexer())
_process("powershell_inline", lexers.shell.BashLexer()) _process("powershell_inline", lexers.shell.BashLexer())
_process("ruby", lexers.RubyLexer()) _process("ruby", lexers.RubyLexer())

+ 1
- 1
hc/front/management/commands/render_docs.py View File

@ -20,7 +20,7 @@ class Command(BaseCommand):
return return
extensions = ["fenced_code", "codehilite", "tables", "def_list", "attr_list"] extensions = ["fenced_code", "codehilite", "tables", "def_list", "attr_list"]
ec = {"codehilite": {"css_class": "highlight"}}
ec = {"codehilite": {"css_class": "highlight", "startinline": True}}
docs_path = os.path.join(settings.BASE_DIR, "templates/docs") docs_path = os.path.join(settings.BASE_DIR, "templates/docs")
for doc in os.listdir(docs_path): for doc in os.listdir(docs_path):


+ 22
- 22
templates/docs/api.html View File

@ -103,12 +103,12 @@ specified value.</p>
<dd>The API key is either missing or invalid.</dd> <dd>The API key is either missing or invalid.</dd>
</dl> </dl>
<h3>Example Request</h3> <h3>Example Request</h3>
<div class="highlight"><pre><span></span><code>curl --header <span class="s2">&quot;X-Api-Key: your-api-key&quot;</span> SITE_ROOT/api/v1/checks/
<div class="bash highlight"><pre><span></span><code>curl --header <span class="s2">&quot;X-Api-Key: your-api-key&quot;</span> SITE_ROOT/api/v1/checks/
</code></pre></div> </code></pre></div>
<h3>Example Response</h3> <h3>Example Response</h3>
<div class="highlight"><pre><span></span><code><span class="p">{</span>
<div class="json highlight"><pre><span></span><code><span class="p">{</span>
<span class="nt">&quot;checks&quot;</span><span class="p">:</span> <span class="p">[</span> <span class="nt">&quot;checks&quot;</span><span class="p">:</span> <span class="p">[</span>
<span class="p">{</span> <span class="p">{</span>
<span class="nt">&quot;name&quot;</span><span class="p">:</span> <span class="s2">&quot;Filesystem Backup&quot;</span><span class="p">,</span> <span class="nt">&quot;name&quot;</span><span class="p">:</span> <span class="s2">&quot;Filesystem Backup&quot;</span><span class="p">,</span>
@ -151,7 +151,7 @@ specified value.</p>
<p>When using the read-only API key, the following fields are omitted: <p>When using the read-only API key, the following fields are omitted:
<code>ping_url</code>, <code>update_url</code>, <code>pause_url</code>, <code>channels</code>. An extra <code>unique_key</code> field <code>ping_url</code>, <code>update_url</code>, <code>pause_url</code>, <code>channels</code>. An extra <code>unique_key</code> field
is added which can be used <a href="#get-check">to <code>GET</code> a check</a> in place of the <code>UUID</code>. The <code>unique_key</code> identifier is stable across API calls. Example:</p> is added which can be used <a href="#get-check">to <code>GET</code> a check</a> in place of the <code>UUID</code>. The <code>unique_key</code> identifier is stable across API calls. Example:</p>
<div class="highlight"><pre><span></span><code><span class="p">{</span>
<div class="json highlight"><pre><span></span><code><span class="p">{</span>
<span class="nt">&quot;checks&quot;</span><span class="p">:</span> <span class="p">[</span> <span class="nt">&quot;checks&quot;</span><span class="p">:</span> <span class="p">[</span>
<span class="p">{</span> <span class="p">{</span>
<span class="nt">&quot;name&quot;</span><span class="p">:</span> <span class="s2">&quot;Filesystem Backup&quot;</span><span class="p">,</span> <span class="nt">&quot;name&quot;</span><span class="p">:</span> <span class="s2">&quot;Filesystem Backup&quot;</span><span class="p">,</span>
@ -203,12 +203,12 @@ using the read-only API key) as an identifier.</p>
<dd>The specified check does not exist.</dd> <dd>The specified check does not exist.</dd>
</dl> </dl>
<h3>Example Request</h3> <h3>Example Request</h3>
<div class="highlight"><pre><span></span><code>curl --header <span class="s2">&quot;X-Api-Key: your-api-key&quot;</span> SITE_ROOT/api/v1/checks/&lt;uuid&gt;
<div class="bash highlight"><pre><span></span><code>curl --header <span class="s2">&quot;X-Api-Key: your-api-key&quot;</span> SITE_ROOT/api/v1/checks/&lt;uuid&gt;
</code></pre></div> </code></pre></div>
<h3>Example Response</h3> <h3>Example Response</h3>
<div class="highlight"><pre><span></span><code><span class="p">{</span>
<div class="json highlight"><pre><span></span><code><span class="p">{</span>
<span class="nt">&quot;name&quot;</span><span class="p">:</span> <span class="s2">&quot;Database Backup&quot;</span><span class="p">,</span> <span class="nt">&quot;name&quot;</span><span class="p">:</span> <span class="s2">&quot;Database Backup&quot;</span><span class="p">,</span>
<span class="nt">&quot;tags&quot;</span><span class="p">:</span> <span class="s2">&quot;production db&quot;</span><span class="p">,</span> <span class="nt">&quot;tags&quot;</span><span class="p">:</span> <span class="s2">&quot;production db&quot;</span><span class="p">,</span>
<span class="nt">&quot;desc&quot;</span><span class="p">:</span> <span class="s2">&quot;Runs ~/db-backup.sh&quot;</span><span class="p">,</span> <span class="nt">&quot;desc&quot;</span><span class="p">:</span> <span class="s2">&quot;Runs ~/db-backup.sh&quot;</span><span class="p">,</span>
@ -235,7 +235,7 @@ added. This identifier is stable across API calls.</p>
<p>Note: the <code>ping_url</code>, <code>update_url</code> and <code>pause_url</code> fields, although omitted, are not <p>Note: the <code>ping_url</code>, <code>update_url</code> and <code>pause_url</code> fields, although omitted, are not
really secret. The client already knows the check's unique UUID and so can easily really secret. The client already knows the check's unique UUID and so can easily
construct these URLs by itself.</p> construct these URLs by itself.</p>
<div class="highlight"><pre><span></span><code><span class="p">{</span>
<div class="json highlight"><pre><span></span><code><span class="p">{</span>
<span class="nt">&quot;name&quot;</span><span class="p">:</span> <span class="s2">&quot;Database Backup&quot;</span><span class="p">,</span> <span class="nt">&quot;name&quot;</span><span class="p">:</span> <span class="s2">&quot;Database Backup&quot;</span><span class="p">,</span>
<span class="nt">&quot;tags&quot;</span><span class="p">:</span> <span class="s2">&quot;production db&quot;</span><span class="p">,</span> <span class="nt">&quot;tags&quot;</span><span class="p">:</span> <span class="s2">&quot;production db&quot;</span><span class="p">,</span>
<span class="nt">&quot;desc&quot;</span><span class="p">:</span> <span class="s2">&quot;Runs ~/db-backup.sh&quot;</span><span class="p">,</span> <span class="nt">&quot;desc&quot;</span><span class="p">:</span> <span class="s2">&quot;Runs ~/db-backup.sh&quot;</span><span class="p">,</span>
@ -361,20 +361,20 @@ field values.</dd>
the limit is 20 checks per account.</dd> the limit is 20 checks per account.</dd>
</dl> </dl>
<h3>Example Request</h3> <h3>Example Request</h3>
<div class="highlight"><pre><span></span><code>curl SITE_ROOT/api/v1/checks/ <span class="se">\</span>
<div class="bash highlight"><pre><span></span><code>curl SITE_ROOT/api/v1/checks/ <span class="se">\</span>
--header <span class="s2">&quot;X-Api-Key: your-api-key&quot;</span> <span class="se">\</span> --header <span class="s2">&quot;X-Api-Key: your-api-key&quot;</span> <span class="se">\</span>
--data <span class="s1">&#39;{&quot;name&quot;: &quot;Backups&quot;, &quot;tags&quot;: &quot;prod www&quot;, &quot;timeout&quot;: 3600, &quot;grace&quot;: 60}&#39;</span> --data <span class="s1">&#39;{&quot;name&quot;: &quot;Backups&quot;, &quot;tags&quot;: &quot;prod www&quot;, &quot;timeout&quot;: 3600, &quot;grace&quot;: 60}&#39;</span>
</code></pre></div> </code></pre></div>
<p>Or, alternatively:</p> <p>Or, alternatively:</p>
<div class="highlight"><pre><span></span><code>curl SITE_ROOT/api/v1/checks/ <span class="se">\</span>
<div class="bash highlight"><pre><span></span><code>curl SITE_ROOT/api/v1/checks/ <span class="se">\</span>
--data <span class="s1">&#39;{&quot;api_key&quot;: &quot;your-api-key&quot;, &quot;name&quot;: &quot;Backups&quot;, &quot;tags&quot;: &quot;prod www&quot;, &quot;timeout&quot;: 3600, &quot;grace&quot;: 60}&#39;</span> --data <span class="s1">&#39;{&quot;api_key&quot;: &quot;your-api-key&quot;, &quot;name&quot;: &quot;Backups&quot;, &quot;tags&quot;: &quot;prod www&quot;, &quot;timeout&quot;: 3600, &quot;grace&quot;: 60}&#39;</span>
</code></pre></div> </code></pre></div>
<h3>Example Response</h3> <h3>Example Response</h3>
<div class="highlight"><pre><span></span><code><span class="p">{</span>
<div class="json highlight"><pre><span></span><code><span class="p">{</span>
<span class="nt">&quot;channels&quot;</span><span class="p">:</span> <span class="s2">&quot;&quot;</span><span class="p">,</span> <span class="nt">&quot;channels&quot;</span><span class="p">:</span> <span class="s2">&quot;&quot;</span><span class="p">,</span>
<span class="nt">&quot;desc&quot;</span><span class="p">:</span> <span class="s2">&quot;&quot;</span><span class="p">,</span> <span class="nt">&quot;desc&quot;</span><span class="p">:</span> <span class="s2">&quot;&quot;</span><span class="p">,</span>
<span class="nt">&quot;grace&quot;</span><span class="p">:</span> <span class="mi">60</span><span class="p">,</span> <span class="nt">&quot;grace&quot;</span><span class="p">:</span> <span class="mi">60</span><span class="p">,</span>
@ -485,20 +485,20 @@ field values.</dd>
<dd>The specified check does not exist.</dd> <dd>The specified check does not exist.</dd>
</dl> </dl>
<h3>Example Request</h3> <h3>Example Request</h3>
<div class="highlight"><pre><span></span><code>curl SITE_ROOT/api/v1/checks/f618072a-7bde-4eee-af63-71a77c5723bc <span class="se">\</span>
<div class="bash highlight"><pre><span></span><code>curl SITE_ROOT/api/v1/checks/f618072a-7bde-4eee-af63-71a77c5723bc <span class="se">\</span>
--header <span class="s2">&quot;X-Api-Key: your-api-key&quot;</span> <span class="se">\</span> --header <span class="s2">&quot;X-Api-Key: your-api-key&quot;</span> <span class="se">\</span>
--data <span class="s1">&#39;{&quot;name&quot;: &quot;Backups&quot;, &quot;tags&quot;: &quot;prod www&quot;, &quot;timeout&quot;: 3600, &quot;grace&quot;: 60}&#39;</span> --data <span class="s1">&#39;{&quot;name&quot;: &quot;Backups&quot;, &quot;tags&quot;: &quot;prod www&quot;, &quot;timeout&quot;: 3600, &quot;grace&quot;: 60}&#39;</span>
</code></pre></div> </code></pre></div>
<p>Or, alternatively:</p> <p>Or, alternatively:</p>
<div class="highlight"><pre><span></span><code>curl SITE_ROOT/api/v1/checks/f618072a-7bde-4eee-af63-71a77c5723bc <span class="se">\</span>
<div class="bash highlight"><pre><span></span><code>curl SITE_ROOT/api/v1/checks/f618072a-7bde-4eee-af63-71a77c5723bc <span class="se">\</span>
--data <span class="s1">&#39;{&quot;api_key&quot;: &quot;your-api-key&quot;, &quot;name&quot;: &quot;Backups&quot;, &quot;tags&quot;: &quot;prod www&quot;, &quot;timeout&quot;: 3600, &quot;grace&quot;: 60}&#39;</span> --data <span class="s1">&#39;{&quot;api_key&quot;: &quot;your-api-key&quot;, &quot;name&quot;: &quot;Backups&quot;, &quot;tags&quot;: &quot;prod www&quot;, &quot;timeout&quot;: 3600, &quot;grace&quot;: 60}&#39;</span>
</code></pre></div> </code></pre></div>
<h3>Example Response</h3> <h3>Example Response</h3>
<div class="highlight"><pre><span></span><code><span class="p">{</span>
<div class="json highlight"><pre><span></span><code><span class="p">{</span>
<span class="nt">&quot;channels&quot;</span><span class="p">:</span> <span class="s2">&quot;&quot;</span><span class="p">,</span> <span class="nt">&quot;channels&quot;</span><span class="p">:</span> <span class="s2">&quot;&quot;</span><span class="p">,</span>
<span class="nt">&quot;desc&quot;</span><span class="p">:</span> <span class="s2">&quot;&quot;</span><span class="p">,</span> <span class="nt">&quot;desc&quot;</span><span class="p">:</span> <span class="s2">&quot;&quot;</span><span class="p">,</span>
<span class="nt">&quot;grace&quot;</span><span class="p">:</span> <span class="mi">60</span><span class="p">,</span> <span class="nt">&quot;grace&quot;</span><span class="p">:</span> <span class="mi">60</span><span class="p">,</span>
@ -534,7 +534,7 @@ state. You can resume monitoring of the check by pinging it.</p>
<dd>The specified check does not exist.</dd> <dd>The specified check does not exist.</dd>
</dl> </dl>
<h3>Example Request</h3> <h3>Example Request</h3>
<div class="highlight"><pre><span></span><code>curl SITE_ROOT/api/v1/checks/0c8983c9-9d73-446f-adb5-0641fdacc9d4/pause <span class="se">\</span>
<div class="bash highlight"><pre><span></span><code>curl SITE_ROOT/api/v1/checks/0c8983c9-9d73-446f-adb5-0641fdacc9d4/pause <span class="se">\</span>
--request POST --header <span class="s2">&quot;X-Api-Key: your-api-key&quot;</span> --data <span class="s2">&quot;&quot;</span> --request POST --header <span class="s2">&quot;X-Api-Key: your-api-key&quot;</span> --data <span class="s2">&quot;&quot;</span>
</code></pre></div> </code></pre></div>
@ -543,7 +543,7 @@ state. You can resume monitoring of the check by pinging it.</p>
even though the request body is empty. For HTTP POST requests, the <code>Content-Length</code> even though the request body is empty. For HTTP POST requests, the <code>Content-Length</code>
header is sometimes required by some network proxies and web servers.</p> header is sometimes required by some network proxies and web servers.</p>
<h3>Example Response</h3> <h3>Example Response</h3>
<div class="highlight"><pre><span></span><code><span class="p">{</span>
<div class="json highlight"><pre><span></span><code><span class="p">{</span>
<span class="nt">&quot;channels&quot;</span><span class="p">:</span> <span class="s2">&quot;&quot;</span><span class="p">,</span> <span class="nt">&quot;channels&quot;</span><span class="p">:</span> <span class="s2">&quot;&quot;</span><span class="p">,</span>
<span class="nt">&quot;desc&quot;</span><span class="p">:</span> <span class="s2">&quot;&quot;</span><span class="p">,</span> <span class="nt">&quot;desc&quot;</span><span class="p">:</span> <span class="s2">&quot;&quot;</span><span class="p">,</span>
<span class="nt">&quot;grace&quot;</span><span class="p">:</span> <span class="mi">60</span><span class="p">,</span> <span class="nt">&quot;grace&quot;</span><span class="p">:</span> <span class="mi">60</span><span class="p">,</span>
@ -579,13 +579,13 @@ check that was just deleted.</p>
<dd>The specified check does not exist.</dd> <dd>The specified check does not exist.</dd>
</dl> </dl>
<h3>Example Request</h3> <h3>Example Request</h3>
<div class="highlight"><pre><span></span><code>curl SITE_ROOT/api/v1/checks/f618072a-7bde-4eee-af63-71a77c5723bc <span class="se">\</span>
<div class="bash highlight"><pre><span></span><code>curl SITE_ROOT/api/v1/checks/f618072a-7bde-4eee-af63-71a77c5723bc <span class="se">\</span>
--request DELETE --header <span class="s2">&quot;X-Api-Key: your-api-key&quot;</span> --request DELETE --header <span class="s2">&quot;X-Api-Key: your-api-key&quot;</span>
</code></pre></div> </code></pre></div>
<h3>Example Response</h3> <h3>Example Response</h3>
<div class="highlight"><pre><span></span><code><span class="p">{</span>
<div class="json highlight"><pre><span></span><code><span class="p">{</span>
<span class="nt">&quot;channels&quot;</span><span class="p">:</span> <span class="s2">&quot;&quot;</span><span class="p">,</span> <span class="nt">&quot;channels&quot;</span><span class="p">:</span> <span class="s2">&quot;&quot;</span><span class="p">,</span>
<span class="nt">&quot;desc&quot;</span><span class="p">:</span> <span class="s2">&quot;&quot;</span><span class="p">,</span> <span class="nt">&quot;desc&quot;</span><span class="p">:</span> <span class="s2">&quot;&quot;</span><span class="p">,</span>
<span class="nt">&quot;grace&quot;</span><span class="p">:</span> <span class="mi">60</span><span class="p">,</span> <span class="nt">&quot;grace&quot;</span><span class="p">:</span> <span class="mi">60</span><span class="p">,</span>
@ -622,13 +622,13 @@ number of returned pings depends on account's billing plan: 100 for free account
<dd>The specified check does not exist.</dd> <dd>The specified check does not exist.</dd>
</dl> </dl>
<h3>Example Request</h3> <h3>Example Request</h3>
<div class="highlight"><pre><span></span><code>curl SITE_ROOT/api/v1/checks/f618072a-7bde-4eee-af63-71a77c5723bc/pings/ <span class="se">\</span>
<div class="bash highlight"><pre><span></span><code>curl SITE_ROOT/api/v1/checks/f618072a-7bde-4eee-af63-71a77c5723bc/pings/ <span class="se">\</span>
--header <span class="s2">&quot;X-Api-Key: your-api-key&quot;</span> --header <span class="s2">&quot;X-Api-Key: your-api-key&quot;</span>
</code></pre></div> </code></pre></div>
<h3>Example Response</h3> <h3>Example Response</h3>
<div class="highlight"><pre><span></span><code><span class="p">{</span>
<div class="json highlight"><pre><span></span><code><span class="p">{</span>
<span class="nt">&quot;pings&quot;</span><span class="p">:</span> <span class="p">[</span> <span class="nt">&quot;pings&quot;</span><span class="p">:</span> <span class="p">[</span>
<span class="p">{</span> <span class="p">{</span>
<span class="nt">&quot;type&quot;</span><span class="p">:</span> <span class="s2">&quot;success&quot;</span><span class="p">,</span> <span class="nt">&quot;type&quot;</span><span class="p">:</span> <span class="s2">&quot;success&quot;</span><span class="p">,</span>
@ -713,13 +713,13 @@ number of returned pings depends on account's billing plan: 100 for free account
<dd>The specified check does not exist.</dd> <dd>The specified check does not exist.</dd>
</dl> </dl>
<h3>Example Request</h3> <h3>Example Request</h3>
<div class="highlight"><pre><span></span><code>curl SITE_ROOT/api/v1/checks/f618072a-7bde-4eee-af63-71a77c5723bc/flips/ <span class="se">\</span>
<div class="bash highlight"><pre><span></span><code>curl SITE_ROOT/api/v1/checks/f618072a-7bde-4eee-af63-71a77c5723bc/flips/ <span class="se">\</span>
--header <span class="s2">&quot;X-Api-Key: your-api-key&quot;</span> --header <span class="s2">&quot;X-Api-Key: your-api-key&quot;</span>
</code></pre></div> </code></pre></div>
<h3>Example Response</h3> <h3>Example Response</h3>
<div class="highlight"><pre><span></span><code><span class="p">[</span>
<div class="json highlight"><pre><span></span><code><span class="p">[</span>
<span class="p">{</span> <span class="p">{</span>
<span class="nt">&quot;timestamp&quot;</span><span class="p">:</span> <span class="s2">&quot;2020-03-23T10:18:23+00:00&quot;</span><span class="p">,</span> <span class="nt">&quot;timestamp&quot;</span><span class="p">:</span> <span class="s2">&quot;2020-03-23T10:18:23+00:00&quot;</span><span class="p">,</span>
<span class="nt">&quot;up&quot;</span><span class="p">:</span> <span class="mi">1</span> <span class="nt">&quot;up&quot;</span><span class="p">:</span> <span class="mi">1</span>
@ -747,12 +747,12 @@ number of returned pings depends on account's billing plan: 100 for free account
<dd>The API key is either missing or invalid.</dd> <dd>The API key is either missing or invalid.</dd>
</dl> </dl>
<h3>Example Request</h3> <h3>Example Request</h3>
<div class="highlight"><pre><span></span><code>curl --header <span class="s2">&quot;X-Api-Key: your-api-key&quot;</span> SITE_ROOT/api/v1/channels/
<div class="bash highlight"><pre><span></span><code>curl --header <span class="s2">&quot;X-Api-Key: your-api-key&quot;</span> SITE_ROOT/api/v1/channels/
</code></pre></div> </code></pre></div>
<h3>Example Response</h3> <h3>Example Response</h3>
<div class="highlight"><pre><span></span><code><span class="p">{</span>
<div class="json highlight"><pre><span></span><code><span class="p">{</span>
<span class="nt">&quot;channels&quot;</span><span class="p">:</span> <span class="p">[</span> <span class="nt">&quot;channels&quot;</span><span class="p">:</span> <span class="p">[</span>
<span class="p">{</span> <span class="p">{</span>
<span class="nt">&quot;id&quot;</span><span class="p">:</span> <span class="s2">&quot;4ec5a071-2d08-4baa-898a-eb4eb3cd6941&quot;</span><span class="p">,</span> <span class="nt">&quot;id&quot;</span><span class="p">:</span> <span class="s2">&quot;4ec5a071-2d08-4baa-898a-eb4eb3cd6941&quot;</span><span class="p">,</span>


+ 3
- 3
templates/docs/attaching_logs.html View File

@ -6,7 +6,7 @@ the request body, so you can inspect it later.</p>
<h2>Logging Command Output</h2> <h2>Logging Command Output</h2>
<p>In this example, we run <code>certbot renew</code>, capture its output, and submit <p>In this example, we run <code>certbot renew</code>, capture its output, and submit
the captured output to SITE_NAME:</p> the captured output to SITE_NAME:</p>
<div class="highlight"><pre><span></span><code><span class="ch">#!/bin/sh</span>
<div class="bash highlight"><pre><span></span><code><span class="ch">#!/bin/sh</span>
<span class="nv">m</span><span class="o">=</span><span class="k">$(</span>/usr/bin/certbot renew <span class="m">2</span>&gt;<span class="p">&amp;</span><span class="m">1</span><span class="k">)</span> <span class="nv">m</span><span class="o">=</span><span class="k">$(</span>/usr/bin/certbot renew <span class="m">2</span>&gt;<span class="p">&amp;</span><span class="m">1</span><span class="k">)</span>
curl -fsS --retry <span class="m">3</span> --data-raw <span class="s2">&quot;</span><span class="nv">$m</span><span class="s2">&quot;</span> PING_URL curl -fsS --retry <span class="m">3</span> --data-raw <span class="s2">&quot;</span><span class="nv">$m</span><span class="s2">&quot;</span> PING_URL
@ -16,7 +16,7 @@ curl -fsS --retry <span class="m">3</span> --data-raw <span class="s2">&quot;</s
<h2>In Combination with the <code>/fail</code> Endpoint</h2> <h2>In Combination with the <code>/fail</code> Endpoint</h2>
<p>We can extend the previous example and signal either success or failure <p>We can extend the previous example and signal either success or failure
depending on the exit code:</p> depending on the exit code:</p>
<div class="highlight"><pre><span></span><code><span class="ch">#!/bin/sh</span>
<div class="bash highlight"><pre><span></span><code><span class="ch">#!/bin/sh</span>
<span class="nv">url</span><span class="o">=</span>PING_URL <span class="nv">url</span><span class="o">=</span>PING_URL
@ -30,5 +30,5 @@ curl -fsS --retry <span class="m">3</span> --data-raw <span class="s2">&quot;</s
<h2>All in One Line</h2> <h2>All in One Line</h2>
<p>Finally, all of the above can be packaged in a single line. The one-line <p>Finally, all of the above can be packaged in a single line. The one-line
version can be put directly in crontab, without using a wrapper script.</p> version can be put directly in crontab, without using a wrapper script.</p>
<div class="highlight"><pre><span></span><code><span class="nv">m</span><span class="o">=</span><span class="k">$(</span>/usr/bin/certbot renew <span class="m">2</span>&gt;<span class="p">&amp;</span><span class="m">1</span><span class="k">)</span><span class="p">;</span> curl -fsS --data-raw <span class="s2">&quot;</span><span class="nv">$m</span><span class="s2">&quot;</span> <span class="s2">&quot;PING_URL</span><span class="k">$(</span><span class="o">[</span> <span class="nv">$?</span> -ne <span class="m">0</span> <span class="o">]</span> <span class="o">&amp;&amp;</span> <span class="nb">echo</span> -n /fail<span class="k">)</span><span class="s2">&quot;</span>
<div class="bash highlight"><pre><span></span><code><span class="nv">m</span><span class="o">=</span><span class="k">$(</span>/usr/bin/certbot renew <span class="m">2</span>&gt;<span class="p">&amp;</span><span class="m">1</span><span class="k">)</span><span class="p">;</span> curl -fsS --data-raw <span class="s2">&quot;</span><span class="nv">$m</span><span class="s2">&quot;</span> <span class="s2">&quot;PING_URL</span><span class="k">$(</span><span class="o">[</span> <span class="nv">$?</span> -ne <span class="m">0</span> <span class="o">]</span> <span class="o">&amp;&amp;</span> <span class="nb">echo</span> -n /fail<span class="k">)</span><span class="s2">&quot;</span>
</code></pre></div> </code></pre></div>

+ 4
- 4
templates/docs/bash.html View File

@ -4,7 +4,7 @@ have to do is make a HTTP request at an appropriate place in the script.
<a href="https://curl.haxx.se/docs/manpage.html">curl</a> and <a href="https://curl.haxx.se/docs/manpage.html">curl</a> and
<a href="https://www.gnu.org/software/wget/manual/wget.html">wget</a> <a href="https://www.gnu.org/software/wget/manual/wget.html">wget</a>
are two common command line HTTP clients you can use.</p> are two common command line HTTP clients you can use.</p>
<div class="highlight"><pre><span></span><code><span class="c1"># Sends a HTTP GET request with curl:</span>
<div class="bash highlight"><pre><span></span><code><span class="c1"># Sends a HTTP GET request with curl:</span>
curl -m <span class="m">10</span> --retry <span class="m">5</span> PING_URL curl -m <span class="m">10</span> --retry <span class="m">5</span> PING_URL
<span class="c1"># Silent version (no stdout/stderr output unless curl hits an error):</span> <span class="c1"># Silent version (no stdout/stderr output unless curl hits an error):</span>
@ -38,7 +38,7 @@ signal a failure. The following example:</p>
<li>if the certbot command is successful (exit code 0), sends HTTP GET to <code>PING_URL</code></li> <li>if the certbot command is successful (exit code 0), sends HTTP GET to <code>PING_URL</code></li>
<li>otherwise, sends HTTP GET to <code>PING_URL/fail</code></li> <li>otherwise, sends HTTP GET to <code>PING_URL/fail</code></li>
</ul> </ul>
<div class="highlight"><pre><span></span><code><span class="ch">#!/bin/sh</span>
<div class="bash highlight"><pre><span></span><code><span class="ch">#!/bin/sh</span>
<span class="c1"># Payload here:</span> <span class="c1"># Payload here:</span>
/usr/bin/certbot renew /usr/bin/certbot renew
@ -52,7 +52,7 @@ curl -m <span class="m">10</span> --retry <span class="m">5</span> <span class="
body. If the request body looks like a valid UTF-8 string, SITE_NAME body. If the request body looks like a valid UTF-8 string, SITE_NAME
will accept and store first 10KB of the request body.</p> will accept and store first 10KB of the request body.</p>
<p>In the below example, certbot's output is captured and submitted via HTTP POST:</p> <p>In the below example, certbot's output is captured and submitted via HTTP POST:</p>
<div class="highlight"><pre><span></span><code><span class="ch">#!/bin/sh</span>
<div class="bash highlight"><pre><span></span><code><span class="ch">#!/bin/sh</span>
<span class="nv">m</span><span class="o">=</span><span class="k">$(</span>/usr/bin/certbot renew <span class="m">2</span>&gt;<span class="p">&amp;</span><span class="m">1</span><span class="k">)</span> <span class="nv">m</span><span class="o">=</span><span class="k">$(</span>/usr/bin/certbot renew <span class="m">2</span>&gt;<span class="p">&amp;</span><span class="m">1</span><span class="k">)</span>
curl -fsS -m <span class="m">10</span> --retry <span class="m">5</span> --data-raw <span class="s2">&quot;</span><span class="nv">$m</span><span class="s2">&quot;</span> PING_URL curl -fsS -m <span class="m">10</span> --retry <span class="m">5</span> --data-raw <span class="s2">&quot;</span><span class="nv">$m</span><span class="s2">&quot;</span> PING_URL
@ -64,7 +64,7 @@ curl -fsS -m <span class="m">10</span> --retry <span class="m">5</span> --data-r
(if it does not already exist) and to retrieve its ping URL. (if it does not already exist) and to retrieve its ping URL.
Using this technique, you can write services that automatically Using this technique, you can write services that automatically
register with SITE_NAME the first time they run.</p> register with SITE_NAME the first time they run.</p>
<div class="highlight"><pre><span></span><code><span class="ch">#!/bin/bash</span>
<div class="bash highlight"><pre><span></span><code><span class="ch">#!/bin/bash</span>
<span class="nv">API_KEY</span><span class="o">=</span>your-api-key-here <span class="nv">API_KEY</span><span class="o">=</span>your-api-key-here


+ 1
- 1
templates/docs/cloning_checks.html View File

@ -16,7 +16,7 @@ an existing deployment in a new region. The SITE_NAME web interface does
not have a function to clone an entire project, but this can be done relatively not have a function to clone an entire project, but this can be done relatively
easily using the <a href="../api/">Management API</a> calls. Below is an example using Python easily using the <a href="../api/">Management API</a> calls. Below is an example using Python
and the requests library:</p> and the requests library:</p>
<div class="highlight"><pre><span></span><code><span class="kn">import</span> <span class="nn">requests</span>
<div class="python highlight"><pre><span></span><code><span class="kn">import</span> <span class="nn">requests</span>
<span class="n">API_URL</span> <span class="o">=</span> <span class="s2">&quot;SITE_ROOT/api/v1/checks/&quot;</span> <span class="n">API_URL</span> <span class="o">=</span> <span class="s2">&quot;SITE_ROOT/api/v1/checks/&quot;</span>
<span class="n">SOURCE_PROJECT_READONLY_KEY</span> <span class="o">=</span> <span class="s2">&quot;...&quot;</span> <span class="n">SOURCE_PROJECT_READONLY_KEY</span> <span class="o">=</span> <span class="s2">&quot;...&quot;</span>


+ 1
- 1
templates/docs/configuring_prometheus.html View File

@ -7,7 +7,7 @@ the Prometheus endpoint:</p>
<p><img alt="Project's API Keys" src="IMG_URL/prometheus_endpoint.png" /></p> <p><img alt="Project's API Keys" src="IMG_URL/prometheus_endpoint.png" /></p>
<h2>Update the prometheus.yml</h2> <h2>Update the prometheus.yml</h2>
<p>You can copy the Prometheus endpoint URL and add it to the Prometheus configuration:</p> <p>You can copy the Prometheus endpoint URL and add it to the Prometheus configuration:</p>
<div class="highlight"><pre><span></span><code> <span class="p p-Indicator">-</span> <span class="nt">job_name</span><span class="p">:</span> <span class="s">&quot;healthchecks&quot;</span>
<div class="yaml highlight"><pre><span></span><code> <span class="p p-Indicator">-</span> <span class="nt">job_name</span><span class="p">:</span> <span class="s">&quot;healthchecks&quot;</span>
<span class="nt">scrape_interval</span><span class="p">:</span> <span class="l l-Scalar l-Scalar-Plain">60s</span> <span class="nt">scrape_interval</span><span class="p">:</span> <span class="l l-Scalar l-Scalar-Plain">60s</span>
<span class="nt">scheme</span><span class="p">:</span> <span class="l l-Scalar l-Scalar-Plain">SITE_SCHEME</span> <span class="nt">scheme</span><span class="p">:</span> <span class="l l-Scalar l-Scalar-Plain">SITE_SCHEME</span>
<span class="nt">metrics_path</span><span class="p">:</span> <span class="l l-Scalar l-Scalar-Plain">/projects/45sd78-eeee-dddd-8888-b25a9887ecfd/metrics/NXyGzks4s8xcF1J-wzoaioyoqXIANGD0</span> <span class="nt">metrics_path</span><span class="p">:</span> <span class="l l-Scalar l-Scalar-Plain">/projects/45sd78-eeee-dddd-8888-b25a9887ecfd/metrics/NXyGzks4s8xcF1J-wzoaioyoqXIANGD0</span>


+ 1
- 1
templates/docs/csharp.html View File

@ -1,6 +1,6 @@
<h1>C#</h1> <h1>C#</h1>
<p>Below is an example of making a HTTP request to SITE_NAME from C#.</p> <p>Below is an example of making a HTTP request to SITE_NAME from C#.</p>
<div class="highlight"><pre><span></span><code><span class="k">using</span> <span class="p">(</span><span class="kt">var</span> <span class="n">client</span> <span class="p">=</span> <span class="k">new</span> <span class="n">System</span><span class="p">.</span><span class="n">Net</span><span class="p">.</span><span class="n">WebClient</span><span class="p">())</span>
<div class="csharp highlight"><pre><span></span><code><span class="k">using</span> <span class="p">(</span><span class="kt">var</span> <span class="n">client</span> <span class="p">=</span> <span class="k">new</span> <span class="n">System</span><span class="p">.</span><span class="n">Net</span><span class="p">.</span><span class="n">WebClient</span><span class="p">())</span>
<span class="p">{</span> <span class="p">{</span>
<span class="n">client</span><span class="p">.</span><span class="n">DownloadString</span><span class="p">(</span><span class="s">&quot;PING_URL&quot;</span><span class="p">);</span> <span class="n">client</span><span class="p">.</span><span class="n">DownloadString</span><span class="p">(</span><span class="s">&quot;PING_URL&quot;</span><span class="p">);</span>
<span class="p">}</span> <span class="p">}</span>

+ 9
- 9
templates/docs/http_api.html View File

@ -15,7 +15,7 @@ If the request body looks like a UTF-8 string, SITE_NAME stores the request body
<p>Successful responses will have the "200 OK" HTTP response status code and a short <p>Successful responses will have the "200 OK" HTTP response status code and a short
and simple string "OK" in the response body.</p> and simple string "OK" in the response body.</p>
<h2>Send a "success" Signal</h2> <h2>Send a "success" Signal</h2>
<div class="highlight"><pre><span></span><code>HEAD|GET|POST PING_ENDPOINT{uuid}
<div class="text highlight"><pre><span></span><code>HEAD|GET|POST PING_ENDPOINT{uuid}
</code></pre></div> </code></pre></div>
@ -23,12 +23,12 @@ and simple string "OK" in the response body.</p>
continuously running processes, is still running and healthy). The <code>uuid</code> parameter continuously running processes, is still running and healthy). The <code>uuid</code> parameter
is unique for each check.</p> is unique for each check.</p>
<p><strong>Example</strong></p> <p><strong>Example</strong></p>
<div class="highlight"><pre><span></span><code><span class="nf">GET</span> <span class="nn">/5bf66975-d4c7-4bf5-bcc8-b8d8a82ea278</span> <span class="kr">HTTP</span><span class="o">/</span><span class="m">1.0</span>
<div class="http highlight"><pre><span></span><code><span class="nf">GET</span> <span class="nn">/5bf66975-d4c7-4bf5-bcc8-b8d8a82ea278</span> <span class="kr">HTTP</span><span class="o">/</span><span class="m">1.0</span>
<span class="na">Host</span><span class="o">:</span> <span class="l">hc-ping.com</span> <span class="na">Host</span><span class="o">:</span> <span class="l">hc-ping.com</span>
</code></pre></div> </code></pre></div>
<div class="highlight"><pre><span></span><code><span class="kr">HTTP</span><span class="o">/</span><span class="m">1.1</span> <span class="m">200</span> <span class="ne">OK</span>
<div class="http highlight"><pre><span></span><code><span class="kr">HTTP</span><span class="o">/</span><span class="m">1.1</span> <span class="m">200</span> <span class="ne">OK</span>
<span class="na">Server</span><span class="o">:</span> <span class="l">nginx</span> <span class="na">Server</span><span class="o">:</span> <span class="l">nginx</span>
<span class="na">Date</span><span class="o">:</span> <span class="l">Wed, 29 Jan 2020 09:58:23 GMT</span> <span class="na">Date</span><span class="o">:</span> <span class="l">Wed, 29 Jan 2020 09:58:23 GMT</span>
<span class="na">Content-Type</span><span class="o">:</span> <span class="l">text/plain; charset=utf-8</span> <span class="na">Content-Type</span><span class="o">:</span> <span class="l">text/plain; charset=utf-8</span>
@ -41,19 +41,19 @@ OK
<h2>Send a "fail" Signal</h2> <h2>Send a "fail" Signal</h2>
<div class="highlight"><pre><span></span><code>HEAD|GET|POST PING_ENDPOINT{uuid}/fail
<div class="text highlight"><pre><span></span><code>HEAD|GET|POST PING_ENDPOINT{uuid}/fail
</code></pre></div> </code></pre></div>
<p>Signals to SITE_NAME that the job has failed. Actively signalling a failure <p>Signals to SITE_NAME that the job has failed. Actively signalling a failure
minimizes the delay from your monitored service failing to you receiving an alert.</p> minimizes the delay from your monitored service failing to you receiving an alert.</p>
<p><strong>Example</strong></p> <p><strong>Example</strong></p>
<div class="highlight"><pre><span></span><code><span class="nf">GET</span> <span class="nn">/5bf66975-d4c7-4bf5-bcc8-b8d8a82ea278/fail</span> <span class="kr">HTTP</span><span class="o">/</span><span class="m">1.0</span>
<div class="http highlight"><pre><span></span><code><span class="nf">GET</span> <span class="nn">/5bf66975-d4c7-4bf5-bcc8-b8d8a82ea278/fail</span> <span class="kr">HTTP</span><span class="o">/</span><span class="m">1.0</span>
<span class="na">Host</span><span class="o">:</span> <span class="l">hc-ping.com</span> <span class="na">Host</span><span class="o">:</span> <span class="l">hc-ping.com</span>
</code></pre></div> </code></pre></div>
<div class="highlight"><pre><span></span><code><span class="kr">HTTP</span><span class="o">/</span><span class="m">1.1</span> <span class="m">200</span> <span class="ne">OK</span>
<div class="http highlight"><pre><span></span><code><span class="kr">HTTP</span><span class="o">/</span><span class="m">1.1</span> <span class="m">200</span> <span class="ne">OK</span>
<span class="na">Server</span><span class="o">:</span> <span class="l">nginx</span> <span class="na">Server</span><span class="o">:</span> <span class="l">nginx</span>
<span class="na">Date</span><span class="o">:</span> <span class="l">Wed, 29 Jan 2020 09:58:23 GMT</span> <span class="na">Date</span><span class="o">:</span> <span class="l">Wed, 29 Jan 2020 09:58:23 GMT</span>
<span class="na">Content-Type</span><span class="o">:</span> <span class="l">text/plain; charset=utf-8</span> <span class="na">Content-Type</span><span class="o">:</span> <span class="l">text/plain; charset=utf-8</span>
@ -66,7 +66,7 @@ OK
<h2>Send a "start" Signal</h2> <h2>Send a "start" Signal</h2>
<div class="highlight"><pre><span></span><code>HEAD|GET|POST PING_ENDPOINT{uuid}/start
<div class="text highlight"><pre><span></span><code>HEAD|GET|POST PING_ENDPOINT{uuid}/start
</code></pre></div> </code></pre></div>
@ -77,12 +77,12 @@ optional but enables a few extra features:</p>
<li>SITE_NAME will detect if the job runs longer than its configured grace time</li> <li>SITE_NAME will detect if the job runs longer than its configured grace time</li>
</ul> </ul>
<p><strong>Example</strong></p> <p><strong>Example</strong></p>
<div class="highlight"><pre><span></span><code><span class="nf">GET</span> <span class="nn">/5bf66975-d4c7-4bf5-bcc8-b8d8a82ea278/start</span> <span class="kr">HTTP</span><span class="o">/</span><span class="m">1.0</span>
<div class="http highlight"><pre><span></span><code><span class="nf">GET</span> <span class="nn">/5bf66975-d4c7-4bf5-bcc8-b8d8a82ea278/start</span> <span class="kr">HTTP</span><span class="o">/</span><span class="m">1.0</span>
<span class="na">Host</span><span class="o">:</span> <span class="l">hc-ping.com</span> <span class="na">Host</span><span class="o">:</span> <span class="l">hc-ping.com</span>
</code></pre></div> </code></pre></div>
<div class="highlight"><pre><span></span><code><span class="kr">HTTP</span><span class="o">/</span><span class="m">1.1</span> <span class="m">200</span> <span class="ne">OK</span>
<div class="http highlight"><pre><span></span><code><span class="kr">HTTP</span><span class="o">/</span><span class="m">1.1</span> <span class="m">200</span> <span class="ne">OK</span>
<span class="na">Server</span><span class="o">:</span> <span class="l">nginx</span> <span class="na">Server</span><span class="o">:</span> <span class="l">nginx</span>
<span class="na">Date</span><span class="o">:</span> <span class="l">Wed, 29 Jan 2020 09:58:23 GMT</span> <span class="na">Date</span><span class="o">:</span> <span class="l">Wed, 29 Jan 2020 09:58:23 GMT</span>
<span class="na">Content-Type</span><span class="o">:</span> <span class="l">text/plain; charset=utf-8</span> <span class="na">Content-Type</span><span class="o">:</span> <span class="l">text/plain; charset=utf-8</span>


+ 2
- 2
templates/docs/javascript.html View File

@ -1,13 +1,13 @@
<h1>Javascript</h1> <h1>Javascript</h1>
<p>Below is an example of making a HTTP request to SITE_NAME from Node.js.</p> <p>Below is an example of making a HTTP request to SITE_NAME from Node.js.</p>
<div class="highlight"><pre><span></span><code><span class="kd">var</span> <span class="nx">https</span> <span class="o">=</span> <span class="nx">require</span><span class="p">(</span><span class="s1">&#39;https&#39;</span><span class="p">);</span>
<div class="js highlight"><pre><span></span><code><span class="kd">var</span> <span class="nx">https</span> <span class="o">=</span> <span class="nx">require</span><span class="p">(</span><span class="s1">&#39;https&#39;</span><span class="p">);</span>
<span class="nx">https</span><span class="p">.</span><span class="nx">get</span><span class="p">(</span><span class="s2">&quot;PING_URL&quot;</span><span class="p">);</span> <span class="nx">https</span><span class="p">.</span><span class="nx">get</span><span class="p">(</span><span class="s2">&quot;PING_URL&quot;</span><span class="p">);</span>
</code></pre></div> </code></pre></div>
<p>You can also send pings from a browser environment. SITE_NAME sets the <p>You can also send pings from a browser environment. SITE_NAME sets the
<code>Access-Control-Allow-Origin:*</code> CORS header, so cross-domain AJAX requests work.</p> <code>Access-Control-Allow-Origin:*</code> CORS header, so cross-domain AJAX requests work.</p>
<div class="highlight"><pre><span></span><code><span class="kd">var</span> <span class="nx">xhr</span> <span class="o">=</span> <span class="k">new</span> <span class="nx">XMLHttpRequest</span><span class="p">();</span>
<div class="js highlight"><pre><span></span><code><span class="kd">var</span> <span class="nx">xhr</span> <span class="o">=</span> <span class="k">new</span> <span class="nx">XMLHttpRequest</span><span class="p">();</span>
<span class="nx">xhr</span><span class="p">.</span><span class="nx">open</span><span class="p">(</span><span class="s1">&#39;GET&#39;</span><span class="p">,</span> <span class="s1">&#39;PING_URL&#39;</span><span class="p">,</span> <span class="kc">true</span><span class="p">);</span> <span class="nx">xhr</span><span class="p">.</span><span class="nx">open</span><span class="p">(</span><span class="s1">&#39;GET&#39;</span><span class="p">,</span> <span class="s1">&#39;PING_URL&#39;</span><span class="p">,</span> <span class="kc">true</span><span class="p">);</span>
<span class="nx">xhr</span><span class="p">.</span><span class="nx">send</span><span class="p">(</span><span class="kc">null</span><span class="p">);</span> <span class="nx">xhr</span><span class="p">.</span><span class="nx">send</span><span class="p">(</span><span class="kc">null</span><span class="p">);</span>
</code></pre></div> </code></pre></div>

+ 1
- 1
templates/docs/measuring_script_run_time.html View File

@ -7,7 +7,7 @@
<p>Signalling a start kicks off a separate timer: the job now <strong>must</strong> signal a <p>Signalling a start kicks off a separate timer: the job now <strong>must</strong> signal a
success within its configured "Grace Time", or it will get marked as "down".</p> success within its configured "Grace Time", or it will get marked as "down".</p>
<p>Below is a code example in Python:</p> <p>Below is a code example in Python:</p>
<div class="highlight"><pre><span></span><code><span class="kn">import</span> <span class="nn">requests</span>
<div class="python highlight"><pre><span></span><code><span class="kn">import</span> <span class="nn">requests</span>
<span class="n">URL</span> <span class="o">=</span> <span class="s2">&quot;PING_URL&quot;</span> <span class="n">URL</span> <span class="o">=</span> <span class="s2">&quot;PING_URL&quot;</span>


+ 3
- 3
templates/docs/monitoring_cron_jobs.html View File

@ -3,7 +3,7 @@
update your cron job command to send a HTTP request to SITE_NAME update your cron job command to send a HTTP request to SITE_NAME
after a job completes.</p> after a job completes.</p>
<p>Let's look at an example:</p> <p>Let's look at an example:</p>
<div class="highlight"><pre><span></span><code>$ crontab -l
<div class="bash highlight"><pre><span></span><code>$ crontab -l
<span class="c1"># m h dom mon dow command</span> <span class="c1"># m h dom mon dow command</span>
<span class="m">8</span> <span class="m">6</span> * * * /home/user/backup.sh <span class="m">8</span> <span class="m">6</span> * * * /home/user/backup.sh
</code></pre></div> </code></pre></div>
@ -40,7 +40,7 @@ increasingly important as you add more checks to your account.</p>
</ol> </ol>
<p>Finally, edit your cron job definition and append a curl or wget call <p>Finally, edit your cron job definition and append a curl or wget call
after the command:</p> after the command:</p>
<div class="highlight"><pre><span></span><code>$ crontab -e
<div class="bash highlight"><pre><span></span><code>$ crontab -e
<span class="c1"># m h dom mon dow command</span> <span class="c1"># m h dom mon dow command</span>
<span class="m">8</span> <span class="m">6</span> * * * /home/user/backup.sh <span class="o">&amp;&amp;</span> curl -fsS --retry <span class="m">5</span> -o /dev/null PING_URL <span class="m">8</span> <span class="m">6</span> * * * /home/user/backup.sh <span class="o">&amp;&amp;</span> curl -fsS --retry <span class="m">5</span> -o /dev/null PING_URL
</code></pre></div> </code></pre></div>
@ -81,7 +81,7 @@ Transient error is a timeout or an HTTP 5xx response code.</dd>
<h2>Looking up Your Machine's Time Zone</h2> <h2>Looking up Your Machine's Time Zone</h2>
<p>On modern GNU/Linux systems, you can look up the time zone using the <p>On modern GNU/Linux systems, you can look up the time zone using the
<code>timedatectl status</code> command and looking for "Time zone" in its output:</p> <code>timedatectl status</code> command and looking for "Time zone" in its output:</p>
<div class="highlight"><pre><span></span><code>$ timedatectl status
<div class="text highlight"><pre><span></span><code>$ timedatectl status
Local time: C  2020-01-23 12:35:50 EET Local time: C  2020-01-23 12:35:50 EET
Universal time: C  2020-01-23 10:35:50 UTC Universal time: C  2020-01-23 10:35:50 UTC


+ 6
- 6
templates/docs/php.html View File

@ -1,18 +1,18 @@
<h1>PHP</h1> <h1>PHP</h1>
<p>Below is an example of making a HTTP request to SITE_NAME from PHP.</p> <p>Below is an example of making a HTTP request to SITE_NAME from PHP.</p>
<div class="highlight"><pre><span></span><code><span class="x">file_get_contents(&#39;PING_URL&#39;);</span>
<div class="php highlight"><pre><span></span><code><span class="nb">file_get_contents</span><span class="p">(</span><span class="s1">&#39;PING_URL&#39;</span><span class="p">);</span>
</code></pre></div> </code></pre></div>
<p>If you would like to setup timeout and retry options, as discussed in the <p>If you would like to setup timeout and retry options, as discussed in the
<a href="../reliability_tips/">reliability tips section</a>, there is a <a href="../reliability_tips/">reliability tips section</a>, there is a
<a href="https://www.phpcurlclass.com/">curl package</a> available that lets you do that easily:</p> <a href="https://www.phpcurlclass.com/">curl package</a> available that lets you do that easily:</p>
<div class="highlight"><pre><span></span><code><span class="x">use Curl\Curl;</span>
<div class="php highlight"><pre><span></span><code><span class="k">use</span> <span class="nx">Curl\Curl</span><span class="p">;</span>
<span class="x">$curl = new Curl();</span>
<span class="x">$curl-&gt;setRetry(20);</span>
<span class="x">$curl-&gt;setTimeout(5);</span>
<span class="x">$curl-&gt;get(&#39;PING_URL&#39;);</span>
<span class="nv">$curl</span> <span class="o">=</span> <span class="k">new</span> <span class="nx">Curl</span><span class="p">();</span>
<span class="nv">$curl</span><span class="o">-&gt;</span><span class="na">setRetry</span><span class="p">(</span><span class="mi">20</span><span class="p">);</span>
<span class="nv">$curl</span><span class="o">-&gt;</span><span class="na">setTimeout</span><span class="p">(</span><span class="mi">5</span><span class="p">);</span>
<span class="nv">$curl</span><span class="o">-&gt;</span><span class="na">get</span><span class="p">(</span><span class="s1">&#39;PING_URL&#39;</span><span class="p">);</span>
</code></pre></div> </code></pre></div>

+ 5
- 5
templates/docs/powershell.html View File

@ -5,19 +5,19 @@
<p>Here is a simple PowerShell script that pings SITE_NAME. When scheduled to <p>Here is a simple PowerShell script that pings SITE_NAME. When scheduled to
run with Task Scheduler, it will essentially just send regular "I'm alive" messages. run with Task Scheduler, it will essentially just send regular "I'm alive" messages.
You can of course extend it to do more things.</p> You can of course extend it to do more things.</p>
<div class="highlight"><pre><span></span><code><span class="c1"># inside a PowerShell script:</span>
Invoke-RestMethod PING_URL
<div class="powershell highlight"><pre><span></span><code><span class="c"># inside a PowerShell script:</span>
<span class="nb">Invoke-RestMethod</span> <span class="n">PING_URL</span>
</code></pre></div> </code></pre></div>
<p>Save the above to e.g. <code>C:\Scripts\healthchecks.ps1</code>. <p>Save the above to e.g. <code>C:\Scripts\healthchecks.ps1</code>.
Then use the following command in a Scheduled Task to run the script:</p> Then use the following command in a Scheduled Task to run the script:</p>
<div class="highlight"><pre><span></span><code>powershell.exe -ExecutionPolicy bypass -File C:<span class="se">\S</span>cripts<span class="se">\h</span>ealthchecks.ps1
<div class="bat highlight"><pre><span></span><code>powershell.exe -ExecutionPolicy bypass -File C:\Scripts\healthchecks.ps1
</code></pre></div> </code></pre></div>
<p>In simple cases, you can also pass the script to PowerShell directly, <p>In simple cases, you can also pass the script to PowerShell directly,
using the "-command" argument:</p> using the "-command" argument:</p>
<div class="highlight"><pre><span></span><code><span class="c1"># Without an underlying script, passing the command to PowerShell directly:</span>
powershell.exe -command <span class="p">&amp;</span><span class="o">{</span>Invoke-RestMethod PING_URL<span class="o">}</span>
<div class="bat highlight"><pre><span></span><code># Without an underlying script, passing the command to PowerShell directly:
powershell.exe -command <span class="p">&amp;</span>{Invoke-RestMethod PING_URL}
</code></pre></div> </code></pre></div>

+ 3
- 3
templates/docs/powershell.md View File

@ -8,7 +8,7 @@ Here is a simple PowerShell script that pings SITE_NAME. When scheduled to
run with Task Scheduler, it will essentially just send regular "I'm alive" messages. run with Task Scheduler, it will essentially just send regular "I'm alive" messages.
You can of course extend it to do more things. You can of course extend it to do more things.
```bash
```powershell
# inside a PowerShell script: # inside a PowerShell script:
Invoke-RestMethod PING_URL Invoke-RestMethod PING_URL
``` ```
@ -16,14 +16,14 @@ Invoke-RestMethod PING_URL
Save the above to e.g. `C:\Scripts\healthchecks.ps1`. Save the above to e.g. `C:\Scripts\healthchecks.ps1`.
Then use the following command in a Scheduled Task to run the script: Then use the following command in a Scheduled Task to run the script:
```bash
```bat
powershell.exe -ExecutionPolicy bypass -File C:\Scripts\healthchecks.ps1 powershell.exe -ExecutionPolicy bypass -File C:\Scripts\healthchecks.ps1
``` ```
In simple cases, you can also pass the script to PowerShell directly, In simple cases, you can also pass the script to PowerShell directly,
using the "-command" argument: using the "-command" argument:
```bash
```bat
# Without an underlying script, passing the command to PowerShell directly: # Without an underlying script, passing the command to PowerShell directly:
powershell.exe -command &{Invoke-RestMethod PING_URL} powershell.exe -command &{Invoke-RestMethod PING_URL}
``` ```

+ 3
- 3
templates/docs/python.html View File

@ -1,6 +1,6 @@
<h1>Python</h1> <h1>Python</h1>
<p>If you are already using the requests library, it is convenient to also use it here:</p> <p>If you are already using the requests library, it is convenient to also use it here:</p>
<div class="highlight"><pre><span></span><code><span class="kn">import</span> <span class="nn">requests</span>
<div class="python highlight"><pre><span></span><code><span class="kn">import</span> <span class="nn">requests</span>
<span class="k">try</span><span class="p">:</span> <span class="k">try</span><span class="p">:</span>
<span class="n">requests</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="s2">&quot;PING_URL&quot;</span><span class="p">,</span> <span class="n">timeout</span><span class="o">=</span><span class="mi">10</span><span class="p">)</span> <span class="n">requests</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="s2">&quot;PING_URL&quot;</span><span class="p">,</span> <span class="n">timeout</span><span class="o">=</span><span class="mi">10</span><span class="p">)</span>
@ -11,7 +11,7 @@
<p>Otherwise, you can use the urllib module from Python 3 standard libary:</p> <p>Otherwise, you can use the urllib module from Python 3 standard libary:</p>
<div class="highlight"><pre><span></span><code><span class="kn">import</span> <span class="nn">socket</span>
<div class="python highlight"><pre><span></span><code><span class="kn">import</span> <span class="nn">socket</span>
<span class="kn">import</span> <span class="nn">urllib.request</span> <span class="kn">import</span> <span class="nn">urllib.request</span>
<span class="k">try</span><span class="p">:</span> <span class="k">try</span><span class="p">:</span>
@ -23,7 +23,7 @@
<p>You can include additional diagnostic information in the in the request body (for POST requests):</p> <p>You can include additional diagnostic information in the in the request body (for POST requests):</p>
<div class="highlight"><pre><span></span><code><span class="c1"># Passing diagnostic information in the POST body:</span>
<div class="python highlight"><pre><span></span><code><span class="c1"># Passing diagnostic information in the POST body:</span>
<span class="kn">import</span> <span class="nn">requests</span> <span class="kn">import</span> <span class="nn">requests</span>
<span class="n">requests</span><span class="o">.</span><span class="n">post</span><span class="p">(</span><span class="s2">&quot;PING_URL&quot;</span><span class="p">,</span> <span class="n">data</span><span class="o">=</span><span class="s2">&quot;temperature=-7&quot;</span><span class="p">)</span> <span class="n">requests</span><span class="o">.</span><span class="n">post</span><span class="p">(</span><span class="s2">&quot;PING_URL&quot;</span><span class="p">,</span> <span class="n">data</span><span class="o">=</span><span class="s2">&quot;temperature=-7&quot;</span><span class="p">)</span>
</code></pre></div> </code></pre></div>

+ 2
- 2
templates/docs/reliability_tips.html View File

@ -11,7 +11,7 @@ running worker process which pings SITE_NAME after each completed item. A stuck
request would block the whole process, so it is important to guard against.</p> request would block the whole process, so it is important to guard against.</p>
<p>Specifying the timeout depends on the tool you use. curl, for example, has the <p>Specifying the timeout depends on the tool you use. curl, for example, has the
<code>--max-time</code> (shorthand: <code>-m</code>) parameter:</p> <code>--max-time</code> (shorthand: <code>-m</code>) parameter:</p>
<div class="highlight"><pre><span></span><code><span class="c1"># Send a HTTP, 10 second timeout:</span>
<div class="bash highlight"><pre><span></span><code><span class="c1"># Send a HTTP, 10 second timeout:</span>
curl -m <span class="m">10</span> PING_URL curl -m <span class="m">10</span> PING_URL
</code></pre></div> </code></pre></div>
@ -21,7 +21,7 @@ curl -m <span class="m">10</span> PING_URL
client to retry failed requests several times.</p> client to retry failed requests several times.</p>
<p>Specifying the retry policy depends on the tool you use. curl, for example, has the <p>Specifying the retry policy depends on the tool you use. curl, for example, has the
<code>--retry</code> parameter:</p> <code>--retry</code> parameter:</p>
<div class="highlight"><pre><span></span><code><span class="c1"># Retry up to 5 times, uses an increasing delay between each retry (1s, 2s, 4s, 8s, ...)</span>
<div class="bash highlight"><pre><span></span><code><span class="c1"># Retry up to 5 times, uses an increasing delay between each retry (1s, 2s, 4s, 8s, ...)</span>
curl --retry <span class="m">5</span> PING_URL curl --retry <span class="m">5</span> PING_URL
</code></pre></div> </code></pre></div>


+ 1
- 1
templates/docs/ruby.html View File

@ -1,6 +1,6 @@
<h1>Ruby</h1> <h1>Ruby</h1>
<p>Below is an example of making a HTTP request to SITE_NAME from Ruby.</p> <p>Below is an example of making a HTTP request to SITE_NAME from Ruby.</p>
<div class="highlight"><pre><span></span><code><span class="nb">require</span> <span class="s1">&#39;net/http&#39;</span>
<div class="ruby highlight"><pre><span></span><code><span class="nb">require</span> <span class="s1">&#39;net/http&#39;</span>
<span class="nb">require</span> <span class="s1">&#39;uri&#39;</span> <span class="nb">require</span> <span class="s1">&#39;uri&#39;</span>
<span class="no">Net</span><span class="o">::</span><span class="no">HTTP</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="no">URI</span><span class="o">.</span><span class="n">parse</span><span class="p">(</span><span class="s1">&#39;PING_URL&#39;</span><span class="p">))</span> <span class="no">Net</span><span class="o">::</span><span class="no">HTTP</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="no">URI</span><span class="o">.</span><span class="n">parse</span><span class="p">(</span><span class="s1">&#39;PING_URL&#39;</span><span class="p">))</span>

+ 2
- 2
templates/docs/signalling_failures.html View File

@ -6,7 +6,7 @@ to you getting a notification.</p>
<h2>Shell Scripts</h2> <h2>Shell Scripts</h2>
<p>The below shell script sends either a "success" or "failure" ping depending on <p>The below shell script sends either a "success" or "failure" ping depending on
command's (certbot in this example) exit code:</p> command's (certbot in this example) exit code:</p>
<div class="highlight"><pre><span></span><code><span class="ch">#!/bin/sh</span>
<div class="bash highlight"><pre><span></span><code><span class="ch">#!/bin/sh</span>
<span class="nv">url</span><span class="o">=</span>PING_URL <span class="nv">url</span><span class="o">=</span>PING_URL
@ -20,7 +20,7 @@ curl --retry <span class="m">3</span> <span class="nv">$url</span>
<h2>Python</h2> <h2>Python</h2>
<p>Below is a skeleton code example in Python which signals a failure when the <p>Below is a skeleton code example in Python which signals a failure when the
work function returns an unexpected value or throws an exception:</p> work function returns an unexpected value or throws an exception:</p>
<div class="highlight"><pre><span></span><code><span class="kn">import</span> <span class="nn">requests</span>
<div class="python highlight"><pre><span></span><code><span class="kn">import</span> <span class="nn">requests</span>
<span class="n">URL</span> <span class="o">=</span> <span class="s2">&quot;PING_URL&quot;</span> <span class="n">URL</span> <span class="o">=</span> <span class="s2">&quot;PING_URL&quot;</span>
<span class="k">def</span> <span class="nf">do_work</span><span class="p">():</span> <span class="k">def</span> <span class="nf">do_work</span><span class="p">():</span>


+ 1
- 1
templates/front/snippets/php.html View File

@ -1,2 +1,2 @@
<div class="highlight"><pre><span></span><span class="x">file_get_contents(&#39;{{ ping_url }}&#39;);</span>
<div class="highlight"><pre><span></span><span class="nb">file_get_contents</span><span class="p">(</span><span class="s1">&#39;{{ ping_url }}&#39;</span><span class="p">);</span>
</pre></div> </pre></div>

Loading…
Cancel
Save