cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

Ingesting dummy SNMP traps into Dynatrace

AK
Pro

Hi Folks,

We have recently added SNMP extension to the monitoring and during testing we received some traps.

Now, we wanted to test it again however, it would be difficult for SNMP team to send the traps again just for testing.

Hence I'm looking out a way to send to traps via Dynatrace API.

Has anyone successfully ingested a SNMP traps to Dynatrace. Can someone please suggest.

This is how trap looks when sent to Dynatrace,

AK_0-1691162237211.png

Regards,

AK

3 REPLIES 3

AntonioSousa
DynaMight Guru
DynaMight Guru

@AK,

I have a client where we have managed to ingest more than 10K traps per minute. And it works pretty well.

If you want to inject traps into Dynatrace, I would suggest using pysnmp. Something like the following:

from pysnmp.hlapi import *

errorIndication, errorStatus, errorIndex, varBinds = next(
    sendNotification(
        SnmpEngine(),
        CommunityData('public', mpModel=1),
        UdpTransportTarget(('receiver_ip', 162)),
        ContextData(),
        'trap',
        NotificationType(ObjectIdentity('SNMPv2-MIB', 'linkDown')),
        ('1.3.6.1.2.1.2.2.1.2.1', OctetString('Interface eth0 is down')),
    )
)
Antonio Sousa

@AntonioSousa, thank you for the response.

What prep work I need do to post it? like, anything I need to install on my local system (e.g.-python)?

I never did anything like this before.

I was successfully able to post dummy log via log monitoring API with the static content however, "Device Statistics" graphs are not populating, see the screengrab below.

AK_1-1691998966775.png

I just wanted to post it one time for testing, this is my use case.

Regards,

AK

AntonioSousa
DynaMight Guru
DynaMight Guru

@AK,

If you have Linux, most certainly python is preinstalled. If you have Windows, you would have to install it.

I tried this on an out of the box Linux machine, and it did not work immediately. So here's what you need to do:

  1. Since you shouldn't have the pysnmp module, you have to install it:
    pip3 install pysnmp
  2. Copy the code below to traps.py. I have replaced the OID from a name to a straight OID, because you would have to install additional snmp libraries. You can use whatever OID you want.
  3. Replace 192.168.1.232 in the code to  your AG's IP address
  4. Execute it with
    python3 traps.py
  5. If you want to confirm that it's getting out, run the following command in another shell. It should show you the traps getting out.
    tcpdump -n udp port 162
from pysnmp.hlapi import *

receiver_ip = '192.168.1.232'
trap_oid = '1.3.6.1.4.1.12345.1.0'

errorIndication, errorStatus, errorIndex, varBinds = next(
    sendNotification(
        SnmpEngine(),
        CommunityData('public', mpModel=0),
        UdpTransportTarget((receiver_ip, 162)),
        ContextData(),
        'trap',
        NotificationType(ObjectIdentity(trap_oid)),
    )
)

 

Antonio Sousa

Featured Posts