averaging fixed
This commit is contained in:
6
dist/missingeventdetector.js
vendored
6
dist/missingeventdetector.js
vendored
@ -3,7 +3,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|||||||
const log = require("./log");
|
const log = require("./log");
|
||||||
const CallChain = require("./callchain");
|
const CallChain = require("./callchain");
|
||||||
const Processor = require("./processor");
|
const Processor = require("./processor");
|
||||||
const CHECK_PERIOD = 10; // seconds
|
const CHECK_PERIOD = 60; // seconds
|
||||||
class ClientEntry {
|
class ClientEntry {
|
||||||
}
|
}
|
||||||
class MissingEventProcessor extends Processor.AProcessor {
|
class MissingEventProcessor extends Processor.AProcessor {
|
||||||
@ -28,7 +28,9 @@ class MissingEventProcessor extends Processor.AProcessor {
|
|||||||
clientEntry.delay = currentTime - clientEntry.lastEvent;
|
clientEntry.delay = currentTime - clientEntry.lastEvent;
|
||||||
clientEntry.lastEvent = currentTime;
|
clientEntry.lastEvent = currentTime;
|
||||||
clientEntry.count += 1;
|
clientEntry.count += 1;
|
||||||
|
if (clientEntry.count >= 1) {
|
||||||
clientEntry.delaySum += clientEntry.delay;
|
clientEntry.delaySum += clientEntry.delay;
|
||||||
|
}
|
||||||
clientEntry.avgDelay = clientEntry.delaySum / clientEntry.count;
|
clientEntry.avgDelay = clientEntry.delaySum / clientEntry.count;
|
||||||
this.clientMap.set(client, clientEntry);
|
this.clientMap.set(client, clientEntry);
|
||||||
log.info(`Entry for ${client} updated`);
|
log.info(`Entry for ${client} updated`);
|
||||||
@ -38,7 +40,7 @@ class MissingEventProcessor extends Processor.AProcessor {
|
|||||||
clientEntry.client = client;
|
clientEntry.client = client;
|
||||||
clientEntry.lastEvent = currentTime;
|
clientEntry.lastEvent = currentTime;
|
||||||
clientEntry.delay = 0;
|
clientEntry.delay = 0;
|
||||||
clientEntry.count = 0;
|
clientEntry.count = -1;
|
||||||
clientEntry.delaySum = 0;
|
clientEntry.delaySum = 0;
|
||||||
clientEntry.avgDelay = 0;
|
clientEntry.avgDelay = 0;
|
||||||
this.clientMap.set(client, clientEntry);
|
this.clientMap.set(client, clientEntry);
|
||||||
|
@ -3,7 +3,7 @@ import * as CallChain from './callchain'
|
|||||||
import * as Processor from './processor'
|
import * as Processor from './processor'
|
||||||
|
|
||||||
|
|
||||||
const CHECK_PERIOD : number = 10 // seconds
|
const CHECK_PERIOD : number = 60 // seconds
|
||||||
|
|
||||||
class ClientEntry {
|
class ClientEntry {
|
||||||
client : string
|
client : string
|
||||||
@ -39,7 +39,9 @@ class MissingEventProcessor extends Processor.AProcessor {
|
|||||||
clientEntry.delay = currentTime - clientEntry.lastEvent
|
clientEntry.delay = currentTime - clientEntry.lastEvent
|
||||||
clientEntry.lastEvent = currentTime
|
clientEntry.lastEvent = currentTime
|
||||||
clientEntry.count += 1
|
clientEntry.count += 1
|
||||||
|
if (clientEntry.count >= 1) {
|
||||||
clientEntry.delaySum += clientEntry.delay
|
clientEntry.delaySum += clientEntry.delay
|
||||||
|
}
|
||||||
clientEntry.avgDelay = clientEntry.delaySum / clientEntry.count
|
clientEntry.avgDelay = clientEntry.delaySum / clientEntry.count
|
||||||
this.clientMap.set(client, clientEntry)
|
this.clientMap.set(client, clientEntry)
|
||||||
log.info(`Entry for ${client} updated`)
|
log.info(`Entry for ${client} updated`)
|
||||||
@ -48,7 +50,7 @@ class MissingEventProcessor extends Processor.AProcessor {
|
|||||||
clientEntry.client = client
|
clientEntry.client = client
|
||||||
clientEntry.lastEvent = currentTime
|
clientEntry.lastEvent = currentTime
|
||||||
clientEntry.delay = 0
|
clientEntry.delay = 0
|
||||||
clientEntry.count = 0
|
clientEntry.count = -1
|
||||||
clientEntry.delaySum = 0
|
clientEntry.delaySum = 0
|
||||||
clientEntry.avgDelay = 0
|
clientEntry.avgDelay = 0
|
||||||
this.clientMap.set(client, clientEntry)
|
this.clientMap.set(client, clientEntry)
|
||||||
|
Reference in New Issue
Block a user