DX Infrastructure Manager

Expand all | Collapse all

Java sending an alarm

  • 1.  Java sending an alarm

    Posted 07-26-2011 12:05 AM

    Hello,

     

    We have been experimenting with the Java SDK and have been trying to figure out how to send an alarm.  From the code below, we believe we are sending the alarm correctly but it never shows up in the alarm console in Infastructure Manager.  Any help would be greatly appreciated.

     

    NimUserLogin.login("USERNAME", "PASSWORD", "HOSTNAME");

    NimAlarm alarm = new NimAlarm(NimAlarm.NIML_WARNING, "Alarm generated from Java");

    String id= alarm.send();
    // Change the alarm to critical and send again
    alarm.setSeverity(NimAlarm.NIML_CRITICAL);
    alarm.send();
    // Clear previous critical alarm
    //alarm.setSeverity(NimAlarm.NIML_CLEAR);
    //alarm.send();
    System.out.println(alarm);
    System.out.println(id);
    System.out.println(alarm.isConnected());

     

    //OUTPUT:

    D, severity=5, message==Alarm generated from Java, subsystem=null, suppressionid=null, source=null
    VQ20230184-03141
    true



  • 2.  Re: Java sending an alarm

    Posted 08-09-2011 11:25 AM

    Hello Cody,

     

    the code you are using appear to be OK. The question is, where are you running this code from? Is it a client machine that have a robot installed, or is it a standalone machine? I see you are passing in the host argument.

     

    It appears that if you just use alarm.send() it will use the local spooler to send the alarm, regardless if you have set it in user login.

     

    I tested this code and it uses the local robot.

     

    package com.nimsoft.app;
    
    import java.util.Random;
    
    import com.nimsoft.nimbus.NimAlarm;
    import com.nimsoft.nimbus.NimUserLogin;
    
    public class App {
         public static void main(String[] args) {
              
              try {
                   NimUserLogin.login("xxxx", "yyyy", "193.71.55.116");     
                   
                   App exampleprobe = new App();
                   exampleprobe.doalarmtest(args);
              } catch (Exception e) {
                   e.printStackTrace();
              }
         }
    
         public void doalarmtest(String[] args) throws Exception {
              String basicAlarm = "Alarm generated from Java";
    
              Random r = new Random();
              String token = Long.toString(Math.abs(r.nextLong()), 36);
              System.out.println("Token" + token);
    
              NimAlarm alarm = new NimAlarm(NimAlarm.NIML_WARNING, basicAlarm, "2",  token, "JAVA", null, "8");
              alarm.send();
              alarm.disconnect();
         }
    }

     

    But if I provide the controller IP address as an environment variable it will use that instead. E.g. start the program using 

     

    -DNIMV_CONTIP=193.71.55.116

     

    Hope this helps, if you have not already figured it out.

     

    Thanks,

    Geir.