Real Time Job Monitor in Java

One thing that has always annoyed me in MicroStrategy is that the Job Monitor requires a manual refresh.  Sometimes when debugging issues, request come through so quickly, I have to sit there and spam the refresh button to catch a glimpse.  I could always look at the execution log in Enterprise Manager, but that’s usually less efficient.  Today I’ll share a quick Java application I built the other day to poll the Job Monitor every second to create a Real Time Job Monitor.

DISCLAIMER: I only use this in specific debugging scenarios and I don’t leave it running all day.  I haven’t noticed any system performance impacts while it’s running, but every environment is different.  Please tread carefully when running this code against a Production environment.

I’m not a particularly accomplished Java Developer, so this sample (and other’s I’ll inevitably share) are mostly hacked together via trial and error.  There are probably much better ways to accomplish this task, and please share any suggestions in the comments.

This particular code is very basic, and surely lots of features and enhancements could be added to make this a more robust Real Time Job Monitor.  But for now, it serves as a Proof of Concept, and a handy program in a pinch.

package JobMonitor;

import java.awt.*;
import java.awt.event.*;
import java.util.TimerTask;
import java.util.Timer;
import javax.swing.*;
import java.util.Date;

import com.microstrategy.web.objects.WebIServerSession;
import com.microstrategy.web.objects.WebObjectsException;
import com.microstrategy.web.objects.WebObjectsFactory;
import com.microstrategy.web.objects.admin.monitors.EnumWebMonitorType;
import com.microstrategy.web.objects.admin.monitors.Job;
import com.microstrategy.web.objects.admin.monitors.JobResults;
import com.microstrategy.web.objects.admin.monitors.JobSource;
import com.microstrategy.webapi.EnumDSSXMLLevelFlags;

public class JobMonitor extends JApplet {
private static WebObjectsFactory factory = null;
private static WebIServerSession serverSession = null;
private static JobSource source = null;
JPanel jPanel1 = new JPanel();
JButton jButton1 = new JButton("");
  static JTextArea jText = new JTextArea("");

  //Construct the applet
  public JobMonitor() {
  //Initialize the applet
  public void init() {
    try {
    catch(Exception e) {
  //Component initialization
  private void jbInit() throws Exception {
    this.setSize(new Dimension(800,500));
    jButton1.setText("Start Monitor");
    jButton1.addActionListener(new java.awt.event.ActionListener() {
      public void actionPerformed(ActionEvent e) {
    jButton1.setBounds(new Rectangle(700, 0, 100, 50));
    this.getContentPane().add(jPanel1, BorderLayout.CENTER);
    jText.setBounds(new Rectangle(0, 0, 700, 500));
  //Get Applet information
  public String getAppletInfo() {
    return "Applet Information";
  //Get parameter info
  public String[][] getParameterInfo() {
    return null;

  void jButton1_actionPerformed(ActionEvent e) {

// Sends the request to Intelligence Server to retrieve job information
int delay = 1000;   // delay for 1 sec.
int period = 1000;  // repeat every sec.
Timer timer = new Timer();
timer.scheduleAtFixedRate(new TimerTask() {
       public void run() {
        JobResults results = source.getJobs();
String[] returns = new String[results.getCount()];

if (results.getCount() != 0) {
     for (int i=0; i < results.getCount(); i++) {
          Job singleJob = results.get(i);
          returns[i] = singleJob.getJobID() + ": " + singleJob.getUserName() + " - " + (singleJob.getJobStatus() == 1 ? "Executing" : singleJob.getJobStatus() == 2 ? "Waiting" : singleJob.getJobStatus() == 11 ? "Waiting for Children" : singleJob.getJobStatus()) + " - " + singleJob.getDescription() + " - " + singleJob.getDuration() + " sec";

String ret="";
for (String s : returns) {
ret += s;
ret += "n";
if (ret.length() > 1)
say(ret.substring(0, ret.length()-2));
say("No Jobs Running");
  }catch(Exception ev){
   }, delay, period);


  public static void getSession() {
System.out.println("Connecting to MicroStrategy");
factory = WebObjectsFactory.getInstance();
serverSession = factory.getIServerSession();
serverSession.setProjectName("PROJECT"); //Required to connect, but doesn't impact this program.
try {
source = (JobSource) factory.getMonitorSource(EnumWebMonitorType.WebMonitorTypeJob);
} catch (WebObjectsException ex) {
say("Error: " + ex.getMessage());

private static void say(String words) {

You may also like...

6 Responses

  1. Hi Bryan,

    Found your posts very useful.

    But i am not able to run the above.

    1. If i try to run it through command manager then it throws a number of errors.

    2. Else wise if i try to run it in unix server (with java installed)
    it throws the below error

    Exception in thread “main” java.lang.NoClassDefFoundError: JobMonitor/java
    Caused by: java.lang.ClassNotFoundException:
    at Method)
    at java.lang.ClassLoader.loadClass(
    at sun.misc.Launcher$AppClassLoader.loadClass(
    at java.lang.ClassLoader.loadClass(
    at java.lang.ClassLoader.loadClassInternal(
    Could not find the main class: Program will exit.

    Could you please help me on this

  2. Scott Vieth says:

    Wow do I feel like a Java rookie again. 🙂

    Do I need to straight-up do a copy-paste with javac, replacing the parameters, and then run it with Java?

  3. Ram S says:

    Hi Bryan,

    We are getting the below error message when using your code.

    (ServiceManager: XML syntax error.) (com.microstrategy.webapi.MSTRWebAPIException) 0x80043038: [com.microstrategy.webapi.MSTRWebAPIException: (ServiceManager: XML syntax error.)

  4. Karthik says:

    Yes. Job Monitoring program was very much helpful. Thanks a lot. Also i would like to know, how to get query details from IServer. We have some predefined interfaces from MicroStrategy.


    From this interface, we can get duration of query, No of rows processed, start time, end time, pass table count etc.

    I would like to know, how to use this QueryPass interface to fetch those details. Need your help for writing a custom java program or script.

Leave a Reply

Your email address will not be published. Required fields are marked *