Update params at end of provisions

Hi all,

I have two provisions, the first one update some params and add a tag:

const now = Date.now()

declare(
  'VirtualParameters.bytesReceived', 
   { value: now }, 
)

const wait = ext('getTimestamp', 'getTimestamp', JSON.stringify({ now }))

declare(
  'InternetGatewayDevice.WANDevice.1.WANCommonInterfaceConfig.TotalBytesReceived', 
  {path: now}, 
)

declare('Tags.Updated', null, {value: true})

log('Atualização finalizada')

After this, I have other that collect the values and do some math.

The question is: the values are just updated after both provisions end, but I read that there’s a implicit commit() at end of each provision, so, why the values are not updated before the second provisions starts?

There’s the second provision:

log('Coleta iniciada')
const now = Date.now()

const bytesAnteriores = declare(
  'VirtualParameters.bytesReceived', 
  { value: 1 }
).value[0]

const bytesAtuais = declare(
  'InternetGatewayDevice.WANDevice.1.WANCommonInterfaceConfig.TotalBytesReceived', 
  { value: 1 },
).value[0]


const traffic = Math.trunc(((bytesAtuais - bytesAnteriores)*8)/1000000)

log(`Download in Mb: ${traffic}`)

and log of event:

2023-07-24T19:51:32.390Z [INFO] 10.0.0.253 00259E-HG8121H-48575443A53FF09E: Inform; cpeRequestId="630" informEvent="6 CONNECTION REQUEST" informRetryCount=0
2023-07-24T19:51:32.428Z [INFO] 10.0.0.253 00259E-HG8121H-48575443A53FF09E: ACS request; acsRequestId="1898974fb050000" acsRequestName="GetParameterNames"
2023-07-24T19:51:32.443Z [INFO] 10.0.0.253 00259E-HG8121H-48575443A53FF09E: ACS request; acsRequestId="1898974fb050001" acsRequestName="GetParameterNames"
2023-07-24T19:51:32.456Z [INFO] 10.0.0.253 00259E-HG8121H-48575443A53FF09E: ACS request; acsRequestId="1898974fb050002" acsRequestName="GetParameterNames"
2023-07-24T19:51:32.521Z [INFO] 10.0.0.253 00259E-HG8121H-48575443A53FF09E: ACS request; acsRequestId="1898974fb050003" acsRequestName="GetParameterNames"
2023-07-24T19:51:32.538Z [INFO] 10.0.0.253 00259E-HG8121H-48575443A53FF09E: ACS request; acsRequestId="1898974fb050004" acsRequestName="GetParameterNames"
2023-07-24T19:51:32.556Z [INFO] 10.0.0.253 00259E-HG8121H-48575443A53FF09E: ACS request; acsRequestId="1898974fb050005" acsRequestName="GetParameterNames"
2023-07-24T19:51:32.625Z [INFO] 10.0.0.253 00259E-HG8121H-48575443A53FF09E: ACS request; acsRequestId="1898974fb050006" acsRequestName="GetParameterNames"
2023-07-24T19:51:32.651Z [INFO] 10.0.0.253 00259E-HG8121H-48575443A53FF09E: ACS request; acsRequestId="1898974fb050007" acsRequestName="GetParameterValues"
2023-07-24T19:51:35.057Z [INFO] 10.0.0.253 00259E-HG8121H-48575443A53FF09E: Script: Atualização finalizada
2023-07-24T19:51:35.082Z [INFO] 10.0.0.253 00259E-HG8121H-48575443A53FF09E: ACS request; acsRequestId="1898974fb050200" acsRequestName="GetParameterNames"
2023-07-24T19:51:35.123Z [INFO] 10.0.0.253 00259E-HG8121H-48575443A53FF09E: ACS request; acsRequestId="1898974fb050201" acsRequestName="GetParameterValues"
2023-07-24T19:51:35.228Z [INFO] 10.0.0.253 00259E-HG8121H-48575443A53FF09E: ACS request; acsRequestId="1898974fb050202" acsRequestName="GetParameterNames"
2023-07-24T19:51:35.250Z [INFO] 10.0.0.253 00259E-HG8121H-48575443A53FF09E: Script: Coleta iniciada
2023-07-24T19:51:37.271Z [INFO] 10.0.0.253 00259E-HG8121H-48575443A53FF09E: Script: Atualização finalizada
2023-07-24T19:51:37.275Z [INFO] 10.0.0.253 00259E-HG8121H-48575443A53FF09E: Script: Download in Mb: 0

This is not refresh the value from the router. {value: 1} means if there is currently a value in the mongo db for the param requested, use that. You need to use {value: Date.now()} to refresh the value.

What are you trying to do with this line? I don’t see it used anywhere in your provision script.

Actually I do like this in the firts provision, the second it’s just to get the values already updated, but, as I said, the parameter is just updated before two provisions end, so,the value I get is not a updated value.

About

const wait = ext('getTimestamp', 'getTimestamp', JSON.stringify({ now }))

It’s an external function to wait 2 seconds. My idea is use that to get traffic in real time, got it?

if your goal is to get the traffic in real time as you said then you are using the wrong tool.

snmp is what you need. the acs can only help you to fire diagnostics on cpe side.

ok, thanks for answer!

SNMP as @rudymartin said is one way.

Another option is to get the stats directly from the access controller. I poll our access controller once per second and then I graph this data in our subscriber management system. Blue dashed line is the max download speed. Orange dashed line is max upload speed. They are offset from each other so we customers have a symmetrical connection, you can still see both lines. See screenshot 2.

1 Like

Realy nice, I’ll search for other tool to do that. Thanks again!

Very Interested