Created
April 14, 2022 14:40
-
-
Save JonasGhost/f441b0dc880b72ef6a72cbf933aec062 to your computer and use it in GitHub Desktop.
monitoring provision genieacs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var device = declare("DeviceID.ID", { value: Date.now() }); | |
var lastMile = declare("VirtualParameters.Lastmile", { value: 1 }); | |
var points = []; | |
const parameters = [{ | |
cpePath: "VirtualParameters.DownstreamBandwidthDSL", | |
loggingName: "DownstreamBandwidthDSL", | |
transformation: function(value) { | |
return value; | |
} | |
}, | |
{ | |
cpePath: "VirtualParameters.MaxBandwidthCurrBandwidthPercentage", | |
loggingName: "MaxBandwidthCurrBandwidthPercentage", | |
transformation: function(value) { | |
return value; | |
} | |
}, | |
{ | |
cpePath: "VirtualParameters.Retrains", | |
loggingName: "Retrains", | |
transformation: function(value) { | |
return value; | |
} | |
}, | |
{ | |
cpePath: "VirtualParameters.CPEguessMaxBandwidth", | |
loggingName: "CPEguessMaxBandwidth", | |
transformation: function(value) { | |
return value; | |
} | |
}, | |
{ | |
cpePath: "VirtualParameters.Uptime", | |
loggingName: "Uptime", | |
transformation: function(value) { | |
return value; | |
} | |
}, | |
{ | |
cpePath: "VirtualParameters.memusage2", | |
loggingName: "MemoryUsage", | |
transformation: function(value) { | |
return value; | |
} | |
}, | |
{ | |
cpePath: "VirtualParameters.CRCErrors", | |
loggingName: "CRCErrors", | |
transformation: function(value) { | |
return value; | |
} | |
}, | |
{ | |
cpePath: "VirtualParameters.FECErrors", | |
loggingName: "FECErrors", | |
transformation: function(value) { | |
return value; | |
} | |
} | |
] | |
var points = [] | |
let localPoints = {} | |
for (var j = 0; j < parameters.length; j++) { | |
let parameterName = parameters[j].cpePath; | |
let parameterNicName = parameters[j].loggingName; | |
var parameterFromCPE = declare(parameterName, { path: 0, value: Date.now() }); | |
var parameterTimestamp = Date.now(); | |
if (parameterFromCPE.value[0] != "UNKNOWN") { | |
let tmpValue = parameters[j].transformation(parameterFromCPE.value[0]); | |
if (tmpValue !== null && tmpValue !== undefined) { | |
if (!localPoints[parameterTimestamp]) { | |
localPoints[parameterTimestamp] = { | |
measurement: 'lastmiles', | |
tags: { lastmile: lastMile.value[0], cpe_id: device.value[0] }, | |
fields: {}, | |
timestamp: parameterTimestamp * 1000000 | |
}; | |
} | |
localPoints[parameterTimestamp].fields[parameterNicName] = tmpValue; | |
} | |
} | |
} | |
let localPointsKeys = Object.keys(localPoints); | |
for (let k = 0; k < localPointsKeys.length; k++) { | |
points.push(localPoints[localPointsKeys[k]]); | |
} | |
if (args[0] && args[0] === "WRITE") { | |
log("writing to influx"); | |
ext("influxdb", "writeDataToInflux", JSON.stringify(points)); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment