Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[BUG] SNMP connector does not send all telemetry #819

Closed
farmerkz opened this issue May 4, 2022 · 5 comments · Fixed by #840
Closed

[BUG] SNMP connector does not send all telemetry #819

farmerkz opened this issue May 4, 2022 · 5 comments · Fixed by #840
Labels

Comments

@farmerkz
Copy link

farmerkz commented May 4, 2022

Describe the bug
My SNMP connector config:

{
  "devices": [
    {
      "deviceName": "ArzRouter",
      "deviceType": "snmp",
      "ip": "192.168.1.254",
      "port": 161,
      "pollPeriod": 5000,
      "community": "public",
      "attributes": [
        {
          "key": "sysDescr",
          "method": "get",
          "oid": "1.3.6.1.2.1.1.1.0",
          "timeout": 6
        }
      ],
      "telemetry": [
        {
          "key": "eth1-beeline",
          "method": "get",
          "oid": "1.3.6.1.2.1.2.2.1.8.1",
          "timeout": 1
        },
        {
          "key": "l2tp-beeline",
          "method": "get",
          "oid": "1.3.6.1.2.1.2.2.1.8.6",
          "timeout": 1
        }
      ]
    }
  ]
}

On thingsboard I only get the second telemetry value.

Connector name (If bug in the some connector):
SNMP Connector

Versions (please complete the following information):

  • OS: 20.04.4 LTS
  • Thingsboard IoT Gateway version v.3.3.4
  • Python version 3.8.10
@farmerkz farmerkz added the bug label May 4, 2022
@samson0v
Copy link
Contributor

samson0v commented May 6, 2022

Hi @farmerkz, we will investigate your problem and let you know about the results.
Thanks for your interest in ThingsBoard IoT Gateway!

@samson0v samson0v linked a pull request May 31, 2022 that will close this issue
@aedahh
Copy link

aedahh commented Jun 4, 2022

Hello @farmerkz, sorry for posting to this ticket. From your post, looks like getting snmp telemetry is working for your, so hope you can share some insights. I am new to Thingsboard and also try to get snmp from telemetry from local on premise device. I am running an iot-gateway locally from docker image and try to send telemetry data to my https://thingsboard.cloud instance. I don't know if this configuration is supported as I always get mqtt connection error and snmp time out.
image

Are you running a local Thingsboard instance or cloud?
Can you share your configuration files and uplink and downlink converter code to parse snmp telemetry?
Looking forward to your reply. Thanks

@farmerkz
Copy link
Author

Hi @aedahh !
I am using a local Thingsboard server and the tb-gateway is also on the same network as the server.

snmp.json:

{
  "devices": [
    {
      "deviceName": "ArzRouter",
      "deviceType": "snmp",
      "ip": "192.168.1.254",
      "port": 161,
      "pollPeriod": 5000,
      "community": "public",
      "attributes": [
        {
          "key": "sysDescr",
          "method": "get",
          "oid": "1.3.6.1.2.1.1.1.0",
          "timeout": 6
        }
      ],
      "telemetry": [
        {
          "key": "eth1-beeline",
          "method": "get",
          "oid": "1.3.6.1.2.1.2.2.1.8.1",
          "timeout": 6
        }
      ]
    },
    {
      "deviceName": "ArzRouter",
      "deviceType": "snmp",
      "ip": "192.168.1.254",
      "port": 161,
      "pollPeriod": 5000,
      "community": "public",
      "attributes": [
        {
          "key": "sysDescr",
          "method": "get",
          "oid": "1.3.6.1.2.1.1.1.0",
          "timeout": 6
        }
      ],
      "telemetry": [
        {
          "key": "l2tp-beeline",
          "method": "get",
          "oid": "1.3.6.1.2.1.2.2.1.8.6",
          "timeout": 1
        }
      ]
    }
  ]
}

@ts4iot
Copy link

ts4iot commented Jul 12, 2023

I think this issue/bug is not really solved, it is only fixed by a configuration workaround. The snmp.json from @farmerkz first post:

"telemetry": [
  {
    "key": "eth1-beeline",
    "method": "get",
    "oid": "1.3.6.1.2.1.2.2.1.8.1",
    "timeout": 1
  },
  {
    "key": "l2tp-beeline",
    "method": "get",
    "oid": "1.3.6.1.2.1.2.2.1.8.6",
    "timeout": 1
  }
]

should be possible because the element "telemetry" is an array, and it makes no sense to create multiple device entries to transfer multiple oids from one device. The move of the following code snipped (see: file snmp_connector.py) out of the loop leads to the problem that only the last element of the array will be transmitted to the platform:

if isinstance(converted_data, dict) and (converted_data.get("attributes") or converted_data.get("telemetry")):
    self.collect_statistic_and_send(self.get_name(), converted_data)

After moving the code snipped again in to the loop all values will be transmitted but then I got the following error:

|ERROR| - [tb_gateway_service.py] - tb_gateway_service - __send_to_storage - 861 - 'str' object has no attribute 'get'"

The error occures in the following section of function validate_converted_data(data) in file tb_utility.py:

if data.get("telemetry") is not None:
    for entry in data.get("telemetry"):
        if (entry.get("ts") is not None and len(entry.get("values")) > 0) or entry.get("ts") is None:
            got_telemetry = True
            break

This should be fixed.

@Yassinebouothman
Copy link

Hey @farmerkz, do you know how can I use SNMP in the cloud version of thingsboard not the one installed locally? Thanks.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging a pull request may close this issue.

5 participants