1
0
mirror of https://github.com/nttgin/BGPalerter.git synced 2024-05-19 06:50:08 +00:00

simplified number of peers check on monitorRPKI

This commit is contained in:
Massimo Candela
2020-04-29 00:40:24 +02:00
parent a04ce4a024
commit edae264ec4

View File

@@ -45,23 +45,9 @@ export default class MonitorRPKI extends Monitor {
squashAlerts = (alerts) => {
const matchedMessages = alerts.map(alert => alert.matchedMessage);
const matchPerPrefix = {};
const prefixesOut = [];
const peers = [...new Set(alerts.map(alert => alert.matchedMessage.peer))].length;
for (let m of matchedMessages) { // Get the number of peers that triggered the alert for each prefix
matchPerPrefix[m.prefix] = matchPerPrefix[m.prefix] || [];
matchPerPrefix[m.prefix].push(m.peer);
}
for (let p in matchPerPrefix) { // Check if any of the prefixes went above the thresholdMinPeers
const peers = [...new Set(matchPerPrefix[p])];
if (peers.length >= this.thresholdMinPeers) {
prefixesOut.push(p);
}
}
if (prefixesOut.length > 0) {
if (peers >= this.thresholdMinPeers) {
const firstAlert = alerts[0];
const message = firstAlert.matchedMessage;
const extra = firstAlert.extra;