We'd then supply external scripts to be executed on up/down. We originally used this to merely start or stop a ucarp instance, and this would then promote and demote mysql instances as needed. We later realised this can do more interesting things, like modify haproxy configs (use sed to comment/uncomment server lines and reload haproxy), or update ipsets for firewalls (monitor is on the mariadb server itself in order to only have one monitor rather than from every haproxy "client") so that connections are *rejected* from the clients resulting in haproxy declaring dead. That way you merely need to monitor for tcp connectability from haproxy side, reducing the haproxy test to a simple "is tcp available". We've since implemented similar strategies for a bunch of other protocols (like smtp, imap, and pop3 as well).
The haproxy have the `agent check` option for this purpose. But I would not use a third weel for checking of the server up and running.