expAlarms.groovy - Foglight for Databases - Foglight for Databases - Dell Community

expAlarms.groovy

expAlarms.groovy

This question is answered

Hello to all

Can anyone help me with a little problem I have.

How to obtain all alarms, cleared and not cleared with groovy script.

There is variable alarms = almSvc.getCurrentAlarms(), but I need instead variable alarms = almSvc.getAlarms();


If I put this second variable, script does not work, with error : Could not find which method getAlarms() to invoke from this list:

public abstract java.util.List com.quest.nitro.service.sl.interfaces.alarm.AlarmService#getAlarms(java.util.Date, java.util.Date)
public abstract java.util.List com.quest.nitro.service.sl.interfaces.alarm.AlarmService#getAlarms(java.util.Date, java.util.Date, java.lang.String)

 

.I need this function because we send alarms from foglight to ITM Tivoli and we must now when alarm is cleared. Therefore, I need both, cleared and not cleared alarams.

Thanks in advance for help

Nikola 

Verified Answer
  • Hi Nikola,

    Instead of using this line:

    alarms = almSvc.getCurrentAlarms();

     

    You should use the following:

    startTime = new Date(0);

    endtime = new Date(System.currentTimeMillis());

    alarms = almSvc.getAlarms(startTime, endtime);

    The above will return all available alarms from the FMS beginning.

    If you want to limit the alarms returned to a specific timeframe, let’s say, 3 days back, you should use:

    startTime = new Date(System.currentTimeMillis() - 3*24*60*60*1000L);

     

    Anat and Tal

All Replies
  • The getAlarms API requires two parameters:

    getAlarms

    List<Alarm> getAlarms(Date startTime,

                        Date endTime)

    Returns all the alarms in the system generated between the startTime and the endTime up to the maximum defined in alarm service. Current alarms are always included.

    Parameters:

    startTime -

    endTime -

    Returns:

    List of alarms

  • Hi adror

    thank you for your reply, but can you be more specific in terms of syntax..here is my groovy script:

    ////////////////////////
    // get Data and Export
    ////////////////////////


    alarms = almSvc.getCurrentAlarms();
    //alarmCount=0;

    def expAlarms = []

    alarms.each{ _alarm ->
    expAlarms.add(getAlarmProperties(_alarm))
    }

    // Build Result
    StringBuffer buffer = new StringBuffer();
    buffer.append("AlarmID,TopologyID,Created,Cleared?,Source,Severity,Message,Host,Agent,Rule\n");
    expAlarms.each{m->
    int i = 0;
    m.each {k->
    buffer.append((i>0?",":"")+k)
    i++
    }
    buffer.append("\n")
    }
    return buffer

    Please if you can show me how to write this:

    getAlarms

    List<Alarm> getAlarms(Date startTime,

                        Date endTime)

    Regards, Nikola 

  • Hi Nikola,

    Instead of using this line:

    alarms = almSvc.getCurrentAlarms();

     

    You should use the following:

    startTime = new Date(0);

    endtime = new Date(System.currentTimeMillis());

    alarms = almSvc.getAlarms(startTime, endtime);

    The above will return all available alarms from the FMS beginning.

    If you want to limit the alarms returned to a specific timeframe, let’s say, 3 days back, you should use:

    startTime = new Date(System.currentTimeMillis() - 3*24*60*60*1000L);

     

    Anat and Tal

  • Hi dror

    thank you, this is what I looking for. It works.

    One question, the Foglight has pack for integration with Tivoli TEC..but  Tivoli TEC ( Tivoli enterprise Console ) was abandoned before 5 years from the side IBM and there is no support anymore. Why is that? This is old soultions and I think that no one use TEC anymore.

    than you for your effort and Help

    nikola