Tuesday, February 21, 2012

An InterMapper Probe in Python

InterMapper ships with Python -- the recent releases come with Python 2.7, making extending it using Python a natural choice.

So when a colleague diagnosed a problem between Cisco ACE and some application servers it load-balances for, I thought about turning his curl script into a probe. Previously I tried to put curl on the Windows 2008 server where our InterMapper software runs, but I didn't get far with that effort. I turned to Python since then when I need to do anything with InterMapper, like writing notifiers and probes.

My notifier and probe code are available on Google Code. My first probe is one that talks to the Cisco xml_agent process, which seems to be supported in more and more Cisco boxes. The probe itself is in the xmlprobe.xml file -- Simple installation instructions are found in there. It connects to the agent on a Cisco box via HTTPS and runs a command configurable either in a configuration file or via InterMapper's "set probe" dialog.

Lessons learned in writing this simple probe: I really hope InterMapper has more documentation about the details of the probe syntaxes. For example, in the section, the arg value doesn't seem to require quotes around it, which leaves the double-quote to be used for quoting individual command line parameters. Also, Windows handles quoted command line parameters differently than Linux -- That caused my much grief as the command used in this case is "show xlate global %(vip)s | count" and the vertical bar caused error when InterMapper runs the probe although it runs fine manually under Cygwin. After searching around in the InterMapper support forums, I happened upon an earlier Q&A topic and found out how to turn on the detailed logging for troubleshooting a command line probe, which revealed the error that I did not see in my manual command line tests.

This probe still looks messy: The JSON configuration data has to be edited manually. It seems that a web-based front-end tool would be helpful. It seems that InterMapper could extend its HTTP API so that the remote access client could be extended through server side plug-ins.

No comments:

Post a Comment