I would like to know if there is a way that I would be able to automate the clearing of alarms that are older then a certain number of days old.
Current versions of Foglight automatically purge alarms when they've been cleared for more than 30 days. This is configurable through the AlarmPurgeAge registry variable.
Starting with Foglight 8.0, the registry variable server.alarm.auto-clear-days can be used to define the number of days before an alarm is automatically cleared. This is disabled by default with a value of -1.
For previous versions, the following groovy script can be scheduled to run and clear alarms older than X days old. It is currently set to 60 days, which you can change to meet your needs. Remember that when automatically clearing alarms if the condition is still true the alarm will fire again after it is cleared.
// alarmAge defined in days (change this)
alarmAge = 60;
ageMSecs = alarmAge * (24 * 60 * 60 * 1000L);
alarmSvc = server.get("AlarmService");
output = new StringBuilder();
now = new Date().getTime();
currentAlarms = alarmSvc.getCurrentAlarms();
i = 0;
for (alarm in currentAlarms)
{
timeDifference = now - alarm.getCreatedTime().getTime()
if (timeDifference > ageMSecs)
{
alarmSvc. clearAlarm (alarm. getID());
i++;
}
}
return "Cleared ${i} alarms out of ${currentAlarms.size()} in the range";
This can be run manually on the Script Console or used in the condition of a Time Driven custom rule.