Telgraf: make IPs configureable (fixes #7)

This commit is contained in:
Jannik Beyerstedt 2020-04-18 15:25:41 +02:00
parent 87b23b5b8a
commit c33c1850b0
4 changed files with 72 additions and 38 deletions

View file

@ -60,9 +60,10 @@ Mandatory variables:
Telegraf is configured with basic host telemetry by default. You can add more features, if you like: Telegraf is configured with basic host telemetry by default. You can add more features, if you like:
- `telegraf_docker`: Set to `true`, if docker telemetry should be collected (uses file from `telegraf_docker_file`) - `telegraf_docker`: Set to `true`, if docker telemetry should be collected (uses file from `telegraf_docker_file`)
- `telegraf_snmp`: Set to `true`, if SNMP telemetry should be collected (uses file from `telegraf_snmp_file`) - `telegraf_unifi_usg_ips`: Specify a list of USG IPs, if SNMP telemetry should be collected (uses file from `telegraf_unifi_file`)
- `telegraf_unifi_ap_ips`: Specify a list of AP IPs, if SNMP telemetry should be collected (uses file from `telegraf_unifi_file`)
- `telegraf_docker_file`: filename of the docker telegraf config part in `{{role_path}}/templates` (default `telegraf-docker.conf`). - `telegraf_docker_file`: filename of the docker telegraf config part in `{{role_path}}/templates` (default `telegraf-docker.conf`).
- `telegraf_snmp_file`: filename of the SNMP telegraf config part in `{{role_path}}/templates` (default `telegraf-SNMP.conf`). - `telegraf_unifi_file`: filename of the SNMP telegraf config part in `{{role_path}}/templates` (default `telegraf-UniFi.conf`).
Optional settings: Optional settings:
- `telegraf_interval`: Data sampling interval (default `300s`) - `telegraf_interval`: Data sampling interval (default `300s`)

View file

@ -7,6 +7,6 @@ caddy_cachedir: "{{ ansible_user_dir }}/.ansbl-caddy-cache"
telegraf_interval: "300s" telegraf_interval: "300s"
telegraf_docker_file: "telegraf-docker.conf" telegraf_docker_file: "telegraf-docker.conf"
telegraf_snmp_file: "telegraf-SNMP.conf" telegraf_unifi_file: "telegraf-UniFi.conf.j2"
dockercompose_use_pip: false dockercompose_use_pip: false

View file

@ -1,8 +1,14 @@
{# Telegraf config snippet for UniFi devices #}
{# Variables: #}
{# - telegraf_unifi_usg_ips: List of IPs of EdgeRouter/ USG #}
{# - telegraf_unifi_ap_ips: List of IPs of Access Points #}
{% if telegraf_unifi_ap_ips is defined %}
## ##
## SNMP Input For Unifi APs (Gen 2/Gen 3) ## SNMP Input For Unifi APs (Gen 2/Gen 3)
## ##
[[inputs.snmp]] [[inputs.snmp]]
agents = [ "192.168.4.21", "192.168.4.22", "192.168.4.23" ] agents = [ "{{ telegraf_unifi_ap_ips | join('", "') }}" ]
interval = "5m" interval = "5m"
timeout = "10s" timeout = "10s"
retries = 3 retries = 3
@ -28,35 +34,27 @@
[[inputs.snmp.field]] [[inputs.snmp.field]]
name = "sysDescr" name = "sysDescr"
oid = "RFC1213-MIB::sysDescr.0" oid = "RFC1213-MIB::sysDescr.0"
# System contact
[[inputs.snmp.field]]
name = "sysContact"
oid = "RFC1213-MIB::sysContact.0"
# System location
[[inputs.snmp.field]]
name = "sysLocation"
oid = "RFC1213-MIB::sysLocation.0"
# UAP model # UAP model
[[inputs.snmp.field]] [[inputs.snmp.field]]
name = "unifiApSystemModel" name = "unifiApSystemModel"
oid = "UBNT-UniFi-MIB::unifiApSystemModel" oid = "UBNT-UniFi-MIB::unifiApSystemModel.0"
# UAP firmware version
[[inputs.snmp.field]]
name = "unifiApSystemVersion"
oid = "UBNT-UniFi-MIB::unifiApSystemVersion.0"
# System uptime # System uptime
[[inputs.snmp.field]] [[inputs.snmp.field]]
name = "sysUpTime" name = "sysUpTime"
oid = "RFC1213-MIB::sysUpTime.0" oid = "RFC1213-MIB::sysUpTime.0"
##
## Host Resources
##
# Total memory
#[[inputs.snmp.field]]
# name = "memTotal"
# oid = "FROGFOOT-RESOURCES-MIB::memTotal.0"
# Free memory
#[[inputs.snmp.field]]
# name = "memFree"
# oid = "FROGFOOT-RESOURCES-MIB::memFree.0"
# Buffer memory
#[[inputs.snmp.field]]
# name = "memBuffer"
# oid = "FROGFOOT-RESOURCES-MIB::memBuffer.0"
# Cache memory
#[[inputs.snmp.field]]
# name = "memCache"
# oid = "FROGFOOT-RESOURCES-MIB::memCache.0"
## ##
## Interface Details & Metrics ## Interface Details & Metrics
## ##
@ -86,21 +84,58 @@
oid = "UBNT-UniFi-MIB::unifiIfName" oid = "UBNT-UniFi-MIB::unifiIfName"
## ##
## System Performance ## Host performance metrics
## ##
# System load averages # System Load Average
#[[inputs.snmp.table]] [[inputs.snmp.table]]
# oid = "FROGFOOT-RESOURCES-MIB::loadTable" oid = "UCD-SNMP-MIB::laTable"
# [[inputs.snmp.table.field]] [[inputs.snmp.table.field]]
# is_tag = true oid = "UCD-SNMP-MIB::laNames"
# oid = "FROGFOOT-RESOURCES-MIB::loadDescr" is_tag = true
##
## System Memory (physical/virtual)
## TODO: just reads 0
# Size of swap sapce configured
[[inputs.snmp.field]]
name = "memTotalSwap"
oid = "UCD-SNMP-MIB::memTotalSwap.0"
# Size of swap sapce unused/avail
[[inputs.snmp.field]]
name = "memAvailSwap"
oid = "UCD-SNMP-MIB::memAvailSwap.0"
# Size of real/phys mem installed
[[inputs.snmp.field]]
name = "memTotalReal"
oid = "UCD-SNMP-MIB::memTotalReal.0"
# Size of real/phys mem unused/avail
[[inputs.snmp.field]]
name = "memAvailReal"
oid = "UCD-SNMP-MIB::memAvailReal.0"
# Total amount of mem unused/avail
[[inputs.snmp.field]]
name = "memTotalFree"
oid = "UCD-SNMP-MIB::memTotalFree.0"
# Size of mem used as shared memory
[[inputs.snmp.field]]
name = "memShared"
oid = "UCD-SNMP-MIB::memShared.0"
# Size of mem used for buffers
[[inputs.snmp.field]]
name = "memBuffer"
oid = "UCD-SNMP-MIB::memBuffer.0"
# Size of mem used for cache
[[inputs.snmp.field]]
name = "memCached"
oid = "UCD-SNMP-MIB::memCached.0"
{% endif %}
{% if telegraf_unifi_usg_ips is defined %}
## ##
## SNMP Input For EdgeRouter/ Unifi USG ## SNMP Input For EdgeRouter/ Unifi USG
## ##
[[inputs.snmp]] [[inputs.snmp]]
agents = [ "192.168.2.1" ] agents = [ "{{ telegraf_unifi_usg_ips | join('", "') }}" ]
interval = "5m" interval = "5m"
timeout = "5s" timeout = "5s"
retries = 3 retries = 3
@ -348,3 +383,4 @@
[[inputs.snmp.field]] [[inputs.snmp.field]]
name = "ipRoutingDiscards" name = "ipRoutingDiscards"
oid = "RFC1213-MIB::ipRoutingDiscards.0" oid = "RFC1213-MIB::ipRoutingDiscards.0"
{% endif %}

View file

@ -32,7 +32,7 @@
# Read metrics about disk usage by mount point # Read metrics about disk usage by mount point
[[inputs.disk]] [[inputs.disk]]
# By default, telegraf gather stats for all mountpoints. # By default, telegraf gather stats for all mountpoints.
mount_points = ["/"] mount_points = ["/", "/mnt/volume-nbg1-1"]
ignore_fs = ["tmpfs", "devtmpfs", "devfs", "overlay", "aufs", "squashfs"] ignore_fs = ["tmpfs", "devtmpfs", "devfs", "overlay", "aufs", "squashfs"]
fieldpass = ["total", "free", "used_percent"] fieldpass = ["total", "free", "used_percent"]
@ -64,10 +64,7 @@
{% include telegraf_docker_file %} {% include telegraf_docker_file %}
{% endif %} {% endif %}
{% include telegraf_unifi_file %}
{% if telegraf_snmp|default(false)|bool %}
{% include telegraf_snmp_file %}
{% endif %}
# # Monitor sensors, requires lm-sensors package # # Monitor sensors, requires lm-sensors package