markabrahams / node-net-snmp

JavaScript implementation of the Simple Network Management Protocol (SNMP)
209 stars 97 forks source link

How can I assign a handler to provider loaded from MIB via registerProviders method? #246

Closed ivanbaj closed 7 months ago

ivanbaj commented 8 months ago

How can I assign a handler to provider loaded from MIB via registerProviders method?

I need to load a MIB and set values dynamically as the request (GET) are coming in.

I am able to do this for a provider defined in JS but I can't figure put how to do this win automatically created providers form the loaded MIB file.

markabrahams commented 7 months ago

Hi @ivanbaj - you can assign a handler directly on the provider e.g.

agent.getProvider("yourRegisteredProviderName").handler = (mibRequest) => {
  console.log("Extra hello");
  mibRequest.done();
}