User Tools

Site Tools


packet:linbpq_monitoring

Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Next revision
Previous revision
packet:linbpq_monitoring [2024/05/06 16:05] – created g6fjipacket:linbpq_monitoring [2024/05/15 10:05] (current) – [Prometheus] remove note about sysUpTime 2m0mqn
Line 1: Line 1:
-====== Monitoring LinBPQ through Home Assistant ======+====== Monitoring LinBPQ through SNMP ======
  
-===== 1. Enable SNMP on LinBPQ =====+===== Enable SNMP on LinBPQ =====
  
 N.B. This approach requires a recent version of LinBPQ, 6.0.24.34 or later.  Older releases supported SNMP through the IPGATEWAY feature - see [[packet:snmp_graphs|]] N.B. This approach requires a recent version of LinBPQ, 6.0.24.34 or later.  Older releases supported SNMP through the IPGATEWAY feature - see [[packet:snmp_graphs|]]
Line 31: Line 31:
 </code> </code>
  
-===== 2. Set up SNMP on Home Assistant =====+===== Set up monitoring in Home Assistant ===== 
 + 
 +One way to monitor BPQ's SNMP metrics is using Home Assistant.
  
 SNMP support is built-in to HA but requires hand-editing ''configuration.yaml''. If you are not comfortable doing that, stop now! SNMP support is built-in to HA but requires hand-editing ''configuration.yaml''. If you are not comfortable doing that, stop now!
Line 125: Line 127:
  
  
 +===== Telegraf / Grafana =====
 +
 +Another way to collect and monitor BPQ's SNMP metrics is by using Telegraf. You typically run Telegraf as part of a monitoring stack, in this case Telegraf + InfluxDB + Grafana. Telegraf is the collection agent, InfluxDB is the time-series database, and Grafana is the visualisation.
 +
 +In telegraf.conf:
 +
 +<code>
 +[[inputs.snmp]]
 +  agents = ["udp4://localhost:161"]
 +  version = 1
 +
 +# for each port...
 +  
 +[[inputs.snmp.field]]
 +  oid = "1.3.6.1.2.1.2.2.1.10.1"
 +  name = "port_1_octets_in"
 +  conversion = "int"
 +
 +[[inputs.snmp.field]]
 +  oid = "1.3.6.1.2.1.2.2.1.16.1"
 +  name = "port_1_octets_out"
 +  conversion = "int"
 +
 +</code>
 +
 +These counters show up in InfluxDB under a measurement named SNMP with multiple fields, one for each oid. You get a counter update every 10 seconds.
 +
 +Query like this:
 +
 +{{:packet:linbpq-snmp-influxdb.png?800|}}
 +
 +End result:
 +
 +{{:packet:linbpq-snmp-grafana.png?800|}}
 +
 +===== Prometheus =====
 +
 +It's also quite easy to get prometheus-snmp-exporter to collect stats from BPQ.
 +
 +Add something like the following to your generator.yml
 +
 +<code>
 +  linbpq:
 +    walk:
 +      - 1.3.6.1.2.1.1.3.0
 +      - 1.3.6.1.2.1.1.5
 +      - 1.3.6.1.2.1.2.2.1.10.1
 +      - 1.3.6.1.2.1.2.2.1.16.1
 +    version: 1
 +    auth:
 +      community: public
 +</code>
 +
 +Repeat the 1.3.6.1.2.1.2.2.1.10.X and 1.3.6.1.2.1.2.2.1.16.X lines for each of your ports, then run prometheus-snmp-generator generate to regenerate your configuration.
 +
 +You'll likely already have an snmp scrape configuration in your prometheus.yml.
 +Add the linbpq module (as defined above) and the target address of your BPQ node to it.
 +The result will look something like this:
 +
 +<code>
 +  - job_name: 'snmp'
 +    scrape_interval: 20s
 +    scrape_timeout: 5s
 +    metrics_path: /snmp
 +    params:
 +      module: [linbpq]
 +    static_configs:
 +      - targets:
 +        - packet.example.org:8161  # SNMP device - add your IPs here
 +    relabel_configs:
 +      - source_labels: [__address__]
 +        target_label: __param_target
 +      - source_labels: [__param_target]
 +        target_label: instance
 +      - target_label: __address__
 +        replacement: 127.0.0.1:9116  # SNMP exporter.
 +</code>
 +
 +After restarting prometheus-snmp-exporter and prometheus you should start seeing ifInOctets, ifOutOctets, sysName, and sysUpTime metrics appearing.
  
packet/linbpq_monitoring.1715011505.txt.gz · Last modified: 2024/05/06 16:05 by g6fji