SPACE.LA
◀ music select
personal / tool / archived

WebCheck

A Python plugin for the Server Density monitoring agent that fetches a URL and scans the response for a string (such as a closing html tag) to detect fatal errors and broken pages; the sample config monitors Give.mobi and devin.la.

BPM
166
GRADE
B
LEVEL
5
RELEASES
0
YEARS
2011–2011

Looking For The Closing Tag

A site can return a 200 and still be broken. PHP would hit a fatal error halfway down the page, dump a warning and stop, and uptime checkers would still call it healthy. That kept happening to me.

So in August 2011 I wrote WebCheck, a Python plugin for the Server Density agent. It fetches a URL, runs a regex against the response body, and you tell it whether a match means good or bad. Three config parameters: url, find, result. Point find at the closing html tag with result true and you know the page rendered all the way to the bottom. Point it at "Fatal Error" with result false and you catch it the other way. As I put it then, "By looking for , we can know if we got a fatal error or not." You could add as many blocks to the sd-agent config as you wanted.

The sample config had two entries: Give.mobi, checking m.give.mobi, and devin.la, checking my own site. The mobile giving platform I'd been the sole developer on since 2008, and my blog.