Skip to content

Instantly share code, notes, and snippets.

@swissrouting
Forked from C-Otto/sh
Last active October 29, 2022 00:02
Show Gist options
  • Star 2 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save swissrouting/111d4a615d670ddf8d11eaa8a60eacca to your computer and use it in GitHub Desktop.
Save swissrouting/111d4a615d670ddf8d11eaa8a60eacca to your computer and use it in GitHub Desktop.
Shell script that sends a health check ping to the Amboss API
#!/bin/bash
# Sends a health check ping to the Amboss API.
# Docs: https://docs.amboss.space/api/monitoring/health-checks
URL="https://api.amboss.space/graphql"
NOW=$(date -u +%Y-%m-%dT%H:%M:%S%z)
echo "Timestamp: ${NOW}"
SIGNATURE=$(lightning-cli signmessage "$NOW" | jq -r .zbase)
echo "Signature: ${SIGNATURE}"
JSON="{\"query\": \"mutation HealthCheck(\$signature: String!, \$timestamp: String!) { healthCheck(signature: \$signature, timestamp: \$timestamp) }\", \"variables\": {\"signature\": \"$SIGNATURE\", \"timestamp\": \"$NOW\"}}"
echo "Sending ping..."
echo "$JSON" | curl -sSf --data-binary @- -H "Content-Type: application/json" -X POST $URL
@swissrouting
Copy link
Author

This version is for CLN/c-lightning/Core Lightning.
For the original LND version see: https://gist.github.com/C-Otto/cd5d7b0e67fc2e3e212cf13a558b101f

@erikarvstedt
Copy link

Hint: Use curl -sSf so that you get an error description (instead of no output) when curl fails.

@swissrouting
Copy link
Author

Hint: Use curl -sSf so that you get an error description (instead of no output) when curl fails.

Thanks for the hint @erikarvstedt! I updated the gist with these flags.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment