Difference between revisions of "Home Assistant - Network Monitoring"

From WTFwiki
Jump to navigation Jump to search
Line 54: Line 54:
 
     name: OpenVPN_Connections
 
     name: OpenVPN_Connections
 
     command: "grep -c 'CLIENT_LIST' /etc/openvpn/server/openvpn-status.log | awk '{print $0-1}'"
 
     command: "grep -c 'CLIENT_LIST' /etc/openvpn/server/openvpn-status.log | awk '{print $0-1}'"
 +
    scan_interval: 15
 +
</pre>
 +
 +
== ICMP Testing ==
 +
Likely well documented online and simple:
 +
 +
<pre>
 +
  - platform: ping
 +
    host: 10.8.0.1
 +
    name: OpenVPN_GW
 +
    count: 2
 
     scan_interval: 15
 
     scan_interval: 15
 
</pre>
 
</pre>

Revision as of 11: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

  - 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