Creating the python display is easy, but not quite as easy as writing a client. Unfortunately, none of the packages are built by default in the online release (yet). They have been requested for release, but it will take a while before they end up on the online system.
Please note: The display does not have to be run inside the online system. However, if you decide that you want this display to be part of the shifters standard utilities -- and it must run even if the online offline connection is cut, you'll have to do something special (but documented!)..
Below describes how to write a very simple test program that will generate a monitor item. You can use this pattern to integrate monitor information into a more complex monitor program.
import l3xmonitor_util_module import timedisp = l3xmonitor_util_module.monitor_display_relay() test_item = disp.get_item("tester", "count") while 1: disp.query_monitor_server() if len(test_item) == 0: print "No data from the MS" else: print "Count value is %s" % test_item[0] time.sleep(1)
Short explanation of the relevant lines of code:
Often the data that comes back from the monitor server contains XML that needs to be further parsed. This example shows how to write a small bit of python code that gets the And/Or term fire rate for a particular term from the TFW monitor information.
Download the file test.py and put it on the online system. To get it to work, do the following:
setup D0RunII p15.02.03 setup python python test.py
You should see output that looks like the following:
d0ol40.fnal.gov> python test.py /d0dist/dist/releases/p15.02.03/lib/Linux2.4-GCC_3_1/l3xmonitor_util_module.py:2: RuntimeWarning: Python C API version mismatch for module l3xmonitor_util_modulec: This Python has API version 1011, module l3xmonitor_util_modulec has version 1010. import l3xmonitor_util_modulec 207 47712.4 207 47712.6 207 47712.6 207 47712.4 207 47712.4 207 47712.6
The error is due to a new version of python in a release built against an older version of python. It can safely be ignored, and when a newer release built against a more modern version of python appears this will go away of its own accord. You can also build the monitor module on your own if you like.
The python parsing code is fairly simple. The instructions for accessing the XML DOM and the minidom parser can be found on the python documentation site.