mirror of
https://github.com/jambonz/jambonz-feature-server.git
synced 2025-12-19 04:17:44 +00:00
fixes from initial load testing
This commit is contained in:
25
app.js
25
app.js
@@ -11,8 +11,6 @@ assert.ok(process.env.JAMBONES_NETWORK_CIDR, 'missing JAMBONES_SUBNET env var');
|
||||
|
||||
const Srf = require('drachtio-srf');
|
||||
const srf = new Srf();
|
||||
const Mrf = require('drachtio-fsmrf');
|
||||
srf.locals.mrf = new Mrf(srf);
|
||||
const PORT = process.env.HTTP_PORT || 3000;
|
||||
const opts = Object.assign({
|
||||
timestamp: () => {return `, "time": "${new Date().toISOString()}"`;}
|
||||
@@ -76,27 +74,4 @@ setInterval(() => {
|
||||
srf.locals.stats.gauge('fs.sip.calls.count', sessionTracker.count);
|
||||
}, 5000);
|
||||
|
||||
// report freeswitch stats periodically
|
||||
const fsOpts = srf.locals.getFreeswitch();
|
||||
const mrf = srf.locals.mrf;
|
||||
|
||||
async function pollFreeswitch(mrf) {
|
||||
const stats = srf.locals.stats;
|
||||
const ms = await mrf.connect(fsOpts);
|
||||
logger.info({freeswitch: fsOpts}, 'connected to freeswitch for metrics monitoring');
|
||||
setInterval(() => {
|
||||
try {
|
||||
stats.gauge('fs.media.channels.in_use', ms.currentSessions);
|
||||
stats.gauge('fs.media.channels.free', ms.maxSessions - ms.currentSessions);
|
||||
stats.gauge('fs.media.calls_per_second', ms.cps);
|
||||
stats.gauge('fs.media.cpu_idle', ms.cpuIdle);
|
||||
}
|
||||
catch (err) {
|
||||
logger.info(err, 'Error sending media server metrics');
|
||||
}
|
||||
}, 30000);
|
||||
}
|
||||
|
||||
pollFreeswitch(mrf).catch((err) => logger.error(err, 'Error polling freeswitch'));
|
||||
|
||||
module.exports = {srf, logger};
|
||||
|
||||
Reference in New Issue
Block a user