Curl script in cron vs. uptime monitoring: what it misses
A cron job that fetches a URL with curl and sends a mail when it fails is how many people start monitoring, and for a long time it is enough. The trouble shows up at the edges: the cases where the script cannot tell you what is wrong, because it is part of what went wrong.
Why a script might not be enough
- It is one place. A script runs on one machine. If that machine is down, loses its network or has its mail stopped, nothing is sent, and silence looks like a quiet day. The check that fails is the one you never see fail.
- It cannot tell a bad answer from no answer. A timeout, a refused connection, a name that does not resolve and a certificate that has expired are different problems; the script only reports what it was written to expect.
- It tends to report every failure or none. Without keeping state between runs, it either mails every minute while the site is down, or only on a rule you built yourself and now maintain. One slow response at 3 a.m. is a page.
- It has no memory. What was the response time last Tuesday? How long was the outage? The script does not know, unless you also built storage and a chart.
- It checks one thing. A certificate that expires in two days, a redirect that no longer lands, a JSON field that is empty or a header that went missing each need another check, written and tested by you.
How Pingsured answers it
- A checker you do not have to watch. Checks run on our servers in multiple locations around the globe. A check we could not run is recorded as unknown, not as your site being down, so a fault on our side sends no false alarm.
- Thresholds. Alerts fire when a ping crosses a threshold such as 3 of the last 5 checks, per location, and again when it recovers.
- History. Every check's result and response time is kept, split into DNS, connection, TLS and time to first byte.
- More than a status code. The same ping can check the content of the answer, its headers and the certificate.
When the script fits
Pingsured checks public addresses by GET or HEAD request. A service that is only reachable from inside a network, or a check that needs your own logic, is a job for a script, and a good one to keep. The simplest split is: leave the inside to your scripts and let a service watch what visitors see from outside, so the failure that silences the script is not also the failure that silences the monitor.
Questions to ask of any monitor, bought or built
- Who is told when the checker itself stops running?
- Does the alert path (mail, chat, phone) depend on the systems being checked?
- Is a single failed check an alert, or is there a threshold?
- Can I see what happened last week, not only now?
- How many places does it check from?