home-assistant / core

:house_with_garden: Open source home automation that puts local control and privacy first.
https://www.home-assistant.io
Apache License 2.0
68.78k stars 28.11k forks source link

HA core warning: Setup of sensor platform snmp is taking over 10 seconds. #116156

Closed 7wells closed 1 week ago

7wells commented 1 week ago

The problem

Logger: homeassistant.components.sensor Source: runner.py:189 integration: Sensor (documentation, issues) First occurred: 10:06:06 AM (2 occurrences) Last logged: 10:06:06 AM

Setup of sensor platform snmp is taking over 10 seconds.

-- The sensor values from SNMP are ok. Maybe the warning is just what it is, a warning, and I should ignore it? But if it means that there is something wrong, I would be grateful for help to find the reason for the problem and eventually resolve it.

I understand that this is a duplicate of https://github.com/home-assistant/core/issues/71368 and https://github.com/home-assistant/core/issues/75153.

However, both issues were closed in 2022, there is no possibility to add text to them, and the possible solutions laid out there did not help me. Therefore, I opened this new one. I hope that someone can kindly point me into the right direction. Thank you!

What version of Home Assistant Core has the issue?

2024.4.4

What was the last working version of Home Assistant Core?

This is the first version where I use SNMP.

What type of installation are you running?

Home Assistant OS

Integration causing the issue

SNMP

Link to integration documentation on our website

https://www.home-assistant.io/integrations/snmp

Diagnostics information

No response

Example YAML snippet

/homeassistant/sensors/teltonika.yaml

### Teltonika SNMP

# Mobile

- platform: snmp
  host: 192.168.11.1
  port: 161
  version: 2c
  community: public
  accept_errors: true
  name: 'Teltonika mobile SIM state'
  unique_id: teltonika_mobile_SIM_state
  baseoid: .1.3.6.1.4.1.48690.2.2.1.9.1

- platform: snmp
  host: 192.168.11.1
  port: 161
  version: 2c
  community: public
  accept_errors: true
  name: 'Teltonika mobile PIN state'
  unique_id: teltonika_mobile_PIN_state
  baseoid: .1.3.6.1.4.1.48690.2.2.1.10.1

- platform: snmp
  host: 192.168.11.1
  port: 161
  version: 2c
  community: public
  accept_errors: true
  name: 'Teltonika mobile network state'
  unique_id: teltonika_mobile_network_state
  baseoid: .1.3.6.1.4.1.48690.2.2.1.11.1

- platform: snmp
  host: 192.168.11.1
  port: 161
  version: 2c
  community: public
  accept_errors: true
  name: 'Teltonika mobile signal strength'
  unique_id: teltonika_mobile_signal_strength
  unit_of_measurement: dBm
  baseoid: .1.3.6.1.4.1.48690.2.2.1.12.1

- platform: snmp
  host: 192.168.11.1
  port: 161
  version: 2c
  community: public
  accept_errors: true
  name: 'Teltonika mobile operator name'
  unique_id: teltonika_mobile_operator_name
  baseoid: .1.3.6.1.4.1.48690.2.2.1.13.1

- platform: snmp
  host: 192.168.11.1
  port: 161
  version: 2c
  community: public
  accept_errors: true
  name: 'Teltonika mobile operator number'
  unique_id: teltonika_mobile_operator_number
  baseoid: .1.3.6.1.4.1.48690.2.2.1.14.1

- platform: snmp
  host: 192.168.11.1
  port: 161
  version: 2c
  community: public
  accept_errors: true
  name: 'Teltonika mobile connection state'
  unique_id: teltonika_mobile_connection_state
  baseoid: .1.3.6.1.4.1.48690.2.2.1.15.1

- platform: snmp
  host: 192.168.11.1
  port: 161
  version: 2c
  community: public
  accept_errors: true
  name: 'Teltonika mobile network type'
  unique_id: teltonika_mobile_network_type
  baseoid: .1.3.6.1.4.1.48690.2.2.1.16.1

- platform: snmp
  host: 192.168.11.1
  port: 161
  version: 2c
  community: public
  accept_errors: true
  name: 'Teltonika mobile temperature'
  unique_id: teltonika_mobile_temperature
  unit_of_measurement: °C
  baseoid: .1.3.6.1.4.1.48690.2.2.1.17.1

- platform: snmp
  host: 192.168.11.1
  port: 161
  version: 2c
  community: public
  accept_errors: true
  name: 'Teltonika mobile cell ID'
  unique_id: teltonika_mobile_cell_ID
  baseoid: .1.3.6.1.4.1.48690.2.2.1.18.1

- platform: snmp
  host: 192.168.11.1
  port: 161
  version: 2c
  community: public
  accept_errors: true
  name: 'Teltonika mobile SINR'
  unique_id: teltonika_mobile_SINR
  unit_of_measurement: dB
  baseoid: .1.3.6.1.4.1.48690.2.2.1.19.1

- platform: snmp
  host: 192.168.11.1
  port: 161
  version: 2c
  community: public
  accept_errors: true
  name: 'Teltonika mobile RSRP'
  unique_id: teltonika_mobile_RSRP
  unit_of_measurement: dBm
  baseoid: .1.3.6.1.4.1.48690.2.2.1.20.1

- platform: snmp
  host: 192.168.11.1
  port: 161
  version: 2c
  community: public
  accept_errors: true
  name: 'Teltonika mobile RSRQ'
  unique_id: teltonika_mobile_RSRQ
  unit_of_measurement: dB
  baseoid: .1.3.6.1.4.1.48690.2.2.1.21.1

- platform: snmp
  host: 192.168.11.1
  port: 161
  version: 2c
  community: public
  accept_errors: true
  name: 'Teltonika mobile total bytes sent'
  unique_id: teltonika_mobile_total_bytes_sent
  baseoid: .1.3.6.1.4.1.48690.2.2.1.22.1

- platform: snmp
  host: 192.168.11.1
  port: 161
  version: 2c
  community: public
  accept_errors: true
  name: 'Teltonika mobile total bytes received'
  unique_id: teltonika_mobile_total_bytes_received
  baseoid: .1.3.6.1.4.1.48690.2.2.1.23.1

- platform: snmp
  host: 192.168.11.1
  port: 161
  version: 2c
  community: public
  accept_errors: true
  name: 'Teltonika mobile modem IP address'
  unique_id: teltonika_mobile_modem_IP_address
  baseoid: .1.3.6.1.4.1.48690.2.2.1.24.1

- platform: snmp
  host: 192.168.11.1
  port: 161
  version: 2c
  community: public
  accept_errors: true
  name: 'Teltonika mobile bytes sent today'
  unique_id: teltonika_mobile_bytes_sent_today
  baseoid: .1.3.6.1.4.1.48690.2.2.1.25.1

- platform: snmp
  host: 192.168.11.1
  port: 161
  version: 2c
  community: public
  accept_errors: true
  name: 'Teltonika mobile bytes received today'
  unique_id: teltonika_mobile_bytes_received_today
  baseoid: .1.3.6.1.4.1.48690.2.2.1.26.1

- platform: snmp
  host: 192.168.11.1
  port: 161
  version: 2c
  community: public
  accept_errors: true
  name: 'Teltonika mobile SIM ICCID'
  unique_id: teltonika_mobile_SIM_ICCID
  baseoid: .1.3.6.1.4.1.48690.2.2.1.27.1

# GPS

- platform: snmp
  host: 192.168.11.1
  port: 161
  version: 2c
  community: public
  accept_errors: true
  name: 'Teltonika GPS latitude'
  unique_id: teltonika_gps_latitude
  baseoid: .1.3.6.1.4.1.48690.3.1.0

- platform: snmp
  host: 192.168.11.1
  port: 161
  version: 2c
  community: public
  accept_errors: true
  name: 'Teltonika GPS longitude'
  unique_id: teltonika_gps_longitude
  baseoid: .1.3.6.1.4.1.48690.3.2.0

- platform: snmp
  host: 192.168.11.1
  port: 161
  version: 2c
  community: public
  accept_errors: true
  name: 'Teltonika GPS accuracy'
  unique_id: teltonika_gps_accuracy
  baseoid: .1.3.6.1.4.1.48690.3.3.0

