Scenario: Running MMI APIs to gather diagnostic information
XYZ Corporation experiences an issue in the IBM® Control Desk environment and the system administrator opens a Problem Management Report (PMR) with IBM Technical Support. IBM Technical Support and Development determine that there is a need to gather diagnostic information for particular resources from the customer's Maximo® environment.
IBM Technical Support and Development review the available resources in the Monitor Environment Information dialog of the Logging application and determine that the system administrator should run a particular MMI API. In some cases, if an API that is needed to collect the information is not readily available, IBM Development might provide a script that can collect the needed information.
IBM instructs the system administrator to run the API in a web browser by entering a URL similar to http://<host>:<port>/maximo/oslc/members/<memberid>/<api>. The system administrator submits the resulting diagnostic output with the PMR for analysis by IBM.
API output
When the system administrator runs the MMI API by entering the required URL in the browser, the output displays directly in the browser.
The output is not formatted or easily readable unless the browser has a JSON viewer add-on or extension installed. JSON viewers are available for the Mozilla Firefox and Google Chrome browsers. Microsoft Internet Explorer does not have a JSON viewer. JSON viewers can be located by opening the browser and doing a web search on JSON viewer. For example, Firefox has an add-on that is called JSONView. Chrome has an extension that is called JSONView.
The system administrator saves the output in the browser to a text file and submits the file with the PMR for analysis by IBM.
Writing scripts
Prerequisite skills
- System administrator level
- Experience with calling the REST API
- Programming and script language skills
Sample script
from psdi.server import MXServer
if request.getWhere() is not None and request.getWhere().get("spi:topic") is not None:
eventTopicToFind = request.getWhere().get("spi:topic")[0]
eventTopic = MXServer.getMXServer().getEventTopicTree().findEventTopic(eventTopicToFind)
listenerCount = eventTopic.getListenerCount()
br.setProperty("spi:listenerCount",listenerCount)
- request - The MMI API request object. The script uses the request object to determine the object event type that the user is interested in.
- br - The response that the API returns to the user.
The script uses the request object to determine the object event type by using the Where parameter in eventTopicToFind = request.getWhere().get("spi:topic")[0].
The br parameter has a simple setProperty(string,any) interface that is used by the script to gather the information it will send back to the user. The script uses the br setProperty API to set the listenerCount integer to the br object. This object is used to format the response to the API consumer.
The script can be added to the MMI by opening the Monitor Environment Information dialog in the Logging application, selecting New Row, and specifying the script name in the Class or Script Name field. The script must be specified in the qualified notation, script:<script name>, for example, script:LISTENERS.
The script is run by using the URL syntax http://<host>:<port>/maximo/oslc/members/<memberid>/<event topic context>?oslc.where=spi:topic="maximo.asset.add".
Example URL: http://127.0.0.1/maximo/oslc/members/OS4zMi4yMS4xMzcvTVhTZXJ2ZXI-/eventtopic?oslc.where=spi:topic="maximo.asset.add"
See the Maximo Management Interface wiki for information on running MMI APIs and viewing and submitting output to IBM.