Difference between revisions of "Home Assistant - Network Monitoring"

From WTFwiki
Jump to navigation Jump to search
Line 50: Line 50:
  
 
== OpenVPN Session Monitor ==
 
== OpenVPN Session Monitor ==
 +
Assumes default Openvpn config directories:
 +
 
<pre>
 
<pre>
 
   - platform: command_line
 
   - platform: command_line

Revision as of 12:10, 13 March 2023

Handful of helpful configs I've managed to kludge together:

SNMP Interface Polling

configuration.yaml example (TL-ER6020 OIDs)

sensor:
  - platform: snmp
    name: wan_in
    host: 10.10.10.1
    baseoid: 1.3.6.1.2.1.31.1.1.1.6.2
    accept_errors: true
    community: 'public'
    version: '2c'
    scan_interval: 4
  - platform: snmp
    name: wan_out
    host: 10.10.10.1
    baseoid: 1.3.6.1.2.1.31.1.1.1.10.2
    accept_errors: true
    community: 'public'
    version: '2c'
    scan_interval: 4
  - platform: derivative
    name: wan_in_der
    source: sensor.wan_in
    unit_time: s
    unit: B
  - platform: derivative
    name: wan_out_der
    source: sensor.wan_out
    unit_time: s
    unit: B

Required template:

  - platform: template
    sensors:
      wan_in_mbps:
        value_template:  "{{ [((states('sensor.wan_in_der')|float*8)/1000000)|round(2),0]|max }}"
        unit_of_measurement: 'Mbps'
        friendly_name: "WAN In"
      wan_out_mbps:
        value_template:  "{{ [((states('sensor.wan_out_der')|float*8)/1000000)|round(2),0]|max }}"
        unit_of_measurement: 'Mbps'
        friendly_name: "WAN Out"


OpenVPN Session Monitor

Assumes default Openvpn config directories:

  - platform: command_line
    name: OpenVPN_Connections
    command: "grep -c 'CLIENT_LIST' /etc/openvpn/server/openvpn-status.log | awk '{print $0-1}'"
    scan_interval: 15

ICMP Testing

Likely well documented online and simple:

  - platform: ping
    host: 10.8.0.1
    name: OpenVPN_GW
    count: 2
    scan_interval: 15