Quantcast
Channel: Configuration - Home Assistant Community
Viewing all articles
Browse latest Browse all 105968

SNMP sensor Unifi Secure Gateway - WAN 1 / WAN 2 pppoe connected

$
0
0

Hi All,

I am running Unifi Secure Gateway with WAN1 main and WAN2 fallback,
where both of them are pppoe connections.
I am trying to setup two sensors (one for each interface) which shows me if the interface is up and running.
As SNMP is already in place I thought it is a simple thing - so based on some other discussions within the forum I found that OID 1.3.6.1.2.1.31.1.1.1.X.X contains information about the interfaces and I found that 1.3.6.1.2.1.31.1.1.1.18.X contains the string names of intefaces up.
So output looks like:

#> snmpwalk -v2c -c public 192.168.32.1 1.3.6.1.2.1.31.1.1.1.18
iso.3.6.1.2.1.31.1.1.1.18.1 = STRING: “lo”
iso.3.6.1.2.1.31.1.1.1.18.2 = STRING: “WAN”
iso.3.6.1.2.1.31.1.1.1.18.3 = STRING: “LAN”
iso.3.6.1.2.1.31.1.1.1.18.4 = STRING: “WAN2”
iso.3.6.1.2.1.31.1.1.1.18.5 = STRING: “imq0”
iso.3.6.1.2.1.31.1.1.1.18.6 = STRING: “eth1.2@eth1”
iso.3.6.1.2.1.31.1.1.1.18.7 = STRING: “eth1.4@eth1”
iso.3.6.1.2.1.31.1.1.1.18.8 = STRING: “eth1.3@eth1”
iso.3.6.1.2.1.31.1.1.1.18.11 = STRING: “pppoe0”
iso.3.6.1.2.1.31.1.1.1.18.12 = STRING: “pppoe1”

Based on this I created a sensor:

  - platform: snmp
    host: 192.168.32.1
    baseoid: 1.3.6.1.2.1.31.1.1.1.18.11
    community: public
    version: 2c
    name: 'Unifi 32-USG WAN1 pppoe state'
    accept_errors: true

As soon as WAN1 pppoe is online, it shows ‘pppoe0’.
That was fine until I tested and turned WAN1 off and on and hat to find that the OID increases with every connect/disconnect (X wihtin 1.3.6.1.2.1.31.1.1.1.18.X and .11 within my example).
Additionally depending on when which interface gets disconnected, the numbers might get mixed up.

#> snmpwalk -v2c -c public 192.168.32.1 1.3.6.1.2.1.31.1.1.1.18
iso.3.6.1.2.1.31.1.1.1.18.1 = STRING: “lo”
iso.3.6.1.2.1.31.1.1.1.18.2 = STRING: “WAN”
iso.3.6.1.2.1.31.1.1.1.18.3 = STRING: “LAN”
iso.3.6.1.2.1.31.1.1.1.18.4 = STRING: “WAN2”
iso.3.6.1.2.1.31.1.1.1.18.5 = STRING: “imq0”
iso.3.6.1.2.1.31.1.1.1.18.6 = STRING: “eth1.2@eth1”
iso.3.6.1.2.1.31.1.1.1.18.7 = STRING: “eth1.4@eth1”
iso.3.6.1.2.1.31.1.1.1.18.8 = STRING: “eth1.3@eth1”
iso.3.6.1.2.1.31.1.1.1.18.13 = STRING: “pppoe0”
iso.3.6.1.2.1.31.1.1.1.18.14 = STRING: “pppoe1”

So one idea was to get all interfaces and regex filter for ‘pppoe0’ to exist, but with the “value_template” this always returns False (independent of ‘pppoe0’ exsiting or not) and without “value_template” I the the error of: No Such Instance currently exists at this OID

  - platform: snmp
    host: 192.168.32.1
    baseoid: 1.3.6.1.2.1.31.1.1.1.18
    community: public
    version: 2c
    name: 'Unifi 32-USG WAN1 pppoe state'
    accept_errors: true
    value_template: >-
      {{ value is search('pppoe0', ignorecase=True) }}

My last idea is to use a command line sensor (just example version for test - binary etc. might be better and grep being more specific):

  - platform: command_line
    name: 'Unifi 32-USG WAN1 pppoe state'
    command: 'snmpwalk -v2c -c public 192.168.32.1 1.3.6.1.2.1.31.1.1.1.18 | grep "pppoe0"'
    device_class: connectivity

BUT this requires my to install snmp package into my docker container with supervised and I have made bad experiences with “getting lost” packages/binaries after a docker container update…so my question to you is:

Any better ideas or suggestions?
Thanks for any hint in advance

1 post - 1 participant

Read full topic


Viewing all articles
Browse latest Browse all 105968

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>