apache


Using Perl to Ping an AJP Service (Jetty)

One of my recent Citrix KB articles was about creating a Netscaler user monitor (which are Perl based) to allow for a more intelligent type of monitoring for AJP based services than a standard TCP based socket open/close check.  The AJP Protocol Reference is good enough to provide a method for doing a simple and lightweight PING/PONG request/response.  Unfortunately, the format of the packets is such that they cannot (currently) be added as a TCP-ECV monitor, essentially because of restrictions on non-printable characters being inserted into those monitors (believe me, I tried multiple ways to insert the required characters).

So, I set off to write the Perl version of such a monitor, but before I did I needed a simple script outside the Netscaler for debugging purposes – having to rely on the monitor for testing is needlessly cumbersome, better to get it functioning first and then add it to the monitor code later.  Also, because of that approach, the script is perfectly usable as a generic test and is written almost entirely as a self-contained sub-routine (anyone that has seen the user monitor structure on the Netscaler will instantly recognize that also).  Hence, I think it would be very easy to add the subroutine to a syslog or other monitoring type script.  Therefore I decided to share the more generic version here.  The full code is after the jump, if you prefer a more discrete or forkable version, you can find it on github here: ajp.pl

I have the acknowledgements in the code also, but to get them in before the jump, they were invaluable: