Skip to content

Commit

Permalink
introduced TA-specific tolerance (#1204)
Browse files Browse the repository at this point in the history
  • Loading branch information
massimocandela committed Dec 24, 2023
1 parent 1f551e9 commit ef1523e
Show file tree
Hide file tree
Showing 3 changed files with 44 additions and 8 deletions.
14 changes: 12 additions & 2 deletions config.yml.example
Original file line number Diff line number Diff line change
Expand Up @@ -68,8 +68,18 @@ monitors:
enableAdvancedRpkiStats: false
roaExpirationAlertHours: 2
checkOnlyASns: true
toleranceDeletedRoasTA: 20
toleranceExpiredRoasTA: 20
toleranceDeletedRoasTA:
ripe: 20
apnic: 20
arin: 20
lacnic: 20
afrinic: 50
toleranceExpiredRoasTA:
ripe: 20
apnic: 20
arin: 20
lacnic: 20
afrinic: 50

- file: monitorPathNeighbors
channel: path
Expand Down
16 changes: 14 additions & 2 deletions src/config/config.js
Original file line number Diff line number Diff line change
Expand Up @@ -94,8 +94,20 @@ export default class Config {
enableAdvancedRpkiStats: false,
roaExpirationAlertHours: 2,
checkOnlyASns: true,
toleranceDeletedRoasTA: 20,
toleranceExpiredRoasTA: 20
toleranceDeletedRoasTA: {
ripe: 20,
apnic: 20,
arin: 20,
lacnic: 20,
afrinic: 50
},
toleranceExpiredRoasTA: {
ripe: 20,
apnic: 20,
arin: 20,
lacnic: 20,
afrinic: 50
}
}
},
{
Expand Down
22 changes: 18 additions & 4 deletions src/monitors/monitorROAS.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,20 @@ import moment from "moment";
import ipUtils from "ip-sub";
import batchPromises from "batch-promises";

const getTaToleranceDict = (tolerance) => {
if (typeof(tolerance) === "number") {
return {
ripe: tolerance,
apnic: tolerance,
arin: tolerance,
lacnic: tolerance,
afrinic: tolerance
}
}

return tolerance;
}

export default class MonitorROAS extends Monitor {

constructor(name, channel, params, env, input){
Expand All @@ -25,8 +39,8 @@ export default class MonitorROAS extends Monitor {
this.roaExpirationAlertHours = params.roaExpirationAlertHours || 2;
this.checkOnlyASns = params.checkOnlyASns != null ? params.checkOnlyASns : true;

this.toleranceExpiredRoasTA = params.toleranceExpiredRoasTA || 20;
this.toleranceDeletedRoasTA = params.toleranceDeletedRoasTA || 20;
this.toleranceExpiredRoasTA = getTaToleranceDict(params.toleranceExpiredRoasTA || 20);
this.toleranceDeletedRoasTA = getTaToleranceDict(params.toleranceDeletedRoasTA || 20);
this.timesDeletedTAs = {};
this.seenTAs = {};
this.monitored = {
Expand Down Expand Up @@ -84,7 +98,7 @@ export default class MonitorROAS extends Monitor {
const diff = max - min;
const percentage = 100 / max * diff;

if (percentage > this.toleranceDeletedRoasTA) {
if (percentage > this.toleranceDeletedRoasTA[ta]) {
const message = `Possible TA malfunction or incomplete VRP file: ${percentage.toFixed(2)}% of the ROAs disappeared from ${ta}`;

this.publishAlert(`disappeared-${ta}`,
Expand Down Expand Up @@ -115,7 +129,7 @@ export default class MonitorROAS extends Monitor {
const max = sizes[ta];
const percentage = (100 / max) * min;

if (percentage > this.toleranceExpiredRoasTA) {
if (percentage > this.toleranceExpiredRoasTA[ta]) {
const currentTaVrps = vrps.filter(i => i.ta === ta);
this._getExpiringItems(currentTaVrps)
.then(extra => {
Expand Down

0 comments on commit ef1523e

Please sign in to comment.