Skip to content
Snippets Groups Projects
Commit 0bac40a4 authored by void's avatar void
Browse files

additional telegraf metrics

parent ca86dad9
No related branches found
No related tags found
No related merge requests found
Showing
with 771 additions and 0 deletions
---
- name: restart docker_telegraf
docker_service:
project_src: /srv/telegraf/
state: present
restarted: yes
# > 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"]
# > 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
[[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"
[[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"
# 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
# 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
---
- 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
# 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/*
{% 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
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
{% 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" %}
{% 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 = ""
{% 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"]
{% 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" %}
{% 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" %}
#!/bin/sh
# Test Telegraf config and list data
# Usage: ./test.sh <docker name>
docker-compose exec $1 telegraf --test
{% 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" %}
......@@ -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 }
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment