Lessons in tooling: OBI 11g

A recent post by Oracle Business Intelligence (OBI) specialist Robin Moffatt raises several low-level technical questions that deserve a little attention.

The title of the article is “Scripted OBI 11g Linux startup/shutdown“. Moffatt begins, “OBI 11g ships with a one-click startup option for Windows installations, but not for Linux (*NIX).” He has no explanation for this difference, “[o]ther than to reenforce the stereotype of the two OSs being easy/difficult to work with respectively.” Neither do I.

Compounding the curious situation, as Moffatt further points out, is that the Windows script uses Ant, so it “can easily be made to run on Linux.” This is no idle speculation; he goes on to provide just such a script, along with clear explanations for its construction and use–exactly what a conscientious commentator should do. In fact, he materially improves on the Windows script Oracle provides, in several ways which he lucidly describes. I applaud him. Moffatt continues with several other helpful remarks on related matters that I urge you to read for yourself.

All this leaves me with a handful of loose ends of possible interest to “Real User Monitoring” readers:

  • Why does Oracle provide a more complete product to Windows customers than Unix ones? Perhaps more to the point is to express this as a tip: Unix customers, be aware that, when you feel you’re missing a crucial part in comparison to a Windows-based solution, you might be right. A good solution–perhaps one even better than the vendor provides–might be only a few lines of
    scripting away.
  • Why Ant? Well, yes, of course, Ant is well established in Oracle’s Java world, and quite capable in roles such as this. From a DevOps perspective, Ant is about construction, though; starting and stopping OBI services seems to me to be fitter material for a configuration tool like Puppet or CFengine. On one hand, Ant seems up to Oracle’s use of it, as well as extensions such as Moffatt’s, and I’m all in favor of software that works. Over a longer term, Puppet and CFengine might make maintenance even easier. On yet a third hand, Ant has been picking up features that make it progressively more fit for this kind of configuration duty. Can someone who knows OBI better than I do comment on these possibilities?
  • The scripting Moffatt provides has a few lessons for us.

Moffatt’s scripting has several virtues: it works, which is paramount; it parallels what Oracle supplies for Linux, to minimize the effort should someone choose to re-consolidate the two; and, as already mentioned, it has better functionality than Oracle’s script.

Modernize your bash

Even in such a small example, though, I notice room for possible improvement. Part of the way Moffatt improves on Oracle is, as he puts it, to “[a]utomagically determine listening ports”. This takes only a couple of lines, which retrieve values embedded in configuration files. One of these computations is

In English words, this amounts to, “look for the ListenPort assignment, and pull out the value after the equals”.

One possible rewrite of this assignment is

Moffatt’s original grep- awk formulation has much tradition behind it: there’s a lot of existing bash code that looks like that. I’ve always thought that the sed-based rewrite above more clearly expresses the syntax, and it’s certainly more concise and uses only one external process, rather than two.

In a different direction, one can also use

While this requires more typing than Moffatt’s original, I find it stronger in a couple of regards. It focuses attention on the regular expression implicit in $PROPERTY_FILE, and eliminates the slightly magical awk invocation. Also, there are bash executables available for Windows, and scripting which avoids externals like grep and awk tends to be easier to port to Windows.

Similar comments apply to Moffat’s parsing of an XML configuration file with awk. Friends should try to prevent friends from parsing XML “by hand”–except that sometimes the alternative is even worse. It’s easy to speculate about the fragility of export OPMN_PORT=`grep --after-context 1 notification-server $INSTANCE_HOME/config/OPMN/opmn/opmn.xml |grep remote|awk -F'"' '{ print $4}'`, which Moffatt has provided. Until XMLStarlet, xmllint, xpath, xsltproc or similar are more widely distributed, though, we’ll all continue to have occasion to hack these quick little data retrievals.