mirror of
https://github.com/nttgin/BGPalerter.git
synced 2024-05-19 06:50:08 +00:00
added report of most used path in email
This commit is contained in:
@@ -53,6 +53,7 @@ reports:
|
|||||||
# - visibility
|
# - visibility
|
||||||
# - path
|
# - path
|
||||||
# params:
|
# params:
|
||||||
|
# showPaths: 5 # Amount of AS_PATHs to report in the alert
|
||||||
# senderEmail: bgpalerter@xxxx
|
# senderEmail: bgpalerter@xxxx
|
||||||
# # BGPalerter uses nodemailer.
|
# # BGPalerter uses nodemailer.
|
||||||
# # The smtp section can be configured with all the parameters available at https://nodemailer.com/smtp/
|
# # The smtp section can be configured with all the parameters available at https://nodemailer.com/smtp/
|
||||||
|
@@ -158,6 +158,7 @@ Parameters for this report module:
|
|||||||
|
|
||||||
|Parameter| Description|
|
|Parameter| Description|
|
||||||
|---|---|
|
|---|---|
|
||||||
|
|showPaths| Amount of AS_PATHs to report in the alert (0 to disable). |
|
||||||
|senderEmail| The email address that will be used as sender for the alerts. |
|
|senderEmail| The email address that will be used as sender for the alerts. |
|
||||||
|smtp| A dictionary containing the SMTP configuration. Some parameters are described in `config.yml.example`. For all the options refer to the [nodemailer documentation](https://nodemailer.com/smtp/). |
|
|smtp| A dictionary containing the SMTP configuration. Some parameters are described in `config.yml.example`. For all the options refer to the [nodemailer documentation](https://nodemailer.com/smtp/). |
|
||||||
|notifiedEmails| A dictionary containing email addresses grouped by user groups. (key: group, value: list of emails)|
|
|notifiedEmails| A dictionary containing email addresses grouped by user groups. (key: group, value: list of emails)|
|
||||||
|
@@ -48,7 +48,10 @@ Now announced with: ${newprefix}\n\
|
|||||||
When event started: ${earliest} UTC\n\
|
When event started: ${earliest} UTC\n\
|
||||||
Last event: ${latest} UTC\n\
|
Last event: ${latest} UTC\n\
|
||||||
Detected by peers: ${peers}\n\
|
Detected by peers: ${peers}\n\
|
||||||
See in BGPlay: ${bgplay}';
|
See in BGPlay: ${bgplay}\n\
|
||||||
|
\n\
|
||||||
|
Top ${pathNumber} most used AS paths:\n\
|
||||||
|
${paths}';
|
||||||
|
|
||||||
const templateNewPrefix = '${summary}\n\
|
const templateNewPrefix = '${summary}\n\
|
||||||
\n\
|
\n\
|
||||||
|
@@ -12,4 +12,7 @@ Now announced with: ${newprefix}
|
|||||||
When event started: ${earliest} UTC
|
When event started: ${earliest} UTC
|
||||||
Last event: ${latest} UTC
|
Last event: ${latest} UTC
|
||||||
Detected by peers: ${peers}
|
Detected by peers: ${peers}
|
||||||
See in BGPlay: ${bgplay}
|
See in BGPlay: ${bgplay}
|
||||||
|
|
||||||
|
Top ${pathNumber} most used AS paths:
|
||||||
|
${paths}
|
@@ -143,6 +143,21 @@ export default class ReportEmail extends Report {
|
|||||||
|
|
||||||
switch(channel){
|
switch(channel){
|
||||||
case "hijack":
|
case "hijack":
|
||||||
|
const pathsCount = {};
|
||||||
|
const pathIndex = content.data
|
||||||
|
.map(i => JSON.stringify(i.matchedMessage.path.getValues().slice(1)))
|
||||||
|
.forEach(path => {
|
||||||
|
if (!pathsCount[path]){
|
||||||
|
pathsCount[path] = 0;
|
||||||
|
}
|
||||||
|
pathsCount[path] ++;
|
||||||
|
});
|
||||||
|
|
||||||
|
const sortedPathIndex = Object.keys(pathsCount)
|
||||||
|
.map(key => [key, pathsCount[key]] );
|
||||||
|
|
||||||
|
sortedPathIndex.sort((first, second) => second[1] - first[1]);
|
||||||
|
|
||||||
matched = content.data[0].matchedRule;
|
matched = content.data[0].matchedRule;
|
||||||
context.prefix = matched.prefix;
|
context.prefix = matched.prefix;
|
||||||
context.description = matched.description;
|
context.description = matched.description;
|
||||||
@@ -151,6 +166,10 @@ export default class ReportEmail extends Report {
|
|||||||
context.neworigin = content.data[0].matchedMessage.originAS;
|
context.neworigin = content.data[0].matchedMessage.originAS;
|
||||||
context.newprefix = content.data[0].matchedMessage.prefix;
|
context.newprefix = content.data[0].matchedMessage.prefix;
|
||||||
context.bgplay = this._getBGPlayLink(matched.prefix, content.earliest, content.latest);
|
context.bgplay = this._getBGPlayLink(matched.prefix, content.earliest, content.latest);
|
||||||
|
context.pathNumber = (this.params.showPaths > 0) ? Math.min(this.params.showPaths, sortedPathIndex.length) : "";
|
||||||
|
context.paths = (this.params.showPaths > 0) ? sortedPathIndex
|
||||||
|
.slice(0, this.params.showPaths)
|
||||||
|
.map(i => i[0]).join("\n") : "Disabled";
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case "visibility":
|
case "visibility":
|
||||||
@@ -205,7 +224,6 @@ export default class ReportEmail extends Report {
|
|||||||
this.params.notifiedEmails &&
|
this.params.notifiedEmails &&
|
||||||
this.params.notifiedEmails["default"] &&
|
this.params.notifiedEmails["default"] &&
|
||||||
this.params.notifiedEmails["default"].length) {
|
this.params.notifiedEmails["default"].length) {
|
||||||
|
|
||||||
const emailGroups = this.getEmails(content);
|
const emailGroups = this.getEmails(content);
|
||||||
|
|
||||||
for (let emails of emailGroups) {
|
for (let emails of emailGroups) {
|
||||||
|
Reference in New Issue
Block a user