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

SNMP broken after upgrade to 0.78 #16679

Closed
Dinth opened this issue Sep 18, 2018 · 9 comments · Fixed by #16716
Closed

SNMP broken after upgrade to 0.78 #16679

Dinth opened this issue Sep 18, 2018 · 9 comments · Fixed by #16716

Comments

@Dinth
Copy link

Dinth commented Sep 18, 2018

Home Assistant release with the issue: 0.78

Last working Home Assistant release (if known):

0.77.3

Operating environment (Hass.io/Docker/Windows/etc.):

Intel NUC docker image running on Ubuntu

Component/platform:

SNMP sensor

Description of problem:

After upgrading to 0.78 HA stopped working. Using trial and error method (removing yaml files one by one) i found out that the problem is caused by my SNMP config. There shouldnt be any breaking changes regarding SNMP in 0.78.

Problem-relevant configuration.yaml entries and (fill out even if it seems unimportant):

  - platform: snmp
    host: 10.10.0.20
    baseoid: 1.3.6.1.4.1.11.2.14.11.5.1.9.6.1.0
    name: "Procurve 3500yl CPU usage"
    icon: mdi:chip
    unit_of_measurement: '%'
    community: "x"

  - platform: snmp
    host: 10.10.0.20
    baseoid: 1.3.6.1.4.1.11.2.14.11.5.1.1.2.1.1.1.6.1 
    icon: mdi:memory
    name: "Procurve 3500yl memory usage"
    unit_of_measurement: 'B'
    community: "x"
    
  - platform: snmp
    host: 10.10.0.20
    baseoid: 1.3.6.1.4.1.11.2.14.11.1.2.6.1.4.1
    name: "Procurve 3500yl fan status"
    community: "x"    
    #1	Invalid Value 2	Bad 3	Warning 4	Good 5	Not Present
    
  - platform: snmp
    host: 10.10.0.20
    baseoid: 1.3.6.1.4.1.11.2.14.11.1.2.6.1.4.2
    name: "Procurve 3500yl Primary PSU status"
    community: "x"    
    #1	Invalid Value 2	Bad 3	Warning 4	Good 5	Not Present
    
  - platform: snmp
    host: 10.10.0.20
    baseoid: 1.3.6.1.4.1.11.2.14.11.1.2.6.1.4.3
    name: "Procurve 3500yl Secondary PSU status"
    community: "x"
    #1	Invalid Value 2	Bad 3	Warning 4	Good 5	Not Present
    
  - platform: snmp
    host: 10.10.0.20
    baseoid: 1.3.6.1.4.1.11.2.14.11.1.2.6.1.4.4
    name: "Procurve 3500yl current temperature state"
    community: "x"
    #1	Invalid Value 2	Bad 3	Warning 4	Good 5	Not Present
    
  - platform: snmp
    host: 10.10.0.20
    baseoid: 1.3.6.1.4.1.11.2.14.11.1.2.8.1.1.3.0
    community: "x"
    value_template: "{{ value.replace('C','') | int }}"
    unit_of_measurement: "°C"
    name: "Procurve 3500yl current temperature"
    
  - platform: snmp
    host: 10.10.0.20
    baseoid: 1.3.6.1.4.1.11.2.14.11.1.2.8.1.1.4.0
    community: "x"    
    value_template: "{{ value.replace('C','') | int }}"
    unit_of_measurement: "°C"
    name: "Procurve 3500yl maximum temperature"
    
  - platform: snmp
    host: 10.10.0.20
    baseoid: 1.3.6.1.4.1.11.2.14.11.1.2.8.1.1.5.0
    value_template: "{{ value.replace('C','') | int }}"
    unit_of_measurement: "°C"
    community: "x"
    name: "Procurve 3500yl minimum temperature"
    
  - platform: snmp
    host: 10.10.0.20
    baseoid: 1.3.6.1.4.1.11.2.14.11.1.2.8.1.1.6.0
    name: "Procurve 3500yl over-temperature state"
    community: "x"
    # 1 - on; 2 - off;

  - platform: snmp
    host: 10.10.0.20
    baseoid: 1.3.6.1.4.1.11.2.14.11.1.2.8.1.1.7.0
    name: "Procurve 3500yl temperature threshold"
    value_template: "{{ value.replace('C','') | int }}"
    unit_of_measurement: "°C"
    community: "x"
    


  - platform: snmp
    host: 10.10.1.1
    baseoid: 1.3.6.1.2.1.25.3.3.1.2.1
    name: "PowerEdge R210II ESXi CPU 1"
    unit_of_measurement: '%'    
    community: "x"
  - platform: snmp
    host: 10.10.1.1
    baseoid: 1.3.6.1.2.1.25.3.3.1.2.2
    name: "PowerEdge R210II ESXi CPU 2"
    unit_of_measurement: '%'
    community: "x"
  - platform: snmp
    host: 10.10.1.1
    baseoid: 1.3.6.1.2.1.25.3.3.1.2.3
    name: "PowerEdge R210II ESXi CPU 3"
    unit_of_measurement: '%'
    community: "x"
  - platform: snmp
    host: 10.10.1.1
    baseoid: 1.3.6.1.2.1.25.3.3.1.2.4
    name: "PowerEdge R210II ESXi CPU 4"
    unit_of_measurement: '%'
    community: "x"
  - platform: snmp
    host: 10.10.1.1
    baseoid: 1.3.6.1.2.1.25.2.3.1.6.3
    name: "PowerEdge R210II ESXi Real memory usage"
    unit_of_measurement: 'B'
    community: "x"
    

Traceback (if applicable):
Only the last few lines of log are relevant to SNMP

2018-09-18 02:29:25 INFO (MainThread) [homeassistant.core] Bus:Handling <Event service_registered[L]: domain=tts, service=clear_cache>
2018-09-18 02:29:25 INFO (MainThread) [homeassistant.setup] Setup of domain tts took 0.3 seconds.
2018-09-18 02:29:25 INFO (MainThread) [homeassistant.core] Bus:Handling <Event component_loaded[L]: component=tts>
2018-09-18 02:29:25 INFO (MainThread) [homeassistant.core] Bus:Handling <Event state_changed[L]: entity_id=sensor.procurve_3500yl_cpu_usage, old_state=None, new_state=<state sensor.procurve_3500yl_cpu_usage=2; unit_of_measurement=%, friendly_name=Procurve 3500yl CPU usage @ 2018-09-18T02:29:25.119553+01:00>>
2018-09-18 02:29:25 INFO (MainThread) [homeassistant.core] Bus:Handling <Event state_changed[L]: entity_id=sensor.procurve_3500yl_memory_usage, old_state=None, new_state=<state sensor.procurve_3500yl_memory_usage=83348032; unit_of_measurement=B, friendly_name=Procurve 3500yl memory usage @ 2018-09-18T02:29:25.120627+01:00>>
2018-09-18 02:29:25 INFO (MainThread) [homeassistant.core] Bus:Handling <Event state_changed[L]: entity_id=sensor.procurve_3500yl_fan_status, old_state=None, new_state=<state sensor.procurve_3500yl_fan_status=4; friendly_name=Procurve 3500yl fan status @ 2018-09-18T02:29:25.121406+01:00>>
2018-09-18 02:29:25 INFO (MainThread) [homeassistant.core] Bus:Handling <Event state_changed[L]: entity_id=sensor.procurve_3500yl_primary_psu_status, old_state=None, new_state=<state sensor.procurve_3500yl_primary_psu_status=4; friendly_name=Procurve 3500yl Primary PSU status @ 2018-09-18T02:29:25.121867+01:00>>
2018-09-18 02:29:25 DEBUG (SyncWorker_14) [homeassistant.helpers.restore_state] Last run: 2018-09-18 01:27:25 - 2018-09-18 01:29:19+00:00
2018-09-18 02:29:25 INFO (MainThread) [homeassistant.core] Bus:Handling <Event state_changed[L]: entity_id=sensor.procurve_3500yl_secondary_psu_status, old_state=None, new_state=<state sensor.procurve_3500yl_secondary_psu_status=4; friendly_name=Procurve 3500yl Secondary PSU status @ 2018-09-18T02:29:25.122866+01:00>>
2018-09-18 02:29:25 INFO (MainThread) [homeassistant.core] Bus:Handling <Event state_changed[L]: entity_id=sensor.procurve_3500yl_current_temperature_state, old_state=None, new_state=<state sensor.procurve_3500yl_current_temperature_state=4; friendly_name=Procurve 3500yl current temperature state @ 2018-09-18T02:29:25.128047+01:00>>
2018-09-18 02:29:25 DEBUG (SyncWorker_14) [homeassistant.components.recorder.util] converting 0 rows to native objects took 0.003785s
2018-09-18 02:29:25 DEBUG (SyncWorker_14) [homeassistant.helpers.restore_state] Created cache with []

The log ends here.

Additional information:

@awarecan
Copy link
Contributor

There is a major changes in SNMP, see #14753

Please fill in your configuration and error log in bug report.

@Dinth
Copy link
Author

Dinth commented Sep 18, 2018

Actually i managed to narrow the problematic config down. This bit causes the problem:

  - platform: snmp
    host: 10.10.0.20
    baseoid: 1.3.6.1.4.1.11.2.14.11.1.2.6.1.4.4
    name: "Procurve 3500yl current temperature state"
    community: "x"
    #1	Invalid Value 2	Bad 3	Warning 4	Good 5	Not Present
    
  - platform: snmp
    host: 10.10.0.20
    baseoid: 1.3.6.1.4.1.11.2.14.11.1.2.8.1.1.3.0
    community: "x"
    value_template: "{{ value.replace('C','') | int }}"
    unit_of_measurement: "°C"
    name: "Procurve 3500yl current temperature"
    
  - platform: snmp
    host: 10.10.0.20
    baseoid: 1.3.6.1.4.1.11.2.14.11.1.2.8.1.1.4.0
    community: "x"    
    value_template: "{{ value.replace('C','') | int }}"
    unit_of_measurement: "°C"
    name: "Procurve 3500yl maximum temperature"
    
  - platform: snmp
    host: 10.10.0.20
    baseoid: 1.3.6.1.4.1.11.2.14.11.1.2.8.1.1.5.0
    value_template: "{{ value.replace('C','') | int }}"
    unit_of_measurement: "°C"
    community: "x"
    name: "Procurve 3500yl minimum temperature"
    
  - platform: snmp
    host: 10.10.0.20
    baseoid: 1.3.6.1.4.1.11.2.14.11.1.2.8.1.1.6.0
    name: "Procurve 3500yl over-temperature state"
    community: "x"
    # 1 - on; 2 - off;

  - platform: snmp
    host: 10.10.0.20
    baseoid: 1.3.6.1.4.1.11.2.14.11.1.2.8.1.1.7.0
    name: "Procurve 3500yl temperature threshold"
    value_template: "{{ value.replace('C','') | int }}"
    unit_of_measurement: "°C"
    community: "x"

And i believe that 'value_template:' option here may be preventing HA from starting up.

@awarecan
Copy link
Contributor

Can you edit your local homeassistant/components/sensor/snmp.py file

https://github.com/home-assistant/home-assistant/blob/27d50d388fe61e38f5623d0e63c4bdc28764ebe2/homeassistant/components/sensor/snmp.py#L185-L186

change render_with_possible_json_value to async_render_with_possible_json_value

            value = self._value_template.async_render_with_possible_json_value(
                value, STATE_UNKNOWN)

@Dinth
Copy link
Author

Dinth commented Sep 18, 2018

change render_with_possible_json_value to async_render_with_possible_json_value

Seems that this has fixed the problem - HA is booting correctly now.

Thank you!

@awarecan
Copy link
Contributor

cc @mtdcr

@daveyrb
Copy link

daveyrb commented Sep 18, 2018

I can confirm that this seems to have fixed the problem for me: Once I worked out how to edit a file inside a Docker container.

@Dinth
Copy link
Author

Dinth commented Sep 18, 2018

I can confirm that this seems to have fixed the problem for me: Once I worked out how to edit a file inside a Docker container.

vi never fails :)

@mtdcr
Copy link
Contributor

mtdcr commented Sep 19, 2018

@awarecan, thank you for locating the problem! Would you mind creating the PR?

@awarecan
Copy link
Contributor

I don't have environment to test

@ghost ghost added the in progress label Sep 19, 2018
@ghost ghost removed the in progress label Sep 19, 2018
balloob pushed a commit that referenced this issue Sep 19, 2018
balloob pushed a commit that referenced this issue Sep 20, 2018
@balloob balloob mentioned this issue Sep 20, 2018
@home-assistant home-assistant locked and limited conversation to collaborators Feb 5, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants