5 curl One-Liners for Quick Server Diagnostics
- 1. Check SSL Certificate Expiry
- 2. Measure Response Time
- 3. Get All DNS Records at Once
- 4. Check HTTP Headers Without Downloading
- 5. Test if a Port is Open
- Bonus: Chain Them in a Monitoring Script
When something breaks in production, these are the curl commands I actually reach for. No extra tools needed.
1. Check SSL Certificate Expiry
echo | openssl s_client -servername example.com -connect example.com:443 2>/dev/null | openssl x509 -noout -dates
Or hit the API: curl http://5.78.129.127/api/ssl/example.com
2. Measure Response Time
curl -s -o /dev/null -w "DNS: %{time_namelookup}s\nConnect: %{time_connect}s\nTLS: %{time_appconnect}s\nTotal: %{time_total}s\n" https://example.com
3. Get All DNS Records at Once
dig +short example.com ANY
Or for clean JSON: curl http://5.78.129.127/api/dns/lookup/example.com
4. Check HTTP Headers Without Downloading
curl -sI https://example.com | head -20
Look for security headers: X-Frame-Options, Content-Security-Policy, Strict-Transport-Security.
5. Test if a Port is Open
curl -s --connect-timeout 3 telnet://example.com:5432 && echo "open" || echo "closed"
Or more reliably: nc -zv example.com 5432 2>&1
Bonus: Chain Them in a Monitoring Script
#!/bin/bash
for domain in app.example.com api.example.com; do
status=$(curl -s -o /dev/null -w "%{http_code}" --max-time 5 "https://$domain")
[ "$status" != "200" ] && echo "ALERT: $domain returned $status"
done
All the API endpoints mentioned above are part of DevToolKit — 28 free endpoints for DNS, SSL, email validation, QR codes, and more: http://5.78.129.127/api/