Scripts (Python, Node, any language)
If your job is a script, send the ping at the very end — after the real work has finished successfully. Any HTTP client works; here are the two most common.
Copy your monitor’s ping URL from the dashboard and keep it in an environment variable rather than hardcoding it.
Python
Section titled “Python”Using requests (pip install requests):
import osimport requests
PING_URL = os.environ["DMJR_PING_URL"]
def main(): # ... do the work ... pass
if __name__ == "__main__": main() # if this raises, we never reach the ping requests.get(PING_URL, timeout=10)Because the ping is the last line, it only runs if main() completed without raising. If the work throws, the script exits non-zero, no ping is sent, and you get alerted.
Node.js
Section titled “Node.js”const PING_URL = process.env.DMJR_PING_URL;
async function main() { // ... do the work ...}
main() .then(() => fetch(PING_URL)) // ping only after success .catch((err) => { console.error(err); process.exit(1); // fail loudly, skip the ping });The rule
Section titled “The rule”Whatever the language, the pattern is the same: do the work first, ping last, and only if nothing failed. Don’t wrap the ping in a finally/always block — that would report success even when the job errored.