SNMP bandwidth monitor using statistics

I had a deep dive into the NPM server, and it looks like someone didn’t enable the 64 bit counters.

[facepalm]

So, everything I said about exhausting 64 bit counters? Ignore it.

Worked like a charm for me, but after installing the HA core update from october stopped working. Anyone else having issues?

Nope. Still working for me.

Thanks,
I’ll digg in to it later then, maybe delete sensors and restart HA and configure them again will do the trick

For anybody with Float = None errors etc… (p.s. not an expert just FYI)

Worked today (Core 10.3) on it, graphing IN/OUT Mbps of a Unifi USG router:
Confirmed working:

configuration.yaml

sensor:
  - platform: snmp
    name: 'USG WAN in'
    host: <IP router>
    baseoid: 1.3.6.1.2.1.31.1.1.1.6.2
    community: 'public'
    version: '2c'
    scan_interval: 10
  - platform: snmp
    name: 'USG WAN out'
    host: <IP router>
    baseoid: 1.3.6.1.2.1.31.1.1.1.10.2
    community: 'public'
    version: '2c'
    scan_interval: 10
    #-----
  - platform: derivative
    name: wan_in_der
    source: sensor.usg_wan_in
    unit_time: s
    unit: B
  - platform: derivative
    name: wan_out_der
    source: sensor.usg_wan_out
    unit_time: s
    unit: B
  - platform: template
    sensors:
      wan_in_mbps:
        value_template:  "{{ [((states('sensor.wan_in_der')|float(0)*8)/1000000)|round(2),0]|max }}"
        unit_of_measurement: 'Mbps'
        friendly_name: "WAN In der"
      wan_out_mbps:
        value_template:  "{{ [((states('sensor.wan_out_der')|float(0)*8)/1000000)|round(2),0]|max }}"
        unit_of_measurement: 'Mbps'
        friendly_name: "WAN Out der"

Well that will return 0 when sensor.wan_in_der is unknown, like the last version of Home Assistant did.

A better option would be

value_template:  "{{ [((states('sensor.wan_in_der')|float(none)*8)/1000000)|round(2, default=none),0]|max }}"

So you know when there is an issue with your sensor.

See here for more:

1 Like

Thanks @tom_l

After reading the template info page I am testing your suggestion (in configuration.yaml):

sensor:
    - platform: snmp
      name: 'USG WAN in'
      host: <IProuter IP>
      baseoid: 1.3.6.1.2.1.31.1.1.1.6.2
      community: 'public'
      version: '2c'
      scan_interval: 10
    - platform: snmp
      name: 'USG WAN out'
      host: <IProuter IP>
      baseoid: 1.3.6.1.2.1.31.1.1.1.10.2
      community: 'public'
      version: '2c'
      scan_interval: 10
    - platform: derivative
      name: wan_in_der
      source: sensor.usg_wan_in
      unit_time: s
      unit: B
    - platform: derivative
      name: wan_out_der
      source: sensor.usg_wan_out
      unit_time: s
      unit: B
   - platform: template
     sensors:
        wan_in_mbps:
             value_template:  "{{ [((states('sensor.wan_in_der')|float(none)*8)/1000000)|round(2, default=none),0]|max }}"
            unit_of_measurement: 'Mbps'
            friendly_name: "WAN In der Alex"
       wan_out_mbps:
            value_template:  "{{ [((states('sensor.wan_out_der')|float(none)*8)/1000000)|round(2, default=none),0]|max }}"
           unit_of_measurement: 'Mbps'
           friendly_name: "WAN Out der Alex"
1 Like

does anyone know how to find OID of my UDM/UDR. The OIDs posted above do not work for me.

The UDM does not support SNMP. This has made a lot of people very mad.

I don’t know about the UDR.

1 Like

What does this SnMP do?

https://community.ui.com/questions/SNMP-on-UDM-UDM-PRO/a2887f2a-c3dc-43ed-81a0-7fe0e63537ce#answer/1097781e-93ec-45c5-ae5f-b502389013fd

1 Like

What a disappointment!

