I am responsible for DataPower Probe since I joined DataPower (Compiler) team 7 years ago. Just looked at the 18 Probe related APARs from the last 4 years and saw that I did fix half of them.
Probe is a very useful debugging tool in DataPower development. I have answered many Probe related questions in developerWorks DataPower forum over the last years. Last Thursday posting
was the first time I have seen request on determining whether Probe is enabled or not INSIDE a stylesheet being executed. Ted's usecase is on different amount of logging he wants to have depending on Probe is enabled or not. This may be solved alternatively via log level, but the question on how to determine Probe status in stylesheet was interesting.
OK, with Probe being enabled we are talking about dev and/or functional test DataPower boxes -- do not enble Probe in performance test or prod environments (InfoCenter is very clear on this).
Accessing the XML Management interface is possible from within a stylesheet:
Doing SOMA call that way to just query Probe state is possible, but would add quite some latency to XSLT processing.
DataPower stylesheets are able to access all status providers via "dp:variable('var://service/system/status/___')":
The status provider which helps on determining Probe status is "Stylesheet Status" [dp:variable('var://service/system/status/StylesheetStatusSimpleIndex')]. I did execute a stylesheet via coproc2 service two times, and "Stylesheet Status" shows "coproc2.xsl" needed by coproc2 service and two temporary stylesheets (one new gets created each time a coproc2 execution happens).
As you can see there is an indication on whether a stylesheet is streamable (xslt-s-f-...) or not streamable (xslt-f-...). Then I did enable Probe for coproc2 service and did another coproc2 request:
As you can see besides the (new) temporary stylesheet "webgui:///msdebug-client.xsl" is displayed. This stylesheet is used by DataPower internally to capture all the data for each context of a Transaction with Probe enabled. And you can see that now the (same) stylesheet that was streamable before is marked as not streamable (xslt-f-...). Reason is that enabling Probe automatically converts all "PIPE" contexts to "real" contexts and disables all streaming processing.
So for stylesheets that are streamable you might just look for streamability indicator in Stylesheet cache, but the vast majority of stylesheets is NOT streamable. For these we can look for the presence of "webgui:///msdebug-client.xsl" in XML manager of the stylesheet's service.
Now I turned off Probe for coproc2 service again and did another coproc2 transaction:
As you can see the new temporary stylesheet has the streambility indicator again (xslt-s-f-...), but "webgui:///msdebug-client.xsl" is still present. Reason is that disabling Probe does not remove that stylesheet from stylesheet cache.
So in order to use "webgui:///msdebug-client.xsl" as Probe status indicator we need to do:
1) on "enable" Probe, nothing
2) on "disable" Probe, flush service's XML Manager's Stylesheet cache
xi52(config)# clear xsl
Usage: clear xsl cache <xml-mgr>
xi52(config)# clear xsl cache coproc2xform
Cleared cache of XML manager 'coproc2xform'
3) In order to not get fooled by another service's Probe enabled with same XML Manager, use a XML Manager specific to each service
In order to look for presence of "webgui:///msdebug-client.xsl" in stylesheet cache of XSLT's service's XML Manager we need to determine its name. This can be easily done by "dp:variable('var://service/xmlmgr-name')". This stylesheet now does put all pieces together, and returns a simple true/false response. In addition it measures the time needed for the test, measured in milliseconds. Here you see that it takes 1msec on XI52 with Probe enabled:
$ echo "<foobar/>" | coproc2 ssstat.xsl - http://firestar:2223 ; echo
And this is stylesheet ssstate.xsl:
Hermann<myBlog/><myTweets/> | <GraphvizFiddle/> | <xqib/> | <myCE/><myFrameless/>