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:
@@ -80,32 +80,34 @@ export default class MonitorAS extends Monitor {
|
||||
|
||||
const messageOrigin = message.originAS;
|
||||
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);
|
||||
|
||||
if (this.skipPrefixMatch) {
|
||||
this.publishAlert(messageOrigin.getId().toString() + "-" + messagePrefix,
|
||||
messageOrigin.getId(),
|
||||
matchedRule,
|
||||
message,
|
||||
{});
|
||||
const skipMatches = matchedPrefixRules.map(i => i.group).flat();
|
||||
const goodMatches = matchedASRule.map(i => i.group).flat();
|
||||
|
||||
for (let matchedPrefixRule of matchedPrefixRules) {
|
||||
this.publishAlert(messageOrigin.getId().toString() + "-" + messagePrefix,
|
||||
messageOrigin.getId(),
|
||||
matchedPrefixRule,
|
||||
message,
|
||||
{});
|
||||
for (let g of goodMatches) {
|
||||
if (!skipMatches.includes(g)) {
|
||||
this.publishAlert(messageOrigin.getId().toString() + "-" + messagePrefix,
|
||||
messageOrigin.getId(),
|
||||
{
|
||||
...matchedASRule,
|
||||
group: [g]
|
||||
},
|
||||
message,
|
||||
{});
|
||||
}
|
||||
}
|
||||
|
||||
} else if (!matchedPrefixRules.length) {
|
||||
|
||||
this.publishAlert(messageOrigin.getId().toString() + "-" + messagePrefix,
|
||||
messageOrigin.getId(),
|
||||
matchedRule,
|
||||
matchedASRule,
|
||||
message,
|
||||
{});
|
||||
}
|
||||
|
Reference in New Issue
Block a user