Adding shell example

This commit is contained in:
Pēteris Caune 2020-01-29 13:39:41 +02:00
parent d29b0050a3
commit 564f69aca5
No known key found for this signature in database
GPG Key ID: E28D7679E9A9EDE2
2 changed files with 30 additions and 0 deletions

View File

@ -3,6 +3,20 @@
Requesting the <code>/fail</code> URL will immediately mark the check as "down". Requesting the <code>/fail</code> URL will immediately mark the check as "down".
You can use this feature to minimize the delay from your monitored service failing You can use this feature to minimize the delay from your monitored service failing
to you getting a notification.</p> to you getting a notification.</p>
<h2>Shell Scripts</h2>
<p>The below shell script sends sends either a "success" or "failure" ping depending on
command's (certbot in this example) exit code:</p>
<div class="highlight"><pre><span></span><span class="ch">#!/bin/sh</span>
<span class="nv">url</span><span class="o">=</span>PING_URL
/usr/bin/certbot renew
<span class="k">if</span> <span class="o">[</span> <span class="nv">$?</span> -ne <span class="m">0</span> <span class="o">]</span><span class="p">;</span> <span class="k">then</span> <span class="nv">url</span><span class="o">=</span><span class="nv">$url</span>/fail<span class="p">;</span> <span class="k">fi</span>
curl --retry <span class="m">3</span> <span class="nv">$url</span>
</pre></div>
<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>

View File

@ -5,6 +5,22 @@ Requesting the `/fail` URL will immediately mark the check as "down".
You can use this feature to minimize the delay from your monitored service failing You can use this feature to minimize the delay from your monitored service failing
to you getting a notification. to you getting a notification.
## Shell Scripts
The below shell script sends sends either a "success" or "failure" ping depending on
command's (certbot in this example) exit code:
```bash
#!/bin/sh
url=PING_URL
/usr/bin/certbot renew
if [ $? -ne 0 ]; then url=$url/fail; fi
curl --retry 3 $url
```
## Python ## Python
Below is a skeleton code example in Python which signals a failure when the Below is a skeleton code example in Python which signals a failure when the