mirror of
https://github.com/nttgin/BGPalerter.git
synced 2024-05-19 06:50:08 +00:00
minor refactoring
This commit is contained in:
4
AUTHORS
4
AUTHORS
@@ -1,4 +1,4 @@
|
|||||||
BGPalerter was originally created at the beginning of 2019 at NTT Ltd.
|
BGPalerter was originally created in February 2019 at NTT Ltd.
|
||||||
|
|
||||||
Here is a list of authors and contributors who patched or extended the code.
|
Here is a list of authors and contributors who patched or extended the code.
|
||||||
If this list is not up to date, please contact NTT or one of the authors.
|
If this list is not up to date, please contact NTT or one of the authors.
|
||||||
@@ -12,7 +12,7 @@ If this list is not up to date, please contact NTT or one of the authors.
|
|||||||
- CONTRIBUTORS -
|
- CONTRIBUTORS -
|
||||||
Damian Zaremba, Fastly
|
Damian Zaremba, Fastly
|
||||||
Mircea Ulinic, DigitalOcean
|
Mircea Ulinic, DigitalOcean
|
||||||
Alan Haynes, Harbin Clinic
|
Alan Haynes, Harbin Clinic
|
||||||
Florian Domain, Criteo
|
Florian Domain, Criteo
|
||||||
Louis Poinsignon, Cloudflare
|
Louis Poinsignon, Cloudflare
|
||||||
See complete list at https://github.com/nttgin/BGPalerter/graphs/contributors
|
See complete list at https://github.com/nttgin/BGPalerter/graphs/contributors
|
||||||
|
15
README.md
15
README.md
@@ -26,8 +26,8 @@ It can deliver alerts on files, email, kafka, slack, and more.
|
|||||||
> BGPalerter connects to public BGP data repos (not managed by NTT), and the entire monitoring is done directly in the application (there are no NTT servers involved).
|
> BGPalerter connects to public BGP data repos (not managed by NTT), and the entire monitoring is done directly in the application (there are no NTT servers involved).
|
||||||
|
|
||||||
## TL;DR (1 minute setup)
|
## TL;DR (1 minute setup)
|
||||||
> This section is useful if you don't care about the source code but you just want to run the monitor.
|
> This section is useful if you don't care about the source code, but you just want to start monitoring.
|
||||||
Instead, if you want to run the source code (which is completely open) or develop, please read directly the documentation.
|
Instead, if you want to run the source code or develop, skip to the documentation below.
|
||||||
|
|
||||||
1. Download the binary [here](https://github.com/nttgin/BGPalerter/releases) (be sure to select the one for your OS)
|
1. Download the binary [here](https://github.com/nttgin/BGPalerter/releases) (be sure to select the one for your OS)
|
||||||
|
|
||||||
@@ -36,11 +36,11 @@ The first time you run it, the auto-configuration will start.
|
|||||||
|
|
||||||
|
|
||||||
If something happens (e.g., a hijack) you will see the alerts in `logs/reports.log`.
|
If something happens (e.g., a hijack) you will see the alerts in `logs/reports.log`.
|
||||||
In `config.yml` you can find other reporting mechanisms (e.g., email, Slack, Kafka) in addition to logging on files.
|
In `config.yml` you can find other reporting mechanisms (e.g., email, Slack, Kafka) in addition to logging on files. Uncomment the related section and configure according to your needs.
|
||||||
Please uncomment the related section and configure according to your needs.
|
|
||||||
|
|
||||||
If the installation doesn't go smoothly, read [here](docs/installation.md).
|
If the installation doesn't go smoothly, read [here](docs/installation.md). Read the documentation below for more options.
|
||||||
Read the documentation below for more options.
|
|
||||||
|
> If you are looking for a BGP and RPKI monitoring service based on BGPalerter, try [PacketVis](https://packetvis.com)
|
||||||
|
|
||||||
## Documentation
|
## Documentation
|
||||||
|
|
||||||
@@ -74,11 +74,12 @@ Read the documentation below for more options.
|
|||||||
- [Syslog](docs/reports.md#reportsyslog)
|
- [Syslog](docs/reports.md#reportsyslog)
|
||||||
- [Alerta dashboard](docs/reports.md#reportalerta)
|
- [Alerta dashboard](docs/reports.md#reportalerta)
|
||||||
- [Webex](docs/reports.md#reportwebex)
|
- [Webex](docs/reports.md#reportwebex)
|
||||||
- [HTTP URL (push)](docs/reports.md#reporthttp)
|
|
||||||
- [Telegram](docs/reports.md#reporttelegram)
|
- [Telegram](docs/reports.md#reporttelegram)
|
||||||
- [Mattermost](docs/reports.md#mattermost)
|
- [Mattermost](docs/reports.md#mattermost)
|
||||||
- [Pushover](docs/report-http.md#pushover)
|
- [Pushover](docs/report-http.md#pushover)
|
||||||
- [Microsoft Teams](docs/report-http.md#ms-teams)
|
- [Microsoft Teams](docs/report-http.md#ms-teams)
|
||||||
|
- [Matrix](docs/reports.md#reportmatrix)
|
||||||
|
- [HTTP URL (push)](docs/reports.md#reporthttp)
|
||||||
- [REST API (pull)](docs/reports.md#reportpullapi)
|
- [REST API (pull)](docs/reports.md#reportpullapi)
|
||||||
- [Test report configuration](docs/installation.md#bgpalerter-parameters)
|
- [Test report configuration](docs/installation.md#bgpalerter-parameters)
|
||||||
- [Process/Uptime monitoring](docs/process-monitors.md)
|
- [Process/Uptime monitoring](docs/process-monitors.md)
|
||||||
|
@@ -281,8 +281,9 @@ reports:
|
|||||||
# homeserverUrl: https://matrix.org
|
# homeserverUrl: https://matrix.org
|
||||||
# accessToken: _ACCESS_TOKEN_
|
# accessToken: _ACCESS_TOKEN_
|
||||||
# roomIds:
|
# roomIds:
|
||||||
# default: "_ROOM_ID_"
|
# default: _ROOM_ID_
|
||||||
# noc: "_ROOM_ID_"
|
# noc: _ROOM_ID_
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
############################
|
############################
|
||||||
|
@@ -185,12 +185,12 @@ Example of alert:
|
|||||||
|
|
||||||
Parameters for this monitor module:
|
Parameters for this monitor module:
|
||||||
|
|
||||||
|Parameter| Description|
|
|Parameter| Description |
|
||||||
|---|---|
|
|---|--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
|
||||||
|thresholdMinPeers| Minimum number of peers that need to see the BGP update before to trigger an alert.|
|
|thresholdMinPeers| Minimum number of peers that need to see the BGP update before to trigger an alert. |
|
||||||
|notificationIntervalSeconds| It overwrite the global `notificationIntervalSeconds` for this specific monitor. See [here](#Configuration) the definition.|
|
|notificationIntervalSeconds| It overwrite the global `notificationIntervalSeconds` for this specific monitor. See [here](#Configuration) the definition. Useful if you are monitoring a beacon. |
|
||||||
|noProxy| If there is a global proxy configuration (see [here](http-proxy.md)), this parameter if set to true allows the single module to bypass the proxy. |
|
|noProxy| If there is a global proxy configuration (see [here](http-proxy.md)), this parameter if set to true allows the single module to bypass the proxy. |
|
||||||
|maxDataSamples| Maximum number of collected BGP messages for each alert which doesn't reach yet the `thresholdMinPeers`. Default to 1000. As soon as the `thresholdMinPeers` is reached, the collected BGP messages are flushed, independently from the value of `maxDataSamples`.|
|
|maxDataSamples| Maximum number of collected BGP messages for each alert which doesn't reach yet the `thresholdMinPeers`. Default to 1000. As soon as the `thresholdMinPeers` is reached, the collected BGP messages are flushed, independently from the value of `maxDataSamples`. |
|
||||||
|
|
||||||
#### monitorPath
|
#### monitorPath
|
||||||
|
|
||||||
|
@@ -125,9 +125,10 @@ export default class Config {
|
|||||||
compressOnRotation: false,
|
compressOnRotation: false,
|
||||||
},
|
},
|
||||||
rpki: {
|
rpki: {
|
||||||
vrpProvider: "ntt",
|
vrpProvider: "rpkiclient",
|
||||||
preCacheROAs: true,
|
preCacheROAs: true,
|
||||||
refreshVrpListMinutes: 15
|
refreshVrpListMinutes: 15,
|
||||||
|
markDataAsStaleAfterMinutes: 120
|
||||||
},
|
},
|
||||||
rest: {
|
rest: {
|
||||||
host: "localhost",
|
host: "localhost",
|
||||||
|
@@ -325,7 +325,7 @@ module.exports = function generatePrefixes(inputParameters) {
|
|||||||
};
|
};
|
||||||
|
|
||||||
return getBaseRules(prefixes)
|
return getBaseRules(prefixes)
|
||||||
.then(items => [].concat.apply([], items))
|
.then(items => items.flat())
|
||||||
.then(prefixes => {
|
.then(prefixes => {
|
||||||
return batchPromises(1, prefixes, prefix => {
|
return batchPromises(1, prefixes, prefix => {
|
||||||
return getAnnouncedMoreSpecifics(prefix)
|
return getAnnouncedMoreSpecifics(prefix)
|
||||||
|
@@ -65,7 +65,7 @@ export default class ReportKafka extends Report {
|
|||||||
this.client = new Kafka({
|
this.client = new Kafka({
|
||||||
logLevel: logLevel.ERROR,
|
logLevel: logLevel.ERROR,
|
||||||
clientId: this.clientId,
|
clientId: this.clientId,
|
||||||
brokers: [].concat.apply([], [this.host])
|
brokers: [this.host].flat()
|
||||||
});
|
});
|
||||||
|
|
||||||
this.producer = this.client.producer();
|
this.producer = this.client.producer();
|
||||||
|
@@ -41,7 +41,7 @@ export default class ReportPullAPI extends Report {
|
|||||||
|
|
||||||
this.name = "reportPullAPI" || this.params.name;
|
this.name = "reportPullAPI" || this.params.name;
|
||||||
this.enabled = true;
|
this.enabled = true;
|
||||||
this.maxAlertsAmount = this.params.maxAlertsAmount || 100;
|
this.maxAlertsAmount = Math.min(this.params.maxAlertsAmount || 25, 100);
|
||||||
this.lastQuery = null;
|
this.lastQuery = null;
|
||||||
|
|
||||||
let restDefault = env.config.rest || { port: params.port, host: params.host };
|
let restDefault = env.config.rest || { port: params.port, host: params.host };
|
||||||
|
@@ -13,7 +13,7 @@ export default class RpkiUtils {
|
|||||||
this.clientId = env.clientId || "";
|
this.clientId = env.clientId || "";
|
||||||
this.logger = env.logger;
|
this.logger = env.logger;
|
||||||
this.userAgent = `${this.clientId}/${env.version}`;
|
this.userAgent = `${this.clientId}/${env.version}`;
|
||||||
const defaultMarkDataAsStaleAfterMinutes = 60;
|
const defaultMarkDataAsStaleAfterMinutes = 120;
|
||||||
const providers = [...RpkiValidator.providers, "api"];
|
const providers = [...RpkiValidator.providers, "api"];
|
||||||
|
|
||||||
if (this.params.url || this.params.vrpProvider === "api") {
|
if (this.params.url || this.params.vrpProvider === "api") {
|
||||||
@@ -43,7 +43,7 @@ export default class RpkiUtils {
|
|||||||
message: "The specified vrpProvider is not valid. Using default vrpProvider."
|
message: "The specified vrpProvider is not valid. Using default vrpProvider."
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
this.params.refreshVrpListMinutes = Math.max(this.params.refreshVrpListMinutes || 0, 5);
|
this.params.refreshVrpListMinutes = Math.max(this.params.refreshVrpListMinutes || 0, 1);
|
||||||
this.params.preCacheROAs = !!(this.params.preCacheROAs ?? true);
|
this.params.preCacheROAs = !!(this.params.preCacheROAs ?? true);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -242,7 +242,7 @@ export default class RpkiUtils {
|
|||||||
.then(() => {
|
.then(() => {
|
||||||
return Promise.all(batch
|
return Promise.all(batch
|
||||||
.map(({ prefix, origin }) => {
|
.map(({ prefix, origin }) => {
|
||||||
const origins = [].concat.apply([], [origin.getValue()]);
|
const origins = [origin.getValue()].flat();
|
||||||
|
|
||||||
return Promise
|
return Promise
|
||||||
.all(origins.map(asn => this.rpki.validate(prefix, asn, true))) // Validate each origin
|
.all(origins.map(asn => this.rpki.validate(prefix, asn, true))) // Validate each origin
|
||||||
@@ -253,21 +253,21 @@ export default class RpkiUtils {
|
|||||||
if (!!results.length && results.every(result => result && result.valid)) { // All valid
|
if (!!results.length && results.every(result => result && result.valid)) { // All valid
|
||||||
return {
|
return {
|
||||||
valid: true,
|
valid: true,
|
||||||
covering: [].concat.apply([], results.map(i => i.covering)),
|
covering: results.map(i => i.covering).flat(),
|
||||||
prefix,
|
prefix,
|
||||||
origin
|
origin
|
||||||
};
|
};
|
||||||
} else if (results.some(result => result && !result.valid)) { // At least one not valid
|
} else if (results.some(result => result && !result.valid)) { // At least one not valid
|
||||||
return {
|
return {
|
||||||
valid: false,
|
valid: false,
|
||||||
covering: [].concat.apply([], results.map(i => i.covering)),
|
covering: results.map(i => i.covering).flat(),
|
||||||
prefix,
|
prefix,
|
||||||
origin
|
origin
|
||||||
};
|
};
|
||||||
} else { // return not covered
|
} else { // return not covered
|
||||||
return {
|
return {
|
||||||
valid: null,
|
valid: null,
|
||||||
covering: [].concat.apply([], results.map(i => i.covering)),
|
covering: results.map(i => i.covering).flat(),
|
||||||
prefix,
|
prefix,
|
||||||
origin
|
origin
|
||||||
};
|
};
|
||||||
|
Reference in New Issue
Block a user