From 0bac40a45253872db130f14d126603138b08fa79 Mon Sep 17 00:00:00 2001 From: Christian Elberfeld <elberfeld@web.de> Date: Sat, 28 Jul 2018 18:13:15 +0200 Subject: [PATCH] additional telegraf metrics --- warpsrvint/docker_telegraf/handlers/main.yml | 7 + .../docker_telegraf/includes/snmp_disk.conf | 49 +++++++ .../docker_telegraf/includes/snmp_net.conf | 57 ++++++++ .../docker_telegraf/includes/snmp_system.conf | 106 ++++++++++++++ .../docker_telegraf/includes/snmp_uptime.conf | 15 ++ .../docker_telegraf/includes/telegraf.conf | 135 ++++++++++++++++++ .../includes/telegraf_snmp.conf | 135 ++++++++++++++++++ warpsrvint/docker_telegraf/tasks/main.yml | 35 +++++ .../docker_telegraf/templates/Dockerfile | 24 ++++ warpsrvint/docker_telegraf/templates/dns.conf | 30 ++++ .../templates/docker-compose.yml | 39 +++++ .../docker_telegraf/templates/firewall.conf | 12 ++ .../docker_telegraf/templates/ping.conf | 40 ++++++ .../docker_telegraf/templates/storage.conf | 50 +++++++ .../templates/switch-sw01.conf | 10 ++ .../templates/switch-sw02.conf | 10 ++ warpsrvint/docker_telegraf/templates/test.sh | 6 + .../docker_telegraf/templates/warpfire.conf | 10 ++ warpsrvint/main.yml | 1 + 19 files changed, 771 insertions(+) create mode 100644 warpsrvint/docker_telegraf/handlers/main.yml create mode 100644 warpsrvint/docker_telegraf/includes/snmp_disk.conf create mode 100644 warpsrvint/docker_telegraf/includes/snmp_net.conf create mode 100644 warpsrvint/docker_telegraf/includes/snmp_system.conf create mode 100644 warpsrvint/docker_telegraf/includes/snmp_uptime.conf create mode 100644 warpsrvint/docker_telegraf/includes/telegraf.conf create mode 100644 warpsrvint/docker_telegraf/includes/telegraf_snmp.conf create mode 100644 warpsrvint/docker_telegraf/tasks/main.yml create mode 100644 warpsrvint/docker_telegraf/templates/Dockerfile create mode 100644 warpsrvint/docker_telegraf/templates/dns.conf create mode 100644 warpsrvint/docker_telegraf/templates/docker-compose.yml create mode 100644 warpsrvint/docker_telegraf/templates/firewall.conf create mode 100644 warpsrvint/docker_telegraf/templates/ping.conf create mode 100644 warpsrvint/docker_telegraf/templates/storage.conf create mode 100644 warpsrvint/docker_telegraf/templates/switch-sw01.conf create mode 100644 warpsrvint/docker_telegraf/templates/switch-sw02.conf create mode 100644 warpsrvint/docker_telegraf/templates/test.sh create mode 100644 warpsrvint/docker_telegraf/templates/warpfire.conf diff --git a/warpsrvint/docker_telegraf/handlers/main.yml b/warpsrvint/docker_telegraf/handlers/main.yml new file mode 100644 index 00000000..0c21a0c5 --- /dev/null +++ b/warpsrvint/docker_telegraf/handlers/main.yml @@ -0,0 +1,7 @@ +--- + +- name: restart docker_telegraf + docker_service: + project_src: /srv/telegraf/ + state: present + restarted: yes diff --git a/warpsrvint/docker_telegraf/includes/snmp_disk.conf b/warpsrvint/docker_telegraf/includes/snmp_disk.conf new file mode 100644 index 00000000..8db40d0b --- /dev/null +++ b/warpsrvint/docker_telegraf/includes/snmp_disk.conf @@ -0,0 +1,49 @@ + + + +# > disk,device=sda1,fstype=ext4,host=intserver,mode=rw,path=/ used_percent=59.84807964728844,inodes_total=1969920i,inodes_free=1293871i,inodes_used=676049i,total=31570497536i,free=12071796736i,used=17993506816i 1530122504000000000 + +[[inputs.snmp]] + agents = [ "{{ip}}:161" ] + version = 2 + community = "public" + + name = "disk" + + [[inputs.snmp.table]] + name = "disk" + inherit_tags = [ "hostname" ] + + [[inputs.snmp.table.field]] + name = "path" + oid = ".1.3.6.1.4.1.2021.9.1.2" + is_tag = true + + [[inputs.snmp.table.field]] + name = "device" + oid = ".1.3.6.1.4.1.2021.9.1.3" + is_tag = true + + [[inputs.snmp.table.field]] + name = "total" + oid = ".1.3.6.1.4.1.2021.9.1.6" + conversion = "float(-3)" + + [[inputs.snmp.table.field]] + name = "free" + oid = ".1.3.6.1.4.1.2021.9.1.7" + conversion = "float(-3)" + + [[inputs.snmp.table.field]] + name = "used" + oid = ".1.3.6.1.4.1.2021.9.1.8" + conversion = "float(-3)" + + [[inputs.snmp.table.field]] + name = "used_percent" + oid = ".1.3.6.1.4.1.2021.9.1.9" + conversion = "float" + + [inputs.snmp.tagdrop] + device = ["devfs"] + diff --git a/warpsrvint/docker_telegraf/includes/snmp_net.conf b/warpsrvint/docker_telegraf/includes/snmp_net.conf new file mode 100644 index 00000000..69561a33 --- /dev/null +++ b/warpsrvint/docker_telegraf/includes/snmp_net.conf @@ -0,0 +1,57 @@ + +# > net,host=intserver,interface=ens18 bytes_sent=33177357581i,bytes_recv=25054856709i,err_out=0i,packets_sent=26269494i,packets_recv=41050674i,err_in=0i,drop_in=0i,drop_out=0i 1530122482000000000 + +[[inputs.snmp]] + agents = [ "{{ip}}:161" ] + version = 2 + community = "public" + + name = "net" + + [[inputs.snmp.table]] + name = "net" + inherit_tags = [ "hostname" ] + + [[inputs.snmp.table.field]] + name = "interface" + oid = ".1.3.6.1.2.1.31.1.1.1.1" + is_tag = true + + [[inputs.snmp.table.field]] + name = "op_status" + oid = ".1.3.6.1.2.1.2.2.1.8" + + [[inputs.snmp.table.field]] + name = "drop_in" + oid = ".1.3.6.1.2.1.2.2.1.13" + + [[inputs.snmp.table.field]] + name = "drop_out" + oid = ".1.3.6.1.2.1.2.2.1.19" + + [[inputs.snmp.table.field]] + name = "err_in" + oid = ".1.3.6.1.2.1.2.2.1.14" + + [[inputs.snmp.table.field]] + name = "err_out" + oid = ".1.3.6.1.2.1.2.2.1.20" + + [[inputs.snmp.table.field]] + name = "bytes_recv" + oid = ".1.3.6.1.2.1.31.1.1.1.6" + + [[inputs.snmp.table.field]] + name = "bytes_sent" + oid = ".1.3.6.1.2.1.31.1.1.1.10" + + [[inputs.snmp.table.field]] + name = "packets_recv" + oid = ".1.3.6.1.2.1.31.1.1.1.7" + + [[inputs.snmp.table.field]] + name = "packets_sent" + oid = ".1.3.6.1.2.1.31.1.1.1.11" + + [inputs.snmp.tagdrop] + interface = ["lo*","bridge*","pflog*","pfsync*","enc*"] \ No newline at end of file diff --git a/warpsrvint/docker_telegraf/includes/snmp_system.conf b/warpsrvint/docker_telegraf/includes/snmp_system.conf new file mode 100644 index 00000000..9ccd376e --- /dev/null +++ b/warpsrvint/docker_telegraf/includes/snmp_system.conf @@ -0,0 +1,106 @@ + + +[[inputs.snmp]] + agents = [ "{{ip}}:161" ] + version = 2 + community = "public" + + name = "system" + + +# Telegraf System Werte +#> system,host=intserver n_cpus=2i,n_users=2i,load1=0.09,load5=0.14,load15=0.29 1530122432000000000 +#> system,host=intserver uptime=3970179i 1530122432000000000 + + + [[inputs.snmp.field]] + name = "load1" + oid = ".1.3.6.1.4.1.2021.10.1.3.1" + conversion = "float" + + [[inputs.snmp.field]] + name = "load5" + oid = ".1.3.6.1.4.1.2021.10.1.3.2" + conversion = "float" + + [[inputs.snmp.field]] + name = "load15" + oid = ".1.3.6.1.4.1.2021.10.1.3.3" + conversion = "float" + +# Telegraf CPU Werte +# > cpu,cpu=cpu1,host=intserver usage_idle=63.46153841676334,usage_nice=0,usage_iowait=3.8461538405569557,usage_irq=0,usage_user=9.615384615384615,usage_system=7.6923076923076925,usage_softirq=0,usage_steal=15.384615370623159,usage_guest=0,usage_guest_nice=0 1530117600000000000 + +[[inputs.snmp]] + agents = [ "{{ip}}:161" ] + version = 2 + community = "public" + + name = "cpu" + + [[inputs.snmp.field]] + name = "usage_idle" + oid = ".1.3.6.1.4.1.2021.11.11.0" + conversion = "float" + + [[inputs.snmp.field]] + name = "usage_system" + oid = ".1.3.6.1.4.1.2021.11.10.0" + conversion = "float" + + [[inputs.snmp.field]] + name = "usage_user" + oid = ".1.3.6.1.4.1.2021.11.9.0" + conversion = "float" + +# Telegraf Mem werte +# > mem,host=intserver cached=1432678400i,buffered=350068736i,slab=288620544i,total=4047396864i,available=3276423168i,used=634953728i,wired=0i,used_percent=15.687953253303702,available_percent=80.95136894388818,free=1629696000i,active=1072840704i,inactive=995454976i 1530122577000000000 + +[[inputs.snmp]] + agents = [ "{{ip}}:161" ] + version = 2 + community = "public" + + name = "mem" + + [[inputs.snmp.field]] + name = "total" + oid = ".1.3.6.1.4.1.2021.4.5.0" + + [[inputs.snmp.field]] + name = "used" + oid = ".1.3.6.1.4.1.2021.4.6.0" + + [[inputs.snmp.field]] + name = "available" + oid = ".1.3.6.1.4.1.2021.4.11.0" + + [[inputs.snmp.field]] + name = "buffered" + oid = ".1.3.6.1.4.1.2021.4.14.0" + + [[inputs.snmp.field]] + name = "cached" + oid = ".1.3.6.1.4.1.2021.4.15.0" + + + +# Telegraf Swap werte +# > swap,host=intserver total=2146430976i,used=111517696i,free=2034913280i,used_percent=5.1954941596966595 1530123438000000000 +# > swap,host=intserver in=67203072i,out=716234752i 1530123438000000000 + +[[inputs.snmp]] + agents = [ "{{ip}}:161" ] + version = 2 + community = "public" + + name = "swap" + + [[inputs.snmp.field]] + name = "total" + oid = ".1.3.6.1.4.1.2021.4.3.0" + + [[inputs.snmp.field]] + name = "free" + oid = ".1.3.6.1.4.1.2021.4.4.0" + diff --git a/warpsrvint/docker_telegraf/includes/snmp_uptime.conf b/warpsrvint/docker_telegraf/includes/snmp_uptime.conf new file mode 100644 index 00000000..025b8183 --- /dev/null +++ b/warpsrvint/docker_telegraf/includes/snmp_uptime.conf @@ -0,0 +1,15 @@ + +[[inputs.snmp]] + agents = [ "{{ip}}:161" ] + version = 2 + community = "public" + + name = "system" + + +# Telegraf System Werte +#> system,host=intserver uptime=3970179i 1530122432000000000 + + [[inputs.snmp.field]] + name = "uptime" + oid = ".1.3.6.1.2.1.1.3.0" diff --git a/warpsrvint/docker_telegraf/includes/telegraf.conf b/warpsrvint/docker_telegraf/includes/telegraf.conf new file mode 100644 index 00000000..41db966b --- /dev/null +++ b/warpsrvint/docker_telegraf/includes/telegraf.conf @@ -0,0 +1,135 @@ + +# Global tags can be specified here in key="value" format. +[global_tags] + # dc = "us-east-1" # will tag all metrics with dc=us-east-1 + # rack = "1a" + ## Environment variables can be used as tags, and throughout the config file + # user = "$USER" + +# Configuration for telegraf agent +[agent] + + ## Default data collection interval for all inputs + interval = "{{interval}}" + + ## Rounds collection interval to 'interval' + ## ie, if interval="10s" then always collect on :00, :10, :20, etc. + round_interval = true + + ## Telegraf will send metrics to outputs in batches of at most + ## metric_batch_size metrics. + ## This controls the size of writes that Telegraf sends to output plugins. + metric_batch_size = 1000 + + ## For failed writes, telegraf will cache metric_buffer_limit metrics for each + ## output, and will flush this buffer on a successful write. Oldest metrics + ## are dropped first when this buffer fills. + ## This buffer only fills when writes fail to output plugin(s). + metric_buffer_limit = 10000 + + ## Collection jitter is used to jitter the collection by a random amount. + ## Each plugin will sleep for a random time within jitter before collecting. + ## This can be used to avoid many plugins querying things like sysfs at the + ## same time, which can have a measurable effect on the system. + collection_jitter = "0s" + + ## Default flushing interval for all outputs. You shouldn't set this below + ## interval. Maximum flush_interval will be flush_interval + flush_jitter + flush_interval = "{{flush_interval}}" + + ## Jitter the flush interval by a random amount. This is primarily to avoid + ## large write spikes for users running a large number of telegraf instances. + ## ie, a jitter of 5s and interval 10s means flushes will happen every 10-15s + flush_jitter = "0s" + + ## By default or when set to "0s", precision will be set to the same + ## timestamp order as the collection interval, with the maximum being 1s. + ## ie, when interval = "10s", precision will be "1s" + ## when interval = "250ms", precision will be "1ms" + ## Precision will NOT be used for service inputs. It is up to each individual + ## service input to set the timestamp at the appropriate precision. + ## Valid time units are "ns", "us" (or "µs"), "ms", "s". + precision = "" + + ## Logging configuration: + ## Run telegraf with debug log messages. + debug = false + + ## Run telegraf in quiet mode (error log messages only). + quiet = false + + ## Specify the log file name. The empty string means to log to stderr. + logfile = "" + + ## Override default hostname, if empty use os.Hostname() + hostname = "{{hostname}}" + + ## If set to true, do no set the "host" tag in the telegraf agent. + omit_hostname = false + + +############################################################################### +# OUTPUT PLUGINS # +############################################################################### + + +# Configuration for sending metrics to InfluxDB +[[outputs.influxdb]] + ## The full HTTP or UDP URL for your InfluxDB instance. + ## + urls = ["{{influxdb_sysmon.url}}"] + + ## The target database for metrics; will be created as needed. + database = "{{influxdb_sysmon.db}}" + + ## If true, no CREATE DATABASE queries will be sent. Set to true when using + ## Telegraf with a user without permissions to create databases or when the + ## database already exists. + skip_database_creation = true + + ## Name of existing retention policy to write to. Empty string writes to + ## the default retention policy. + # retention_policy = "" + + ## Write consistency (clusters only), can be: "any", "one", "quorum", "all" + # write_consistency = "any" + + ## Timeout for HTTP messages. + # timeout = "5s" + + ## HTTP Basic Auth + username = "{{influxdb_sysmon.user}}" + password = "{{influxdb_sysmon.password}}" + + ## HTTP User-Agent + # user_agent = "telegraf" + + ## UDP payload size is the maximum packet size to send. + # udp_payload = 512 + + ## Optional SSL Config + # ssl_ca = "/etc/telegraf/ca.pem" + # ssl_cert = "/etc/telegraf/cert.pem" + # ssl_key = "/etc/telegraf/key.pem" + ## Use SSL but skip chain & host verification + # insecure_skip_verify = false + + ## HTTP Proxy override, if unset values the standard proxy environment + ## variables are consulted to determine which proxy, if any, should be used. + # http_proxy = "http://corporate.proxy:3128" + + ## Additional HTTP headers + # http_headers = {"X-Special-Header" = "Special-Value"} + + ## HTTP Content-Encoding for write request body, can be set to "gzip" to + ## compress body or "identity" to apply no encoding. + # content_encoding = "identity" + + ## When true, Telegraf will output unsigned integers as unsigned values, + ## i.e.: "42u". You will need a version of InfluxDB supporting unsigned + ## integer values. Enabling this option will result in field type errors if + ## existing data has been written. + # influx_uint_support = false + + + diff --git a/warpsrvint/docker_telegraf/includes/telegraf_snmp.conf b/warpsrvint/docker_telegraf/includes/telegraf_snmp.conf new file mode 100644 index 00000000..41db966b --- /dev/null +++ b/warpsrvint/docker_telegraf/includes/telegraf_snmp.conf @@ -0,0 +1,135 @@ + +# Global tags can be specified here in key="value" format. +[global_tags] + # dc = "us-east-1" # will tag all metrics with dc=us-east-1 + # rack = "1a" + ## Environment variables can be used as tags, and throughout the config file + # user = "$USER" + +# Configuration for telegraf agent +[agent] + + ## Default data collection interval for all inputs + interval = "{{interval}}" + + ## Rounds collection interval to 'interval' + ## ie, if interval="10s" then always collect on :00, :10, :20, etc. + round_interval = true + + ## Telegraf will send metrics to outputs in batches of at most + ## metric_batch_size metrics. + ## This controls the size of writes that Telegraf sends to output plugins. + metric_batch_size = 1000 + + ## For failed writes, telegraf will cache metric_buffer_limit metrics for each + ## output, and will flush this buffer on a successful write. Oldest metrics + ## are dropped first when this buffer fills. + ## This buffer only fills when writes fail to output plugin(s). + metric_buffer_limit = 10000 + + ## Collection jitter is used to jitter the collection by a random amount. + ## Each plugin will sleep for a random time within jitter before collecting. + ## This can be used to avoid many plugins querying things like sysfs at the + ## same time, which can have a measurable effect on the system. + collection_jitter = "0s" + + ## Default flushing interval for all outputs. You shouldn't set this below + ## interval. Maximum flush_interval will be flush_interval + flush_jitter + flush_interval = "{{flush_interval}}" + + ## Jitter the flush interval by a random amount. This is primarily to avoid + ## large write spikes for users running a large number of telegraf instances. + ## ie, a jitter of 5s and interval 10s means flushes will happen every 10-15s + flush_jitter = "0s" + + ## By default or when set to "0s", precision will be set to the same + ## timestamp order as the collection interval, with the maximum being 1s. + ## ie, when interval = "10s", precision will be "1s" + ## when interval = "250ms", precision will be "1ms" + ## Precision will NOT be used for service inputs. It is up to each individual + ## service input to set the timestamp at the appropriate precision. + ## Valid time units are "ns", "us" (or "µs"), "ms", "s". + precision = "" + + ## Logging configuration: + ## Run telegraf with debug log messages. + debug = false + + ## Run telegraf in quiet mode (error log messages only). + quiet = false + + ## Specify the log file name. The empty string means to log to stderr. + logfile = "" + + ## Override default hostname, if empty use os.Hostname() + hostname = "{{hostname}}" + + ## If set to true, do no set the "host" tag in the telegraf agent. + omit_hostname = false + + +############################################################################### +# OUTPUT PLUGINS # +############################################################################### + + +# Configuration for sending metrics to InfluxDB +[[outputs.influxdb]] + ## The full HTTP or UDP URL for your InfluxDB instance. + ## + urls = ["{{influxdb_sysmon.url}}"] + + ## The target database for metrics; will be created as needed. + database = "{{influxdb_sysmon.db}}" + + ## If true, no CREATE DATABASE queries will be sent. Set to true when using + ## Telegraf with a user without permissions to create databases or when the + ## database already exists. + skip_database_creation = true + + ## Name of existing retention policy to write to. Empty string writes to + ## the default retention policy. + # retention_policy = "" + + ## Write consistency (clusters only), can be: "any", "one", "quorum", "all" + # write_consistency = "any" + + ## Timeout for HTTP messages. + # timeout = "5s" + + ## HTTP Basic Auth + username = "{{influxdb_sysmon.user}}" + password = "{{influxdb_sysmon.password}}" + + ## HTTP User-Agent + # user_agent = "telegraf" + + ## UDP payload size is the maximum packet size to send. + # udp_payload = 512 + + ## Optional SSL Config + # ssl_ca = "/etc/telegraf/ca.pem" + # ssl_cert = "/etc/telegraf/cert.pem" + # ssl_key = "/etc/telegraf/key.pem" + ## Use SSL but skip chain & host verification + # insecure_skip_verify = false + + ## HTTP Proxy override, if unset values the standard proxy environment + ## variables are consulted to determine which proxy, if any, should be used. + # http_proxy = "http://corporate.proxy:3128" + + ## Additional HTTP headers + # http_headers = {"X-Special-Header" = "Special-Value"} + + ## HTTP Content-Encoding for write request body, can be set to "gzip" to + ## compress body or "identity" to apply no encoding. + # content_encoding = "identity" + + ## When true, Telegraf will output unsigned integers as unsigned values, + ## i.e.: "42u". You will need a version of InfluxDB supporting unsigned + ## integer values. Enabling this option will result in field type errors if + ## existing data has been written. + # influx_uint_support = false + + + diff --git a/warpsrvint/docker_telegraf/tasks/main.yml b/warpsrvint/docker_telegraf/tasks/main.yml new file mode 100644 index 00000000..1d470a2b --- /dev/null +++ b/warpsrvint/docker_telegraf/tasks/main.yml @@ -0,0 +1,35 @@ +--- + +- name: create folder struct for telegraf + file: + path: "{{ item }}" + state: "directory" + with_items: + - /srv/telegraf/ + +- name: Konfig-Dateien erstellen + template: + src: "{{ item }}" + dest: "/srv/telegraf/{{ item }}" + with_items: + - Dockerfile + - docker-compose.yml + - dns.conf + - firewall.conf + - ping.conf + - storage.conf + - switch.conf + notify: restart docker_telegraf + +- name: Script-Dateien erstellen + template: + src: "{{ item }}" + dest: "/srv/telegraf/{{ item }}" + mode: "o+rwx" + with_items: + - test.sh + +- name: start telegraf dockers + docker_service: + project_src: /srv/telegraf/ + state: present diff --git a/warpsrvint/docker_telegraf/templates/Dockerfile b/warpsrvint/docker_telegraf/templates/Dockerfile new file mode 100644 index 00000000..62f9d2eb --- /dev/null +++ b/warpsrvint/docker_telegraf/templates/Dockerfile @@ -0,0 +1,24 @@ + +# Telegraf with additional SNMP Tools +# Based on: +# https://github.com/influxdata/influxdata-docker +# https://github.com/weldpua2008/docker-net-snmp + +FROM telegraf:1.7 + +RUN export DEBIAN_FRONTEND=noninteractive && \ + export DEBIAN_RELEASE=$(awk -F'[" ]' '/VERSION=/{print $3}' /etc/os-release | tr -cd '[[:alnum:]]._-' ) && \ + echo "remove main from /etc/apt/sources.list" && \ + sed -i '/main/d' /etc/apt/sources.list && \ + echo "remove contrib from /etc/apt/sources.list" && \ + sed -i '/contrib/d' /etc/apt/sources.list && \ + echo "remove non-free from /etc/apt/sources.list" && \ + sed -i '/non-free/d' /etc/apt/sources.list && \ + echo "deb http://httpredir.debian.org/debian ${DEBIAN_RELEASE} main contrib non-free" >> /etc/apt/sources.list && \ + echo "deb http://httpredir.debian.org/debian ${DEBIAN_RELEASE}-updates main contrib non-free" >> /etc/apt/sources.list && \ + echo "deb http://security.debian.org ${DEBIAN_RELEASE}/updates main contrib non-free" >> /etc/apt/sources.list && \ + set -x &&\ + apt-get update && \ + apt-get -y install snmp snmpd snmp-mibs-downloader && \ + rm -r /var/lib/apt/lists/* + diff --git a/warpsrvint/docker_telegraf/templates/dns.conf b/warpsrvint/docker_telegraf/templates/dns.conf new file mode 100644 index 00000000..c906ea54 --- /dev/null +++ b/warpsrvint/docker_telegraf/templates/dns.conf @@ -0,0 +1,30 @@ + +{% set interval = "5s" %} +{% set flush_interval = "10s" %} + +{% set hostname = "intserver" %} + +{% include "includes/telegraf.conf" %} + + +# Query given DNS server and gives statistics +[[inputs.dns_query]] + ## servers to query + servers = ["10.0.0.1","8.8.8.8","9.9.9.10"] + + ## Network is the network protocol name. + # network = "udp" + + ## Domains or subdomains to query. + # domains = ["."] + + ## Query record type. + ## Posible values: A, AAAA, CNAME, MX, NS, PTR, TXT, SOA, SPF, SRV. + # record_type = "A" + + ## Dns server port. + # port = 53 + + ## Query timeout in seconds. + # timeout = 2 + diff --git a/warpsrvint/docker_telegraf/templates/docker-compose.yml b/warpsrvint/docker_telegraf/templates/docker-compose.yml new file mode 100644 index 00000000..bcb176b9 --- /dev/null +++ b/warpsrvint/docker_telegraf/templates/docker-compose.yml @@ -0,0 +1,39 @@ +version: "3" + +services: + + dns: + + build: . + restart: always + volumes: + - /srv/telegraf/dns.conf:/etc/telegraf/telegraf.conf:ro + + firewall: + + build: . + restart: always + volumes: + - /srv/telegraf/firewall.conf:/etc/telegraf/telegraf.conf:ro + + ping: + + build: . + restart: always + volumes: + - /srv/telegraf/ping.conf:/etc/telegraf/telegraf.conf:ro + + switch: + + build: . + restart: always + volumes: + - /srv/telegraf/switch.conf:/etc/telegraf/telegraf.conf:ro + + storage: + + build: . + restart: always + volumes: + - /srv/telegraf/storage.conf:/etc/telegraf/telegraf.conf:ro + diff --git a/warpsrvint/docker_telegraf/templates/firewall.conf b/warpsrvint/docker_telegraf/templates/firewall.conf new file mode 100644 index 00000000..9508ba67 --- /dev/null +++ b/warpsrvint/docker_telegraf/templates/firewall.conf @@ -0,0 +1,12 @@ + +{% set interval = "10s" %} +{% set flush_interval = "30s" %} + +{% set hostname = "firewall" %} +{% set ip = "10.5.0.254" %} + +{% include "includes/telegraf.conf" %} +{% include "includes/snmp_uptime.conf" %} +{% include "includes/snmp_system.conf" %} +{% include "includes/snmp_net.conf" %} + diff --git a/warpsrvint/docker_telegraf/templates/ping.conf b/warpsrvint/docker_telegraf/templates/ping.conf new file mode 100644 index 00000000..0a5f687c --- /dev/null +++ b/warpsrvint/docker_telegraf/templates/ping.conf @@ -0,0 +1,40 @@ + +{% set interval = "5s" %} +{% set flush_interval = "10s" %} + +{% set hostname = "intserver" %} + +{% include "includes/telegraf.conf" %} + +# NOTE: this plugin forks the ping command. You may need to set capabilities +# via setcap cap_net_raw+p /bin/ping +[[inputs.ping]] + ## List of urls to ping + urls = [ + "8.8.8.8", + "9.9.9.10", + "warpzone.ms", + "alerta.warpzone.ms", + "gitlab.warpzone.ms", + "infra.warpzone.ms", + "jabber.warpzone.ms", + "mail.warpzone.ms", + "zone.warpzone.ms", + ] + + ## number of pings to send per collection (ping -c <COUNT>) + count = 1 + + ## interval, in s, at which to ping. 0 == default (ping -i <PING_INTERVAL>) + ## Not available in Windows. + # ping_interval = 1.0 + + ## per-ping timeout, in s. 0 == no timeout (ping -W <TIMEOUT>) + timeout = 3.0 + + ## total-ping deadline, in s. 0 == no deadline (ping -w <DEADLINE>) + # deadline = 10 + + ## interface or source address to send ping from (ping -I <INTERFACE/SRC_ADDR>) + ## on Darwin and Freebsd only source address possible: (ping -S <SRC_ADDR>) + # interface = "" diff --git a/warpsrvint/docker_telegraf/templates/storage.conf b/warpsrvint/docker_telegraf/templates/storage.conf new file mode 100644 index 00000000..db82d0d1 --- /dev/null +++ b/warpsrvint/docker_telegraf/templates/storage.conf @@ -0,0 +1,50 @@ + +{% set interval = "30s" %} +{% set flush_interval = "60s" %} + +{% set hostname = "storage" %} +{% set ip = "10.5.0.100" %} + +{% include "includes/telegraf.conf" %} +{% include "includes/snmp_uptime.conf" %} +{% include "includes/snmp_net.conf" %} + +# Non-Standard mibs für QNAP +# > disk,device=sda1,fstype=ext4,host=intserver,mode=rw,path=/ used_percent=59.84807964728844,inodes_total=1969920i,inodes_free=1293871i,inodes_used=676049i,total=31570497536i,free=12071796736i,used=17993506816i 1530122504000000000 + +[[inputs.snmp]] + agents = [ "{{ip}}:161" ] + version = 2 + community = "public" + + name = "disk" + + [[inputs.snmp.table]] + name = "disk" + inherit_tags = [ "hostname" ] + + [[inputs.snmp.table.field]] + name = "path" + oid = ".1.3.6.1.4.1.24681.1.3.17.1.2" + is_tag = true + + [[inputs.snmp.table.field]] + name = "device" + oid = ".1.3.6.1.4.1.24681.1.3.17.1.2" + is_tag = true + + [[inputs.snmp.table.field]] + name = "total" + oid = ".1.3.6.1.4.1.24681.1.3.17.1.4" + conversion = "float(-3)" + + [[inputs.snmp.table.field]] + name = "free" + oid = ".1.3.6.1.4.1.24681.1.3.17.1.5" + conversion = "float(-3)" + + +[[processors.converter]] + + [processors.converter.fields] + integer = ["total","free"] diff --git a/warpsrvint/docker_telegraf/templates/switch-sw01.conf b/warpsrvint/docker_telegraf/templates/switch-sw01.conf new file mode 100644 index 00000000..a96198b8 --- /dev/null +++ b/warpsrvint/docker_telegraf/templates/switch-sw01.conf @@ -0,0 +1,10 @@ + +{% set interval = "10s" %} +{% set flush_interval = "30s" %} + +{% set hostname = "switch-sw01" %} +{% set ip = "192.168.0.100" %} + +{% include "includes/telegraf_snmp.conf" %} +{% include "includes/snmp_uptime.conf" %} +{% include "includes/snmp_net.conf" %} diff --git a/warpsrvint/docker_telegraf/templates/switch-sw02.conf b/warpsrvint/docker_telegraf/templates/switch-sw02.conf new file mode 100644 index 00000000..c75a8fd7 --- /dev/null +++ b/warpsrvint/docker_telegraf/templates/switch-sw02.conf @@ -0,0 +1,10 @@ + +{% set interval = "10s" %} +{% set flush_interval = "30s" %} + +{% set hostname = "switch-sw02" %} +{% set ip = "192.168.0.101" %} + +{% include "includes/telegraf_snmp.conf" %} +{% include "includes/snmp_uptime.conf" %} +{% include "includes/snmp_net.conf" %} diff --git a/warpsrvint/docker_telegraf/templates/test.sh b/warpsrvint/docker_telegraf/templates/test.sh new file mode 100644 index 00000000..9eca304e --- /dev/null +++ b/warpsrvint/docker_telegraf/templates/test.sh @@ -0,0 +1,6 @@ +#!/bin/sh + +# Test Telegraf config and list data +# Usage: ./test.sh <docker name> + +docker-compose exec $1 telegraf --test diff --git a/warpsrvint/docker_telegraf/templates/warpfire.conf b/warpsrvint/docker_telegraf/templates/warpfire.conf new file mode 100644 index 00000000..4448561a --- /dev/null +++ b/warpsrvint/docker_telegraf/templates/warpfire.conf @@ -0,0 +1,10 @@ + +{% set interval = "10s" %} +{% set flush_interval = "30s" %} + +{% set hostname = "warpfire" %} +{% set ip = "10.0.0.1" %} + +{% include "includes/telegraf_snmp.conf" %} +{% include "includes/snmp_uptime.conf" %} +{% include "includes/snmp_net.conf" %} diff --git a/warpsrvint/main.yml b/warpsrvint/main.yml index 796cbd87..6a54c3bb 100644 --- a/warpsrvint/main.yml +++ b/warpsrvint/main.yml @@ -19,6 +19,7 @@ - { role: docker_mqtt, tags: mqtt } - { role: docker_nodered, tags: nodered } - { role: docker_prometheus, tags: prometheus } + - { role: docker_telegraf, tags: telegraf } - { role: docker_unifi, tags: unifi } - { role: docker_warpinfra, tags: warpinfra } - { role: docker_warpinfratest, tags: warpinfratest } -- GitLab