Good morning, I use the GenieACS inform function to update the following parameters.
const hourly = Date.now()-600000;
// Refresh basic parameters hourly(30000=5 minutos)
declare(“InternetGatewayDevice.WANDevice.1.X_GponInterafceConfig.RXPower”, {path: hourly, value: hourly});
declare(“InternetGatewayDevice.WANDevice.1.X_GponInterafceConfig.TXPower”, {path: hourly, value: hourly});
declare(“InternetGatewayDevice.DeviceInfo.X_HW_CpuUsed”, {path: hourly, value: hourly});
declare(“InternetGatewayDevice.DeviceInfo.X_HW_MemUsed”, {path: hourly, value: hourly});
declare(“InternetGatewayDevice.LANDevice.1.WLANConfiguration.1.TotalAssociations”, {path: hourly, value: hourly});
declare(“InternetGatewayDevice.LANDevice.1.WLANConfiguration.5.TotalAssociations”, {path: hourly, value: hourly});
I have the following provision:
function get1(name) {
const q = declare(name, {value: 1});
return q.size ? q.value[0] : ‘’;
}
function hasTag(name) {
const tag = declare(Tags.${name}, { value: 1 });
return tag.size > 0;
}
function getUsername() {
for (let i = 1; i <= 10; i++) { // Limite de WANConnectionDevice (ajuste se quiser)
const path = InternetGatewayDevice.WANDevice.1.WANConnectionDevice.${i}.WANPPPConnection.1.Username;
const q = declare(path, { value: 1 });
if (q.size > 0 && q.value[0]) {
return q.value[0];
}
}
return “”;
}
const user = getUsername();
// Exemplo de leitura que só consulta cache
const sinal = get1(‘InternetGatewayDevice.WANDevice.1.X_GponInterafceConfig.RXPower’);
//const sinalTX = get1(‘InternetGatewayDevice.WANDevice.1.X_GponInterafceConfig.TXPower’);
const sinalTX = 2;
const cpu = get1(‘InternetGatewayDevice.DeviceInfo.X_HW_CpuUsed’);
const ram = get1(‘InternetGatewayDevice.DeviceInfo.X_HW_MemUsed’);
//const con2 = get1(‘InternetGatewayDevice.LANDevice.1.WLANConfiguration.1.TotalAssociations’);
//const con5 = get1(‘InternetGatewayDevice.LANDevice.1.WLANConfiguration.5.TotalAssociations’);
//const ram = 50;
const key = ‘AK4715091997’;
//const payload = { source: ‘genieacs’, event: ‘auto-reboot’, user, sinal, sinalTX, cpu, ram, key};
const payload = { source: ‘genieacs’, event: ‘auto-reboot’, user, sinal, sinalTX, cpu, ram, key};
try {
const resp = ext(‘events’, ‘send’, JSON.stringify(payload));
// log('Webhook resp: ’ + JSON.stringify(resp));
} catch (e) {
log('Webhook erro: ’ + e.toString());
}
The problem is that I can only retrieve 3 parameters; if I try to retrieve the others, I get session timeout errors.
Can anyone help me?