I’m confused, is SNMP supported on the UDM Pro or not? There seems to be a setting for it, it doesn’t work?

Did you read the posts in the topic linked to?

that will provide snmp for any device the UDM/UDMP manages, such as access points and switches.

Apparently you can install SNMP now.

I think that is outdated as it seems Unifi has added SNMP to the Pro recently. Built in.

SNMP on UDM/UDM-PRO | Ubiquiti Community

And I have enabled it in my setting, but I still can’t connect. Maybe I have the wrong baseoid.

- platform: snmp
  name: "USG WAN in"
  host: 192.168.88.1
  baseoid: 1.3.6.1.2.1.31.1.1.1.6.2
  community: "public"
  version: "2c"
  scan_interval: 10

- platform: snmp
  name: "USG WAN out"
  host: 192.168.88.1
  baseoid: 1.3.6.1.2.1.31.1.1.1.10.2
  community: "public"
  version: "2c"
  scan_interval: 10

Nope. There is nothing in that topic that indicates SNMP is now shipped by default. The original poster made the same mistake as in my link. That setting is only for monitoring other devices connected to the UDM.

However as I said, you can add it now.

1 Like

I see, too bad Unifi does make that clear in their wording. We don’t all have the high level of expertise you have. I’m not sure I want to install third-party apps on my UDM, already unstable enough as it is.

This is only to enable snmp for connected unifi devices to the UDM, to run SNMP on the UDM itself you need to ssh into the udm and install it and run as service.

Here is a good tutorial for it:

2 Likes

I have SNMP running on my UDM Pro, but struggling to find the right OIDs to use for wan in/out

root@ubnt:/# snmpbulkwalk -v 2c -c home 192.168.0.1 1.3.6.1.2.1.31.1.1.1.1
iso.3.6.1.2.1.31.1.1.1.1.1 = STRING: "lo"
iso.3.6.1.2.1.31.1.1.1.1.2 = STRING: "dummy0"
iso.3.6.1.2.1.31.1.1.1.1.3 = STRING: "eth9"
iso.3.6.1.2.1.31.1.1.1.1.4 = STRING: "eth8"
iso.3.6.1.2.1.31.1.1.1.1.5 = STRING: "eth10"
iso.3.6.1.2.1.31.1.1.1.1.6 = STRING: "switch0"
iso.3.6.1.2.1.31.1.1.1.1.7 = STRING: "gre0"
iso.3.6.1.2.1.31.1.1.1.1.8 = STRING: "gretap0"
iso.3.6.1.2.1.31.1.1.1.1.9 = STRING: "erspan0"
iso.3.6.1.2.1.31.1.1.1.1.10 = STRING: "ip_vti0"
iso.3.6.1.2.1.31.1.1.1.1.11 = STRING: "sit0"
iso.3.6.1.2.1.31.1.1.1.1.12 = STRING: "br0"
iso.3.6.1.2.1.31.1.1.1.1.13 = STRING: "eth0"
iso.3.6.1.2.1.31.1.1.1.1.14 = STRING: "eth1"
iso.3.6.1.2.1.31.1.1.1.1.15 = STRING: "eth2"
iso.3.6.1.2.1.31.1.1.1.1.16 = STRING: "eth3"
iso.3.6.1.2.1.31.1.1.1.1.17 = STRING: "eth4"
iso.3.6.1.2.1.31.1.1.1.1.18 = STRING: "eth5"
iso.3.6.1.2.1.31.1.1.1.1.19 = STRING: "eth6"
iso.3.6.1.2.1.31.1.1.1.1.20 = STRING: "eth7"
iso.3.6.1.2.1.31.1.1.1.1.21 = STRING: "ifb0"
iso.3.6.1.2.1.31.1.1.1.1.22 = STRING: "ifb1"
iso.3.6.1.2.1.31.1.1.1.1.23 = STRING: "switch0.1"
iso.3.6.1.2.1.31.1.1.1.1.24 = STRING: "honeypot0"
iso.3.6.1.2.1.31.1.1.1.1.25 = STRING: "cni0"

eth 9 is my wan interface. any clues? :slight_smile: