mirror of
https://github.com/nttgin/BGPalerter.git
synced 2024-05-19 06:50:08 +00:00
minor refactoring
This commit is contained in:
2
AUTHORS
2
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.
|
||||
If this list is not up to date, please contact NTT or one of the authors.
|
||||
|
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).
|
||||
|
||||
## 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.
|
||||
Instead, if you want to run the source code (which is completely open) or develop, please read directly the documentation.
|
||||
> 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 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)
|
||||
|
||||
@ -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`.
|
||||
In `config.yml` you can find other reporting mechanisms (e.g., email, Slack, Kafka) in addition to logging on files.
|
||||
Please uncomment the related section and configure according to your needs.
|
||||
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.
|
||||
|
||||
If the installation doesn't go smoothly, read [here](docs/installation.md).
|
||||
Read the documentation below for more options.
|
||||
If the installation doesn't go smoothly, read [here](docs/installation.md). 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
|
||||
|
||||
@ -74,11 +74,12 @@ Read the documentation below for more options.
|
||||
- [Syslog](docs/reports.md#reportsyslog)
|
||||
- [Alerta dashboard](docs/reports.md#reportalerta)
|
||||
- [Webex](docs/reports.md#reportwebex)
|
||||
- [HTTP URL (push)](docs/reports.md#reporthttp)
|
||||
- [Telegram](docs/reports.md#reporttelegram)
|
||||
- [Mattermost](docs/reports.md#mattermost)
|
||||
- [Pushover](docs/report-http.md#pushover)
|
||||
- [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)
|
||||
- [Test report configuration](docs/installation.md#bgpalerter-parameters)
|
||||
- [Process/Uptime monitoring](docs/process-monitors.md)
|
||||
|
@ -281,8 +281,9 @@ reports:
|
||||
# homeserverUrl: https://matrix.org
|
||||
# accessToken: _ACCESS_TOKEN_
|
||||
# roomIds:
|
||||
# default: "_ROOM_ID_"
|
||||
# noc: "_ROOM_ID_"
|
||||
# default: _ROOM_ID_
|
||||
# noc: _ROOM_ID_
|
||||
|
||||
|
||||
|
||||
############################
|
||||
|
@ -186,9 +186,9 @@ Example of alert:
|
||||
Parameters for this monitor module:
|
||||
|
||||
|Parameter| Description |
|
||||
|---|---|
|
||||
|---|--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
|
||||
|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. |
|
||||
|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`. |
|
||||
|
||||
|
@ -125,9 +125,10 @@ export default class Config {
|
||||
compressOnRotation: false,
|
||||
},
|
||||
rpki: {
|
||||
vrpProvider: "ntt",
|
||||
vrpProvider: "rpkiclient",
|
||||
preCacheROAs: true,
|
||||
refreshVrpListMinutes: 15
|
||||
refreshVrpListMinutes: 15,
|
||||
markDataAsStaleAfterMinutes: 120
|
||||
},
|
||||
rest: {
|
||||
host: "localhost",
|
||||
|
@ -325,7 +325,7 @@ module.exports = function generatePrefixes(inputParameters) {
|
||||
};
|
||||
|
||||
return getBaseRules(prefixes)
|
||||
.then(items => [].concat.apply([], items))
|
||||
.then(items => items.flat())
|
||||
.then(prefixes => {
|
||||
return batchPromises(1, prefixes, prefix => {
|
||||
return getAnnouncedMoreSpecifics(prefix)
|
||||
|
@ -65,7 +65,7 @@ export default class ReportKafka extends Report {
|
||||
this.client = new Kafka({
|
||||
logLevel: logLevel.ERROR,
|
||||
clientId: this.clientId,
|
||||
brokers: [].concat.apply([], [this.host])
|
||||
brokers: [this.host].flat()
|
||||
});
|
||||
|
||||
this.producer = this.client.producer();
|
||||
|
@ -41,7 +41,7 @@ export default class ReportPullAPI extends Report {
|
||||
|
||||
this.name = "reportPullAPI" || this.params.name;
|
||||
this.enabled = true;
|
||||
this.maxAlertsAmount = this.params.maxAlertsAmount || 100;
|
||||
this.maxAlertsAmount = Math.min(this.params.maxAlertsAmount || 25, 100);
|
||||
this.lastQuery = null;
|
||||
|
||||
let restDefault = env.config.rest || { port: params.port, host: params.host };
|
||||
|
@ -13,7 +13,7 @@ export default class RpkiUtils {
|
||||
this.clientId = env.clientId || "";
|
||||
this.logger = env.logger;
|
||||
this.userAgent = `${this.clientId}/${env.version}`;
|
||||
const defaultMarkDataAsStaleAfterMinutes = 60;
|
||||
const defaultMarkDataAsStaleAfterMinutes = 120;
|
||||
const providers = [...RpkiValidator.providers, "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."
|
||||
});
|
||||
}
|
||||
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);
|
||||
}
|
||||
|
||||
@ -242,7 +242,7 @@ export default class RpkiUtils {
|
||||
.then(() => {
|
||||
return Promise.all(batch
|
||||
.map(({ prefix, origin }) => {
|
||||
const origins = [].concat.apply([], [origin.getValue()]);
|
||||
const origins = [origin.getValue()].flat();
|
||||
|
||||
return Promise
|
||||
.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
|
||||
return {
|
||||
valid: true,
|
||||
covering: [].concat.apply([], results.map(i => i.covering)),
|
||||
covering: results.map(i => i.covering).flat(),
|
||||
prefix,
|
||||
origin
|
||||
};
|
||||
} else if (results.some(result => result && !result.valid)) { // At least one not valid
|
||||
return {
|
||||
valid: false,
|
||||
covering: [].concat.apply([], results.map(i => i.covering)),
|
||||
covering: results.map(i => i.covering).flat(),
|
||||
prefix,
|
||||
origin
|
||||
};
|
||||
} else { // return not covered
|
||||
return {
|
||||
valid: null,
|
||||
covering: [].concat.apply([], results.map(i => i.covering)),
|
||||
covering: results.map(i => i.covering).flat(),
|
||||
prefix,
|
||||
origin
|
||||
};
|
||||
|
Reference in New Issue
Block a user