mirror of
https://github.com/openmhz/trunk-server.git
synced 2026-11-14 09:48:10 -05:00
fixed it!
This commit is contained in:
@@ -13,6 +13,7 @@ exports.get_stats = function(req, res) {
|
|||||||
var talkgroupStats = sysStats.talkgroupStats(short_name);
|
var talkgroupStats = sysStats.talkgroupStats(short_name);
|
||||||
var uploadErrors = sysStats.uploadErrors(short_name);
|
var uploadErrors = sysStats.uploadErrors(short_name);
|
||||||
let decodeErrorsFreq = sysStats.decodeErrorsFreq(short_name);
|
let decodeErrorsFreq = sysStats.decodeErrorsFreq(short_name);
|
||||||
|
|
||||||
if (callTotals && talkgroupStats) {
|
if (callTotals && talkgroupStats) {
|
||||||
res.contentType('json');
|
res.contentType('json');
|
||||||
res.send(JSON.stringify({
|
res.send(JSON.stringify({
|
||||||
|
|||||||
@@ -1,11 +1,16 @@
|
|||||||
var mongoose = require('mongoose');
|
var mongoose = require('mongoose');
|
||||||
|
|
||||||
let decodeErrorSchema = mongoose.Schema({
|
let decodeErrorSchema = mongoose.Schema({
|
||||||
|
totalLen: Number,
|
||||||
|
errors: Number,
|
||||||
|
spikes: Number,
|
||||||
errorHistory: [Number],
|
errorHistory: [Number],
|
||||||
spikeHistory: [Number],
|
spikeHistory: [Number],
|
||||||
})
|
})
|
||||||
|
|
||||||
let talkgroupStatsSchema = mongoose.Schema({
|
let talkgroupStatsSchema = mongoose.Schema({
|
||||||
|
calls: Number,
|
||||||
|
totalLen: Number,
|
||||||
callCountHistory: [Number],
|
callCountHistory: [Number],
|
||||||
callAvgLenHistory: [Number]
|
callAvgLenHistory: [Number]
|
||||||
})
|
})
|
||||||
|
|||||||
@@ -34,26 +34,26 @@ async function updateActiveSystems() {
|
|||||||
exports.initStats = async function () {
|
exports.initStats = async function () {
|
||||||
// get the System Stats collection
|
// get the System Stats collection
|
||||||
|
|
||||||
|
|
||||||
for await (const item of SystemStat.find()) {
|
for await (const item of SystemStat.find()) {
|
||||||
const obj = item.toObject();
|
const obj = item.toObject();
|
||||||
// Talkgroup Stats
|
// Talkgroup Stats
|
||||||
if (item.talkgroupStats != undefined) {
|
if (obj.talkgroupStats !== undefined) {
|
||||||
talkgroupStats[item.shortName] = obj.talkgroupStats;
|
talkgroupStats[obj.shortName] = Object.fromEntries(obj.talkgroupStats);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Decode Errors
|
// Decode Errors
|
||||||
if (item.decodeErrorsFreq != undefined) {
|
if (obj.decodeErrorsFreq !== undefined) {
|
||||||
decodeErrorsFreq[item.shortName] = obj.decodeErrorsFreq;
|
|
||||||
|
decodeErrorsFreq[obj.shortName] = Object.fromEntries(obj.decodeErrorsFreq);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Upload Error Totals
|
// Upload Error Totals
|
||||||
if (item.uploadErrors != undefined) {
|
if (obj.uploadErrors !== undefined) {
|
||||||
uploadErrors[item.shortName] = obj.uploadErrors;
|
uploadErrors[obj.shortName] = obj.uploadErrors;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (item.callTotals != undefined) {
|
if (obj.callTotals !== undefined) {
|
||||||
callTotals[item.shortName] = obj.callTotals;
|
callTotals[obj.shortName] = obj.callTotals;
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
@@ -62,7 +62,7 @@ exports.initStats = async function () {
|
|||||||
exports.addError = function (call) {
|
exports.addError = function (call) {
|
||||||
|
|
||||||
// if there is no Array associated with the system.
|
// if there is no Array associated with the system.
|
||||||
if (uploadErrors[call.shortName] == undefined) {
|
if (uploadErrors[call.shortName] === undefined) {
|
||||||
uploadErrors[call.shortName] = new Array();
|
uploadErrors[call.shortName] = new Array();
|
||||||
for (var j = 0; j < spots; j++) {
|
for (var j = 0; j < spots; j++) {
|
||||||
uploadErrors[call.shortName][j] = 0;
|
uploadErrors[call.shortName][j] = 0;
|
||||||
@@ -76,12 +76,12 @@ exports.addError = function (call) {
|
|||||||
// Keeps track of the number of calls for each talkgroup for a system
|
// Keeps track of the number of calls for each talkgroup for a system
|
||||||
exports.addCall = function (call) {
|
exports.addCall = function (call) {
|
||||||
// if you haven't started keeping track of stats for the System yet
|
// if you haven't started keeping track of stats for the System yet
|
||||||
if (talkgroupStats[call.shortName] == undefined) {
|
if (talkgroupStats[call.shortName] === undefined) {
|
||||||
talkgroupStats[call.shortName] = {};
|
talkgroupStats[call.shortName] = {};
|
||||||
}
|
}
|
||||||
var sysTalkgroupStats = talkgroupStats[call.shortName];
|
var sysTalkgroupStats = talkgroupStats[call.shortName];
|
||||||
// if you haven't started keeping track of Stats for this TG yet...
|
// if you haven't started keeping track of Stats for this TG yet...
|
||||||
if (sysTalkgroupStats[call.talkgroupNum] == undefined) {
|
if (sysTalkgroupStats[call.talkgroupNum] === undefined) {
|
||||||
sysTalkgroupStats[call.talkgroupNum] = {}
|
sysTalkgroupStats[call.talkgroupNum] = {}
|
||||||
sysTalkgroupStats[call.talkgroupNum].calls = 0;
|
sysTalkgroupStats[call.talkgroupNum].calls = 0;
|
||||||
sysTalkgroupStats[call.talkgroupNum].totalLen = 0;
|
sysTalkgroupStats[call.talkgroupNum].totalLen = 0;
|
||||||
@@ -105,7 +105,7 @@ exports.addCall = function (call) {
|
|||||||
var sysErrors = decodeErrorsFreq[call.shortName];
|
var sysErrors = decodeErrorsFreq[call.shortName];
|
||||||
|
|
||||||
// if you haven't started keeping track of Stats for this TG yet...
|
// if you haven't started keeping track of Stats for this TG yet...
|
||||||
if (sysErrors[call.freq] == undefined) {
|
if (sysErrors[call.freq] === undefined) {
|
||||||
sysErrors[call.freq] = {}
|
sysErrors[call.freq] = {}
|
||||||
sysErrors[call.freq].totalLen = 0;
|
sysErrors[call.freq].totalLen = 0;
|
||||||
sysErrors[call.freq].errors = 0;
|
sysErrors[call.freq].errors = 0;
|
||||||
|
|||||||
Reference in New Issue
Block a user