Custom Integration: SNMP_stats

Hi all,
this is my 2nd integration for Homeassistant :slight_smile:

It just reads data from SNMP-Service and creates some sensors from it.

I tested it with opnsense and openwrt.

Sensors currently include:
cpu avg 1/2/3
if total in/out
if current mbit/s in/out
if current mbytes in/out

Let me know, if you need more sensors.

Configuration is done via integrations ui.
easily installable via HACS, just add the url as a repository and done.

2 Likes

this is exactly what I’ve been looking for!

Could you explain which format the setup form is expecting? It doesn’t show me anything there except for a blank input field so I assumed it’s asking for the IP address of the router but then the configuration fails (perhaps it needs the user and password credentials as well?).

and is there any configuration required on the OpenWRT device itself?

edit: ok, I’ve installed mini_snmpd on OpenWRT and I can query it using snmpwalk from my computer but the integration still fails during setup.

2020-04-26 22:54:24 ERROR (MainThread) [custom_components.snmp_stats] Unable to connect to snmp: Traceback (most recent call last):
  File "/config/custom_components/snmp_stats/config_flow.py", line 36, in async_step_user
    SnmpStatisticsMonitor(ipaddress)
  File "/config/custom_components/snmp_stats/sensor.py", line 121, in __init__
    self.update_stats()#try this to throw error if not working.
  File "/config/custom_components/snmp_stats/sensor.py", line 194, in update_stats
    self.update_netif_stats()
  File "/config/custom_components/snmp_stats/sensor.py", line 232, in update_netif_stats
    '1.3.6.1.2.1.2.1.0' #v1, ifCount
  File "/config/custom_components/snmp_stats/sensor.py", line 161, in get_bulk_auto
    return __class__.get_bulk(target, oids, credentials, count, start_from, port, engine, context)
  File "/config/custom_components/snmp_stats/sensor.py", line 155, in get_bulk
    return __class__.fetch(handler, count)
  File "/config/custom_components/snmp_stats/sensor.py", line 187, in fetch
    raise RuntimeError('Got SNMP error: {0}'.format(error_indication))
RuntimeError: Got SNMP error: No SNMP response received before timeout

Hi disrupted,
you need to install the snmpd package :slight_smile:

It should show you a label for the ip-address:

image

just tried that, same result. Also doesn’t show me the label unfortunately. Do you have a certain config for snmpd?

edit: I removed some packages on my OpenWRT and reinstalled snmpd and now the configuration succeeded and I can see data coming which is great! Unfortunately the values are a bit hit & miss though, the history graph shows spikes with extremely big negative values. probably it’s related to 32bit limitation causing a rollover of big values. do you know if this can be fixed on the router?

Hi disrupted,
can you check with the latest version.

I made it use only the 64bit counters.

1 Like

I am happy to report this is working now. Thanks for the fix!

One of the most useful integrations I found so far, thank you so much for your work. :slight_smile:

I just installed it via HACS and I have all the sensors ready and working. Just one question: I see the code extracts only 3 cpu load averages, and I have an opnsense running on a dedicated server with a 4 core CPU. Would it be possible to discover ALL the cpu OIDs and prepare sensors for each?

Thanks again. :slight_smile:

Hello!
Do you still maintain this integration? I tried adding it as a custom repostitory in HACS but do not see any way to configure it with the IP address of my router.

After adding it via HACS, you can add it via Settings/Integrations/Add Integration and it should ask you for an IP-Address


image

Thank you for the plugin.
What do you think about add entity like: uptime, free ram memory, free disk space?

Thanks

Hello!
i installed it with HACS but integration didn’t show up when i add an integration. Any idea?

I am having the same issue here. Has this been resolved somehow?

It’s working for me now, i don’t remember what was the problem… :frowning: