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:
@@ -45,23 +45,9 @@ export default class MonitorRPKI extends Monitor {
|
|||||||
|
|
||||||
squashAlerts = (alerts) => {
|
squashAlerts = (alerts) => {
|
||||||
|
|
||||||
const matchedMessages = alerts.map(alert => alert.matchedMessage);
|
const peers = [...new Set(alerts.map(alert => alert.matchedMessage.peer))].length;
|
||||||
const matchPerPrefix = {};
|
|
||||||
const prefixesOut = [];
|
|
||||||
|
|
||||||
for (let m of matchedMessages) { // Get the number of peers that triggered the alert for each prefix
|
if (peers >= this.thresholdMinPeers) {
|
||||||
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) {
|
|
||||||
const firstAlert = alerts[0];
|
const firstAlert = alerts[0];
|
||||||
const message = firstAlert.matchedMessage;
|
const message = firstAlert.matchedMessage;
|
||||||
const extra = firstAlert.extra;
|
const extra = firstAlert.extra;
|
||||||
|
Reference in New Issue
Block a user