1
0
mirror of https://github.com/nttgin/BGPalerter.git synced 2024-05-19 06:50:08 +00:00

simplified config file and changed some default values

This commit is contained in:
Massimo Candela
2019-10-27 01:35:10 +02:00
parent aad82a390a
commit b9f262b508
3 changed files with 15 additions and 13 deletions

View File

@@ -44,8 +44,14 @@ export default class Monitor {
this.monitored = [];
this.alerts = {};
this.sent = {};
this.internalConfig = {
notificationIntervalSeconds: this.config.notificationIntervalSeconds,
checkStaleNotificationsSeconds: 60,
clearNotificationQueueAfterSeconds: (this.config.notificationIntervalSeconds * 3) / 2
};
this.updateMonitoredPrefixes();
setInterval(this._publish, this.config.checkStaleNotificationsSeconds * 1000)
setInterval(this._publish, this.internalConfig.checkStaleNotificationsSeconds * 1000)
};
updateMonitoredPrefixes = () => {
@@ -129,7 +135,7 @@ export default class Monitor {
_clean = (group) => {
if (new Date().getTime() > group.latest + (this.config.clearNotificationQueueAfterSeconds * 1000)) {
if (new Date().getTime() > group.latest + (this.internalConfig.clearNotificationQueueAfterSeconds * 1000)) {
delete this.alerts[group.id];
delete this.sent[group.id];
@@ -145,7 +151,7 @@ export default class Monitor {
if (lastTimeSent) {
const isThereSomethingNew = lastTimeSent < group.latest;
const isItTimeToSend = new Date().getTime() > lastTimeSent + (this.config.notificationIntervalSeconds * 1000);
const isItTimeToSend = new Date().getTime() > lastTimeSent + (this.internalConfig.notificationIntervalSeconds * 1000);
return isThereSomethingNew && isItTimeToSend;
} else {