DX Infrastructure Manager

Expand all | Collapse all

Java sending an alarm

  • 1.  Java sending an alarm

    Posted 07-26-2011 12:05 AM



    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
    // Clear previous critical alarm



    D, severity=5, message==Alarm generated from Java, subsystem=null, suppressionid=null, source=null

  • 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", "");     
                   App exampleprobe = new App();
              } catch (Exception e) {
         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");


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




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