• Recent
    • Tags
    • Popular
    • Register
    • Login

    Please Note This forum exists for community support for the Mango product family and the Radix IoT Platform. Although Radix IoT employees participate in this forum from time to time, there is no guarantee of a response to anything posted here, nor can Radix IoT, LLC guarantee the accuracy of any information expressed or conveyed. Specific project questions from customers with active support contracts are asked to send requests to support@radixiot.com.

    Radix IoT Website Mango 3 Documentation Website Mango 4 Documentation Website Mango 5 Documentation Website

    SNMP Publisher / Agent

    Mango Automation general Discussion
    3
    4
    1.6k
    Loading More Posts
    • Oldest to Newest
    • Newest to Oldest
    • Most Votes
    Reply
    • Reply as topic
    Log in to reply
    This topic has been deleted. Only users with topic management privileges can see it.
    • ricardoR
      ricardo
      last edited by

      Hi,

      Can Mango publish data as a SNMP agent? Can Mango send SNMP traps as an Event Handler type?

      BR,
      Ricardo

      1 Reply Last reply Reply Quote 0
      • CraigWebC
        CraigWeb
        last edited by

        Hi @ricardo

        Mango only has 4 publishers: BACnet, Modbus, Mango PTCP and an HTTP publisher

        phildunlapP 1 Reply Last reply Reply Quote 0
        • phildunlapP
          phildunlap
          last edited by phildunlap

          Hi Ricardo,

          No, Mango does not currently have an SNMP publisher.

          Can Mango send SNMP traps as an Event Handler type?

          Yes, but it isn't really set up to make such a thing easy. I think we'd best to have a running SNMP data source and use some reflection, something like this, in a Set Point Event Handler,

          //untested
          var snmpDataSourceId = com.serotonin.m2m2.db.dao.DataPointDao.instance.getIdByXid("DS_XID_HERE");
          var snmpDataSourceRT = com.serotonin.m2m2.Common.runtimeManager.getRunningDataSource( snmpDataSourceId );
          if( snmpDataSourceRT !== null ) {
              var field = snmpDataSourceRT.getClass().getDeclearedField("snmp");
              field.setAccessible( true );
              var snmp = field.get( snmpDataSourceRT );
          
              //get the SNMP version information
              field = snmpDataSourceRT.getClass().getDeclearedField("writeVersion");
              field.setAccessible( true );
              var writeVersion = field.get( snmpDataSourceRT );
          
              //get the target to send it to
              var target = writeVersion.getTarget( "192.168.0.123", 162, 1, 5000 ); //host, port, retries, timeout
              //construct the PDU
              var pdu = writeVersion.createPDU();
          
              if( target.getVersion === org.snmp4j.mp.SnmpConstants.version1 ) {
                  pdu.setType( org.snmp4j.PDU.V1TRAP );
                  pdu.setEnterprise( new org.snmp4j.smi.OID( "1.1.1.1.1.1.1") ); //probably a clever way to get the OID from the event
                  pdu.setGenericTrap( org.snmp4j.PDUv1.ENTERPRISE_SPECIFIC );
                  pdu.setSpecificTrap( 1 ); //looks like this may need to cycle in value 1-5
                  pdu.setAgentAddress( new org.snmp4j.smi.IpAddress( "127.0.0.1" )); //Mango's IP on the network here
                  snmp.send( pdu, target );
              } else if ( target.getVersion === org.snmp4j.mp.SnmpConstants.version2c ) {
                  throw "not yet implemented!";
              } else if ( target.getVersion === org.snmp4j.mp.SnmpConstants.version3 ) {
                  throw "not yet implemented!";
              } else
                  throw "unknown snmp version!";
          } else {
              throw "Data source not found to send trap for event: " + event;
          }
          return UNCHANGED; //don't set from the set point handler
          

          I would be somewhat surprised if this works, but it shouldn't be too far from the way to do it. I consulted this site for the V1 implementation, and there is also a v2c example: https://www.jitendrazaa.com/blog/java/snmp/generating-trap-in-snmp-using-snmp4j/

          So, possible, but will probably take some trial and error to figure out.

          1 Reply Last reply Reply Quote 0
          • phildunlapP
            phildunlap @CraigWeb
            last edited by phildunlap

            @craigweb said in SNMP Publisher / Agent:

            Hi @ricardo

            Mango only has 4 publishers: BACnet, Modbus, Mango PTCP and an HTTP publisher

            Also Twilio and Pachube.

            1 Reply Last reply Reply Quote 0
            • First post
              Last post