Added telegraf role

This commit is contained in:
Darks 2020-09-10 22:34:14 +02:00
parent 5a211c975a
commit 01adf37d9c
Signed by: Darks
GPG Key ID: F61F10FA138E797C
13 changed files with 87 additions and 0 deletions

View File

@ -10,4 +10,5 @@
- iptables
- nginx
- ssh
- telegraf
- uwsgi

View File

@ -0,0 +1,11 @@
[tags]
# Configuration for telegraf agent
[agent]
debug = false
flush_buffer_when_full = true
flush_interval = "15s"
flush_jitter = "0s"
hostname = "planet-casio.com"
interval = "15s"
round_interval = true

View File

@ -0,0 +1,5 @@
# Read metrics about CPU usage
[[inputs.cpu]]
percpu = false
totalcpu = true
fieldpass = [ "usage*" ]

View File

@ -0,0 +1,3 @@
# Read metrics about disk usagee
[[inputs.disk]]
mount_points=["/"]

View File

@ -0,0 +1,4 @@
# Read metrics about diskio usage
[[inputs.diskio]]
devices = ["vda1"]
skip_serial_number = true

View File

@ -0,0 +1,3 @@
# Read metrics about memory usage
[[inputs.mem]]
# no configuration

View File

@ -0,0 +1,4 @@
# Read metrics about network usage
[[inputs.net]]
interfaces = [ "eth0" ]
fielddrop = [ "icmp*", "ip*", "tcp*", "udp*" ]

View File

@ -0,0 +1,3 @@
# Read metrics about Nginx requests
[[inputs.nginx]]
urls = ["http://127.0.0.1:8080/nginx-status"]

View File

@ -0,0 +1,3 @@
# Read metrics about swap memory usage
[[inputs.swap]]
# no configuration

View File

@ -0,0 +1,3 @@
# Read metrics about system load & uptime
[[inputs.system]]
# no configuration

View File

@ -0,0 +1,3 @@
# Read metrics about systemd services
[[inputs.systemd_units]]
# no configuration

View File

@ -0,0 +1,37 @@
---
- name: "Install telegraf" # Yeah I know, quite useless
pacman:
name: "telegraf"
state: present
- name: "Make configuration structure"
file:
path: "/etc/telegraf/telegraf.d"
state: directory
- name: "Copy main configuration"
file:
src: 'telegraf.conf'
dest: '/etc/telegraf/'
owner: 'telegraf'
mode: 0644
- name: "Copy telegraf.d files"
file:
src: '{{ item }}'
dest: '/etc/telegraf/telegraf.d/'
owner: 'telegraf'
mode: 0644
with_fileglob: 'telegraf.d/*.conf'
- name: "Copy outputs.conf with influxdb password"
template:
src: 'outputs.conf'
dest: '/etc/telegraf/telegraf.d/'
owner: 'telegraf'
mode: 0600
- name: "Reloading telegraf"
service:
name: "telegraf"
state: reloaded

View File

@ -0,0 +1,7 @@
# Setup outputs
[[outputs.influxdb]]
database = "telegraf"
precision = "s"
urls = [ "http://127.0.0.1:8086" ]
username = "telegraf"
password = "{{ lookup('passwordstore', 'PCv5/telegraf_influxdb') }}"