Using a script to clear old alarms results in undesired behavior. The user gets an alert that says “The number of alarms stored in the Foglight database has exceeded 10000.0. There are 8660.0 alarms that have been cleared for over a day. Please consider deleting these alarms." Usually, the user runs the below script:
long now = System.currentTimeMillis() Calendar threshold = Calendar.getInstance(); threshold .add(Calendar.DATE, -3) server.get("AlarmService").purgeAlarms(new Date(0), threshold.getTime()); "done in "+(System.currentTimeMillis()-now)/1000+"s"
The user has a problem with this script is that it clears old alarms that are still valid, which causes them to refire.
Is there a script that deletes old cleared alarms but leaves still valid alarms?
These scripts can delete all cleared alarms in the FMS server from Administration | Tooling | Script Console | click Add | copy the script within "Enter Script Text:"
long now = System.currentTimeMillis() Calendar threshold = Calendar.getInstance(); end_time = threshold.getTime() start_time = new Date(0) alarmService = server.get("AlarmService") allAlarms_before = alarmService.getAlarms(start_time, end_time) alarmService.purgeClearedAlarms(start_time, end_time) // it will delete all the cleared alarms allAlarms_after = alarmService.getAlarms(start_time, end_time) "before delete: $allAlarms_before.size, after deleted:$allAlarms_after.size" + ". done in "+(System.currentTimeMillis()-now)/1000+"s"