- platform: snmp
  host: 192.168.11.1
  port: 161
  version: 2c
  community: public
  accept_errors: true
  name: 'Teltonika GPS sat fix time'
  unique_id: teltonika_gps_fixtime
  baseoid: .1.3.6.1.4.1.48690.3.4.0

- platform: snmp
  host: 192.168.11.1
  port: 161
  version: 2c
  community: public
  accept_errors: true
  name: 'Teltonika GPS sat number'
  unique_id: teltonika_gps_numsat
  baseoid: .1.3.6.1.4.1.48690.3.5.0

Anything in the logs that might be useful for us?

No response

Additional information

HA runs on a Raspberry Pi 4. The link between the Teltonika router (SNMP) and the RPi4 is via Wifi. The connection is strong and stable. But maybe this is nevertheless the reason for the setup of the sensor platform SNMP taking over 10 seconds?

home-assistant[bot] commented 1 week ago

Hey there @nmaggioni, mind taking a look at this issue as it has been labeled with an integration (snmp) you are listed as a code owner for? Thanks!

Code owner commands Code owners of `snmp` can trigger bot actions by commenting: - `@home-assistant close` Closes the issue. - `@home-assistant rename Awesome new title` Renames the issue. - `@home-assistant reopen` Reopen the issue. - `@home-assistant unassign snmp` Removes the current integration label and assignees on the issue, add the integration domain after the command. - `@home-assistant add-label needs-more-information` Add a label (needs-more-information, problem in dependency, problem in custom component) to the issue. - `@home-assistant remove-label needs-more-information` Remove a label (needs-more-information, problem in dependency, problem in custom component) on the issue.

(message by CodeOwnersMention)


snmp documentation snmp source (message by IssueLinks)

nmaggioni commented 1 week ago

I know this is a stupid question, but are you sure that this log entry is recent and is not a leftover from the issues that were present in the past few HA releases? Does it reappear every time you clean the logs and restart HA?

Moving on to troubleshooting: the default timeout is currently 8s for each device, so it could be possible that with that many endpoints to query the global 10s limit could be exceeded if the they don't reply instantaneously. I'm not seeing that warning on my instance with polling of just a couple network appliances, could you try commenting out all but one of the devices in your config and see if the warning comes up anyway?

7wells commented 1 week ago

I know this is a stupid question, but are you sure that this log entry is recent and is not a leftover from the issues that were present in the past few HA releases? Does it reappear every time you clean the logs and restart HA?

No, your question is not stupid at all, and I am really grateful that you asked it. Indeed this message popped up in the logs every time again after I cleared the logs and restarted HA. So I thought it cannot be a left-over. Funny enough, after I restarted HA more times (as I am fiddling with some value_templates and therefore need to restart HA), the message (at least for now) does not appear anymore.

Moving on to troubleshooting: the default timeout is currently 8s for each device, so it could be possible that with that many endpoints to query the global 10s limit could be exceeded if the they don't reply instantaneously. I'm not seeing that warning on my instance with polling of just a couple network appliances, could you try commenting out all but one of the devices in your config and see if the warning comes up anyway?

Yes, I will comment all but just a few definitions in my yaml file with the snmp sensors and see if the message pops up again, and I will report back here.

Again, thanks for your feedback and your explanations about the 8s threshold (which I was indeed not aware of). Again, I have learnt something here in this nice forum. ❤️

7wells commented 1 week ago

I can confirm that the warning "Setup of sensor platform snmp is taking over 10 seconds" in my case only pops up sporadically and only when I have set those many snmp parameters as shown in my initial post. When I reduced the number, the warning did not pop up. I cannot provide a threshold when it happens and when not, but I assume that this is what it says, just a warning and not a problem. Therefore, I hereby close my "issue".

Thanks for your patience and for taking your time for creating and maintaining this very helpful integration. 👍

nmaggioni commented 1 week ago

You're welcome. To sum this up for future reference, in this case the warning is benign and does what it's intended to do: if polling all the configured SNMP devices for the first time takes more than 10s to complete (due to network latency or whatever), it gets logged.