diff --git a/README.md b/README.md index fac57af..3e4a65f 100644 --- a/README.md +++ b/README.md @@ -60,9 +60,10 @@ Mandatory variables: 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_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_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: - `telegraf_interval`: Data sampling interval (default `300s`) diff --git a/defaults/main.yml b/defaults/main.yml index 946bf47..80b516f 100644 --- a/defaults/main.yml +++ b/defaults/main.yml @@ -7,6 +7,6 @@ caddy_cachedir: "{{ ansible_user_dir }}/.ansbl-caddy-cache" telegraf_interval: "300s" telegraf_docker_file: "telegraf-docker.conf" -telegraf_snmp_file: "telegraf-SNMP.conf" +telegraf_unifi_file: "telegraf-UniFi.conf.j2" dockercompose_use_pip: false diff --git a/templates/telegraf-SNMP_fra80.conf b/templates/telegraf-UniFi.conf.j2 similarity index 79% rename from templates/telegraf-SNMP_fra80.conf rename to templates/telegraf-UniFi.conf.j2 index c3192e1..ed853ae 100644 --- a/templates/telegraf-SNMP_fra80.conf +++ b/templates/telegraf-UniFi.conf.j2 @@ -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) ## [[inputs.snmp]] - agents = [ "192.168.4.21", "192.168.4.22", "192.168.4.23" ] + agents = [ "{{ telegraf_unifi_ap_ips | join('", "') }}" ] interval = "5m" timeout = "10s" retries = 3 @@ -28,35 +34,27 @@ [[inputs.snmp.field]] name = "sysDescr" 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 [[inputs.snmp.field]] 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 [[inputs.snmp.field]] name = "sysUpTime" 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 ## @@ -86,21 +84,58 @@ oid = "UBNT-UniFi-MIB::unifiIfName" ## - ## System Performance + ## Host performance metrics ## - # System load averages - #[[inputs.snmp.table]] - # oid = "FROGFOOT-RESOURCES-MIB::loadTable" - # [[inputs.snmp.table.field]] - # is_tag = true - # oid = "FROGFOOT-RESOURCES-MIB::loadDescr" + # System Load Average + [[inputs.snmp.table]] + oid = "UCD-SNMP-MIB::laTable" + [[inputs.snmp.table.field]] + oid = "UCD-SNMP-MIB::laNames" + 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 ## [[inputs.snmp]] - agents = [ "192.168.2.1" ] + agents = [ "{{ telegraf_unifi_usg_ips | join('", "') }}" ] interval = "5m" timeout = "5s" retries = 3 @@ -348,3 +383,4 @@ [[inputs.snmp.field]] name = "ipRoutingDiscards" oid = "RFC1213-MIB::ipRoutingDiscards.0" +{% endif %} diff --git a/templates/telegraf.conf b/templates/telegraf.conf index 3a84b8b..3ba1023 100644 --- a/templates/telegraf.conf +++ b/templates/telegraf.conf @@ -32,7 +32,7 @@ # Read metrics about disk usage by mount point [[inputs.disk]] # By default, telegraf gather stats for all mountpoints. - mount_points = ["/"] + mount_points = ["/", "/mnt/volume-nbg1-1"] ignore_fs = ["tmpfs", "devtmpfs", "devfs", "overlay", "aufs", "squashfs"] fieldpass = ["total", "free", "used_percent"] @@ -64,10 +64,7 @@ {% include telegraf_docker_file %} {% endif %} - -{% if telegraf_snmp|default(false)|bool %} -{% include telegraf_snmp_file %} -{% endif %} +{% include telegraf_unifi_file %} # # Monitor sensors, requires lm-sensors package