Skip to content

Instantly share code, notes, and snippets.

@kbni
Created January 24, 2021 22:44
Show Gist options
  • Save kbni/74e31457c8994123497171bd9e6d1f31 to your computer and use it in GitHub Desktop.
Save kbni/74e31457c8994123497171bd9e6d1f31 to your computer and use it in GitHub Desktop.
Bulk Terminate Alarms by NXSL
sub bulk_terminate_alarms(limit) {
counter = 0;
clear_key_regex = "^(SW_PKG)";
clear_message_regex = "(changed to UNSUPPORTED)$";
for (n : GetAllNodes()) {
for (a : n->alarms) {
if(a->state == 0 && (a->key ~= clear_key_regex || a->message ~= clear_message_regex)) {
a->terminate();
println("Alarm terminated: " . a->key . ": " . a->message);
counter += 1;
}
if(limit && limit > 0 && counter == limit) return counter;
}
}
return counter;
}
cleared = bulk_terminate_alarms(10000);
println "Terminated " . cleared . " alarms.";
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment