SNMP Trap Servers¶
You can easily add a SNMP Trap Server to the platform to capture SNMP Traps sent by your devices.
Remote Host: this is used if you want to limit your server to one particular IP address and block all others. Leave empty or set to
0.0.0.0 if you want your server to accept incoming Traps no matter where from. !!!Please Notice this is not a replacement for your firewall, which will still need to be configured accordingly.
Port: the port you want your server to listen on. The default for SNMP Traps is 162. Notice only one server can listen to a specific port, the first one will succeed in listening and the others will fail. ResIOT handles SNMP Servers in no specific order.
In your log, you will see if the server manages to start listening or if it fails and why.
Once listening, you will get traps reported to your log via the even
If you want to run a custom scene on trap arrival (using a smart scene), here's how to retrieve the SNMP data:
resiot_comm_getparam("snmpversion") -- will print the version of the trap resiot_comm_getparam("snmpcommunity") -- will print the community value of the trap resiot_comm_getparam("snmpvariables") -- will print the variables sent along with their values. resiot_comm_getparam("snmpenterprise") -- will print the enterprise trap value resiot_comm_getparam("snmpgenerictrap") -- will print the generic trap value resiot_comm_getparam("snmpspecifictrap") -- will print the specific trap value resiot_comm_getparam("snmpagentaddress") -- will print the agent address value of the trap
Because of the nature of the trap variables, we give access to a json containing all of them at once. You can then parse it as you would do with any other json.