SNMP function for Ignition version 8

Thanks to both the Norcal-SNMP and Embr-SNMP teams for their efforts to make their SNMP drivers work. I have tested both successfully (read only, v2c) in the office with some of our rapid deployment field equipment where SNMP is the only monitoring we’ve got (and very limited at that). The field failure risk is relatively high (esp for power) due to the rapid, limited, compromised and temporary nature of the deployments so hopefully we can monitor, alarm and intervene before failure. It will also enable to log data on the equipment’s performance over time to optimise specs.

Best regards,
Patrick.

Is there a minimum required version of Ignition for this module?

I’m using it on an 8.1.33 so can’t comment other than that.

I’ve updated this today, it now includes an option to use a privacy key for encryption, along with many error reporting improvements, and an updated readme.

ignition-module-snmp

I just submitted a PR for 8.3 support on this module. No idea if you have GH notifications enabled.

2 Likes

Yup, seen!
I can’t promise when I’ll get to look at it (busy season), but I can promise that I will look at it.

2 Likes

Beta PR (local build posted here)

Adds scripting functions for reading, writing, and walking.

5 Likes

Another beta:

Changes:

  1. Add system.snmp.agent.readTable for reading tables as datasets.
    You are expected to provide the columns of the table, and optionally lower/upper bound indexes for the section of the table you'd like to access.

Example:

system.snmp.agent.readTable('printer', columns=['1.3.6.1.2.1.2.2.1.2', '1.3.6.1.2.1.2.2.1.6'], lowerBoundIndex='0', upperBoundIndex='2')

Result:

subindex | 1.3.6.1.2.1.2.2.1.2 | 1.3.6.1.2.1.2.2.1.6
-----------------------------------------------------
1        | NC-46004h           | 00:80:77:5d:8b:f1  
2        | SoftwareLoopBack    |                    
  1. system.snmp.agent.read and system.snmp.agent.walk now return lists of QualifiedOidValues. You've got the standard QualifiedValue stuff, plus an attached .oid/.getOid().
  2. system.snmp.agent.write now returns a list of QualityCodes.
  3. Full keyword argument support.

Next step before release is Blocking/Async versions.


Final-ish beta, with async and blocking methods.

  • system.snmp.agent.read (hidden, uses blocking implementation)
  • system.snmp.agent.readAsync
  • system.snmp.agent.readBlocking
  • system.snmp.agent.write (hidden, uses blocking implementation)
  • system.snmp.agent.writeAsync
  • system.snmp.agent.writeBlocking
  • system.snmp.agent.walk (hidden, uses blocking implementation)
  • system.snmp.agent.walkAsync
  • system.snmp.agent.walkBlocking
  • system.snmp.agent.readTable (hidden, uses blocking implementation)
  • system.snmp.agent.readTableAsync
  • system.snmp.agent.readTableBlocking
  1. The async methods return PyCompletableFutures.
  2. The QualifiedOidValues now use a custom Oid class instead of directly using SNMP4J's OID type.

PyCompletableFuture

In order to execute asynchronously this function returns a PyCompletableFuture. This is wrapper around a Java CompletableFuture with convenience functions for interacting with Python scripting. PyCompletableFuture functions very similarly to the Promise objects returned from system.net.httpClient calls.

Methods

Signature Returns Description
getFuture() CompletableFuture Returns the raw underlying CompletableFuture.
cancel() Boolean Cancels the completion of this future.
isDone() Boolean Checks if the future is complete.
then(callback) PyCompletableFuture Return a new PyCompletableFuture that wraps this one's return value in a Python callable.
handleException(callback) PyCompletableFuture Return a new PyCompletableFuture that will run the provided callback in the event of an exception, to attempt graceful error handling.
whenComplete(callback) None Call callback, asynchronously, whenever this future completes.

Example:

def displayValue(result, e):
	system.vision.showMessage(str(result[0].value), "Async Operation Complete")

future = system.snmp.agent.readAsync('printer', ['1.3.6.1.2.1.1.5.0'])
future.whenComplete(displayValue)

Any feedback would be great, especially related to the usability of readTable.

Embr-SNMP-Ignition83-0.3.0.modl (866.6 KB)

7 Likes

I merged your PR, but looks like Ben has off and run with it - more time than I’ve had with it!! I’ll go check his out now.

1 Like

My bad, I didn’t mean to derail this thread :joy: At some point I got tagged here and lost the context.

4 Likes