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.

43 lines
1.1 KiB

  1. # Attaching Logs
  2. SITE_NAME ping endpoints accept HTTP HEAD, GET and POST request methods.
  3. When using HTTP POST, **you can include arbitrary payload in the request body**.
  4. If the request body looks like a UTF-8 string, SITE_NAME will log the first 10 kilobytes of
  5. the request body, so you can inspect it later.
  6. ## Logging Command Output
  7. In this example, we run `certbot renew`, capture its output, and submit
  8. the captured output to SITE_NAME:
  9. ```bash
  10. #!/bin/sh
  11. m=$(/usr/bin/certbot renew 2>&1)
  12. curl -fsS --retry 3 -X POST --data-raw "$m" PING_URL
  13. ```
  14. ## In Combination with the `/fail` Endpoint
  15. We can extend the previous example and signal either success or failure
  16. depending on the exit code:
  17. ```bash
  18. #!/bin/sh
  19. url=PING_URL
  20. m=$(/usr/bin/certbot renew 2>&1)
  21. if [ $? -ne 0 ]; then url=$url/fail; fi
  22. curl -fsS --retry 3 -X POST --data-raw "$m" $url
  23. ```
  24. ## All in One Line
  25. Finally, all of the above can be packaged in a single line. The one-line
  26. version can be put directly in crontab, without using a wrapper script.
  27. ```bash
  28. m=$(/usr/bin/certbot renew 2>&1); curl -fsS -X POST --data-raw "$m" "PING_URL$([ $? -ne 0 ] && echo -n /fail)"
  29. ```