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

improved performance of misconfig monitor

This commit is contained in:
Massimo Candela
2023-10-20 01:25:40 +02:00
parent e3f5746ef9
commit 631aae1158

View File

@@ -80,32 +80,34 @@ export default class MonitorAS extends Monitor {
const messageOrigin = message.originAS; const messageOrigin = message.originAS;
const messagePrefix = message.prefix; const messagePrefix = message.prefix;
const matchedRule = this.getMonitoredAsMatch(messageOrigin); const matchedASRule = this.getMonitoredAsMatch(messageOrigin);
if (matchedRule) { if (matchedASRule) {
const matchedPrefixRules = this.getMoreSpecificMatches(messagePrefix, true, false); const matchedPrefixRules = this.getMoreSpecificMatches(messagePrefix, true, false);
if (this.skipPrefixMatch) { if (this.skipPrefixMatch) {
this.publishAlert(messageOrigin.getId().toString() + "-" + messagePrefix, const skipMatches = matchedPrefixRules.map(i => i.group).flat();
messageOrigin.getId(), const goodMatches = matchedASRule.map(i => i.group).flat();
matchedRule,
message,
{});
for (let matchedPrefixRule of matchedPrefixRules) { for (let g of goodMatches) {
this.publishAlert(messageOrigin.getId().toString() + "-" + messagePrefix, if (!skipMatches.includes(g)) {
messageOrigin.getId(), this.publishAlert(messageOrigin.getId().toString() + "-" + messagePrefix,
matchedPrefixRule, messageOrigin.getId(),
message, {
{}); ...matchedASRule,
group: [g]
},
message,
{});
}
} }
} else if (!matchedPrefixRules.length) { } else if (!matchedPrefixRules.length) {
this.publishAlert(messageOrigin.getId().toString() + "-" + messagePrefix, this.publishAlert(messageOrigin.getId().toString() + "-" + messagePrefix,
messageOrigin.getId(), messageOrigin.getId(),
matchedRule, matchedASRule,
message, message,
{}); {});
} }