Compare commits

...

4 commits

Author SHA1 Message Date
Felix Niederwanger a3374d05c7
Merge pull request #21 from GeekOops/cleanup
Cleanup
2022-06-29 16:13:38 +02:00
Felix Niederwanger 8c51f407e5
Cleanup
Remove all currently unsupported templates from the collectd.conf file.
2022-06-29 15:45:50 +02:00
Felix Niederwanger eb23c64253
Merge pull request #6 from GeekOops/plugins
Add more plugins
2022-06-29 15:22:50 +02:00
Felix Niederwanger f13a0120ff
Add more plugins
Add a bunch of new plugins that can be configured via this role.
2022-06-29 15:12:29 +02:00
4 changed files with 125 additions and 525 deletions

View file

@ -2,8 +2,7 @@
# geekoops-collectd
Easy ansible role to setup system metrics transmission to `collectd`.
Currently only `influxdb` is supported by this role. This ansible role works with
Easy ansible role to setup system metrics transmission to `collectd`. This ansible role works with
- openSUSE Leap 15.3
- openSUSE Leap 15.4
@ -13,20 +12,44 @@ Currently only `influxdb` is supported by this role. This ansible role works wit
| Value | Description | Default |
|-------|-------------|---------|
|`nodename`| Name of the node that will be shown in grafana | "localhost" |
|`interval`| Report interval in seconds | 10 |
|`overwrite`| Overwrite existing `collectd.conf` file | false |
|`enable_influx`| Enable InfluxDB | false |
|`influx_host`| InfluxDB host | "127.0.0.1" |
|`influx_port`| InfluxDB post | 25826 |
|`enable_disk`| Enable disk plugin | true |
|`enable_cpu`| Enable CPU plugin | true |
|`enable_load`| Enable load plugin | true |
|`enable_memory`| Enable memory plugin | true |
|`enable_swap`| Enable swap plugin | true |
|`enable_df`| Enable df plugin | false |
|`nodename`| Name of the node that will be shown in grafana | `{{ ansible_hostname }}` |
|`interval`| Report interval in seconds | `10` |
|`overwrite`| Overwrite existing `collectd.conf` file | `true` |
|`influx_host`| If set, collectd will push its metrics to this InfluxDB host | "" |
|`influx_port`| InfluxDB post | `25826` |
|`prometheus_port`| If set, collectd will open a webserver of this port to accept scrape requests from Prometheus on this port | `""` |
|`enable_disk`| Enable the disk plugin | `true` |
|`disk_disks`| Disks added to the `disk` plugin | [] |
|`df_disks`| Disks added to the `df` plugin | [] |
|`enable_cpu`| Enable the CPU plugin | `true` |
|`enable_uptime`| Enable the uptime plugin | `true` |
|`enable_cpufreq`| Enable the cpufreq plugin | `true` |
|`enable_load`| Enable the load plugin | `true` |
|`enable_memory`| Enable the memory plugin | `true` |
|`enable_swap`| Enable the swap plugin | `true` |
|`enable_smart`| Enable the smart plugin | `false` |
|`smart_disk` | Select disk(s) to be monitored by the smart plugin | `""` |
|`smart_use_serial` | Use the disk serial number instead of the kernel name to store data | `true` |
|`enable_df`| Enable the df plugin | `false` |
|`df_disks`| Disks added to the `df` plugin | `[]` |
|`enable_apcups`| Enable the apcups plugin | `false` |
|`apcups_host` | Hostname of the running `acpupsd` to query | `localhost` |
|`apcups_port` | Port to query | `3551` |
|`apcups_report_seconds` | Convert the lifetime to seconds | `true` |
|`apcups_persistent_connection` | Keep the connection between reads open | `true` |
|`enable_vmem`| Enable the vmem plugin | `false` |
|`vmem_verbose`| Report vmem stats verbosely | `false` |
|`enable_connectivity`| Enable the connectivity plugin to report if interfaces are up or down | `false` |
|`connectivity_interfaces`| Set the list of interfaces for the connectivity plugin to monitor | `[]` |
|`enable_battery` | Enable the battery plugin | `false` |
|`battery_percentage` | Report the battery stats as percentages | `true` |
|`battery_report_degraded` | Report the degraded stats instead the corrected-for-degraded stats | `false` |
|`enable_hddtemp` | Enable the hddtemp plugin | `false` |
|`hdd_temp_host` | Host to query by the plugin. This is where the hddtemp daemon is running | `127.0.0.1` |
|`hdd_temp_port` | Port of the hddtemp host to query | `7634` |
|`enable_md` | Enable the md plugin (RAID monitoring) | `false` |
|`md_device` | Device the md plugin should monitor | `/dev/md0` |
If `overwrite` is true, any existing `collectd.conf` file will be overwritten by ansible. Use this with caution! The existing configuration will only be written, if `collectd` is installed.
@ -43,15 +66,9 @@ Extended example
- role: geekoops-collectd
vars:
nodename: "jellyfish"
enable_influx: true
influx_host: vinculum
influx_host: "192.168.122.3"
enable_df: true
## License
MIT
## Author Information
phoenix
Have a lot of fun!

View file

@ -1,32 +1,61 @@
---
# defaults file for geekoops-collectd
nodename: "localhost"
nodename: "{{ ansible_hostname }}"
interval: 10
overwrite: false
overwrite: true
enable_influx: false
influx_host: "127.0.0.1"
## Enable pushing of metrics to influxdb
influx_host: ""
influx_port: 25826
enable_prometheus: false
prometheus_port: "9103"
## Enable prometheus scrape webserver on this port
prometheus_port: ""
## Plugins
enable_disk: true
enable_cpu: true
enable_uptime: true
enable_cpufreq: false
enable_load: true
enable_memory: true
enable_swap: true
enable_smart: false
enable_df: false
enable_apcups: false
enable_vmem: false
enable_connectivity: false
enable_battery: false
enable_hddtemp: false
enable_md: false
disk_disks: []
df_disks: []
smart_disk: ""
smart_use_serial: true
report_by_cpu: false
report_by_state: false
cpu_report_by_cpu: "false"
cpu_report_by_state: "false"
cpu_values_percentage: "true"
cpu_report_num_cpus: "false"
apcups_host: "localhost"
apcups_port: "3551"
apcups_report_seconds: "true"
apcups_persistent_connection: "true"
vmem_verbose: "false"
connectivity_interfaces: []
battery_percentage: "true"
battery_report_degraded: "false"
hdd_temp_host: "127.0.0.1"
hdd_temp_port: "7634"
md_device: "/dev/md0"

View file

@ -37,5 +37,4 @@ verifier:
lint:
name: flake8
lint: |
set -e
yamllint .
yamllint -d "{extends: relaxed, rules: {line-length: {max: 200}}}" .

View file

@ -11,118 +11,48 @@ Hostname "{{ nodename }}"
AutoLoadPlugin true
Interval {{ interval }}
LoadPlugin syslog
LoadPlugin cpu
#LoadPlugin cpufreq
{% if enable_cpufreq == true %}
LoadPlugin cpusleep
{% else %}
#LoadPlugin cpusleep
LoadPlugin cpufreq
{% endif %}
{% if enable_df == true %}
LoadPlugin df
{% else %}
#LoadPlugin df
{% endif %}
{% if enable_disk == true %}
LoadPlugin disk
{% else %}
#LoadPlugin disk
{% endif %}
#LoadPlugin hddtemp
#LoadPlugin hugepages
LoadPlugin interface
#LoadPlugin ipmi
{% if enable_load == true %}
LoadPlugin load
{% else %}
#LoadPlugin load
{% endif %}
#LoadPlugin md
{% if enable_memory == true %}
LoadPlugin memory
{% else %}
#LoadPlugin memory
{% endif %}
#LoadPlugin mysql
#LoadPlugin netlink
#LoadPlugin network
#LoadPlugin nfs
#LoadPlugin nginx
#LoadPlugin ntpd
#LoadPlugin openvpn
#LoadPlugin pcie_errors
#LoadPlugin postgresql
#LoadPlugin processes
#LoadPlugin procevent
#LoadPlugin rrdcached
#LoadPlugin rrdtool
#LoadPlugin sensors
#LoadPlugin serial
{% if enable_smart == true and smart_disk != "" %}
#LoadPlugin smart
{% else %}
#LoadPlugin smart
{% endif %}
#LoadPlugin snmp
#LoadPlugin snmp_agent
#LoadPlugin statsd
{% if enable_swap == true %}
LoadPlugin swap
{% else %}
#LoadPlugin swap
{% endif %}
#LoadPlugin thermal
{% if enable_uptime == true %}
LoadPlugin uptime
#LoadPlugin users
#LoadPlugin virt
#LoadPlugin vmem
{% if enable_prometheus == true %}
LoadPlugin write_prometheus
{% endif %}
#<Plugin apcups>
# Host "localhost"
# Port "3551"
# ReportSeconds true
# PersistentConnection true
#</Plugin>
{% if enable_apcups == true %}
<Plugin apcups>
Host "{{ apcups_host }}"
Port "{{ apcups_port }}"
ReportSeconds {{ apcups_report_seconds }}
PersistentConnection {{ apcups_persistent_connection }}
</Plugin>
{% endif %}
#<Plugin "battery">
# ValuesPercentage false
# ReportDegraded false
# QueryStateFS false
#</Plugin>
{% if enable_battery == true %}
<Plugin "battery">
ValuesPercentage {{ battery_percentage }}
ReportDegraded {{ battery_report_degraded }}
QueryStateFS false
</Plugin>
{% endif %}
#<Plugin chrony>
# Host "localhost"
# Port "323"
# Timeout "2"
#</Plugin>
#<Plugin connectivity>
# Interface eth0
#</Plugin>
#<Plugin cgroups>
# CGroup "libvirt"
# IgnoreSelected false
#</Plugin>
{% if enable_connectivity == true %}
<Plugin connectivity>
{% for interface in connectivity_interfaces %}
Interface {{ interface }}
{% endfor %}
</Plugin>
{% endif %}
{% if enable_cpu == true %}
<Plugin cpu>
{% if report_by_cpu == true %}
ReportByCpu true
{% endif %}
{% if report_by_state == true %}
ReportByState true
{% endif %}
ValuesPercentage true
ReportNumCpu false
ReportGuestState false
SubtractGuestState true
ReportByCpu {{ cpu_report_by_cpu }}
ReportByState {{ cpu_report_by_state }}
ValuesPercentage {{ cpu_values_percentage }}
ReportNumCpu {{ cpu_report_num_cpus }}
</Plugin>
{% endif %}
@ -131,9 +61,6 @@ LoadPlugin write_prometheus
{% for disk in df_disks %}
Device "{{ disk }}"
{% endfor %}
# IgnoreSelected false
# ReportByDevice false
# ReportInodes false
ValuesAbsolute true
ValuesPercentage true
</Plugin>
@ -148,49 +75,13 @@ LoadPlugin write_prometheus
</Plugin>
{% endfor %}
{% endif %}
#<Plugin ethstat>
# Interface "eth0"
# Map "rx_csum_offload_errors" "if_rx_errors" "checksum_offload"
# Map "multicast" "if_multicast"
# MappedOnly false
#</Plugin>
#<Plugin filecount>
# <Directory "/path/to/dir">
# #Plugin "foo"
# Instance "foodir"
# Name "*.conf"
# MTime "-5m"
# Size "+10k"
# Recursive true
# IncludeHidden false
# RegularOnly true
# #FilesSizeType "bytes"
# #FilesCountType "files"
# #TypeInstance "instance"
# </Directory>
#</Plugin>
#<Plugin hddtemp>
# Host "127.0.0.1"
# Port "7634"
#</Plugin>
#<Plugin hugepages>
# ReportPerNodeHP true
# ReportRootHP true
# ValuesPages true
# ValuesBytes false
# ValuesPercentage false
#</Plugin>
#<Plugin interface>
# Interface "eth0"
# IgnoreSelected false
# ReportInactive true
# UniqueName false
#</Plugin>
{% if enable_hddtemp == true %}
<Plugin hddtemp>
Host "127.0.0.1"
Port "7634"
# TranslateDevicename true
</Plugin>
{% endif %}
{% if enable_load == true %}
<Plugin load>
@ -198,10 +89,11 @@ LoadPlugin write_prometheus
</Plugin>
{% endif %}
#<Plugin md>
# Device "/dev/md0"
# IgnoreSelected false
#</Plugin>
{% if enable_md == true %}
<Plugin md>
Device "{{ md_device }}"
</Plugin>
{% endif %}
{% if enable_memory == true %}
<Plugin memory>
@ -210,223 +102,12 @@ LoadPlugin write_prometheus
</Plugin>
{% endif %}
#<Plugin mysql>
# <Database db_name>
# Host "database.serv.er"
# User "db_user"
# Password "secret"
# Database "db_name"
# SSLKey "/path/to/key.pem"
# SSLCert "/path/to/cert.pem"
# SSLCA "/path/to/ca.pem"
# SSLCAPath "/path/to/cas/"
# SSLCipher "DHE-RSA-AES256-SHA"
# MasterStats true
# ConnectTimeout 10
# InnodbStats true
# </Database>
#
# <Database db_name2>
# Alias "squeeze"
# Host "localhost"
# Socket "/var/run/mysql/mysqld.sock"
# SlaveStats true
# SlaveNotifications true
# </Database>
# <Database galera>
# Alias "galera"
# Host "localhost"
# Socket "/var/run/mysql/mysqld.sock"
# WsrepStats true
# </Database>
#</Plugin>
#<Plugin netlink>
# Interface "All"
# VerboseInterface "All"
# QDisc "eth0" "pfifo_fast-1:0"
# Class "ppp0" "htb-1:10"
# Filter "ppp0" "u32-1:0"
# IgnoreSelected false
#</Plugin>
{% if enable_influx %}
{% if influx_host != "" %}
<Plugin network>
Server "{{ influx_host }}" "{{ influx_port }}"
</Plugin>
{% endif %}
#<Plugin nfs>
# ReportV2 false
# #ReportV3 false
# #ReportV4 false
#</Plugin>
#<Plugin nginx>
# URL "http://localhost/status?auto"
# User "www-user"
# Password "secret"
# CACert "/etc/ssl/ca.crt"
#</Plugin>
#<Plugin ntpd>
# Host "localhost"
# Port 123
# ReverseLookups false
# IncludeUnitID true
#</Plugin>
#<Plugin openldap>
# <Instance "localhost">
# URL "ldap://localhost:389"
# StartTLS false
# VerifyHost true
# CACert "/path/to/ca.crt"
# Timeout -1
# Version 3
# </Instance>
#</Plugin>
#<Plugin openvpn>
# StatusFile "/etc/openvpn/openvpn-status.log"
# ImprovedNamingSchema false
# CollectCompression true
# CollectIndividualUsers true
# CollectUserCount false
#</Plugin>
#<Plugin pcie_errors>
# Source "sysfs"
# ReportMasked false
# PersistentNotifications false
#</Plugin>
#<Plugin ping>
# Host "host.foo.bar"
# Interval 1.0
# Timeout 0.9
# TTL 255
# SourceAddress "1.2.3.4"
# AddressFamily "any"
# Device "eth0"
# MaxMissed -1
#</Plugin>
#<Plugin postgresql>
# <Query magic>
# Statement "SELECT magic FROM wizard WHERE host = $1;"
# Param hostname
# <Result>
# Type gauge
# InstancePrefix "magic"
# ValuesFrom magic
# </Result>
# </Query>
# <Query rt36_tickets>
# Statement "SELECT COUNT(type) AS count, type \
# FROM (SELECT CASE \
# WHEN resolved = 'epoch' THEN 'open' \
# ELSE 'resolved' END AS type \
# FROM tickets) type \
# GROUP BY type;"
# <Result>
# Type counter
# InstancePrefix "rt36_tickets"
# InstancesFrom "type"
# ValuesFrom "count"
# </Result>
# </Query>
# <Writer sqlstore>
# # See contrib/postgresql/collectd_insert.sql for details
# Statement "SELECT collectd_insert($1, $2, $3, $4, $5, $6, $7, $8, $9);"
# StoreRates true
# </Writer>
# <Database foo>
# #Plugin "kingdom"
# Host "hostname"
# Port "5432"
# User "username"
# Password "secret"
# SSLMode "prefer"
# KRBSrvName "kerberos_service_name"
# Query magic
# </Database>
# <Database bar>
# Interval 60
# Service "service_name"
# Query backends # predefined
# Query rt36_tickets
# </Database>
# <Database qux>
# Service "collectd_store"
# Writer sqlstore
# # see collectd.conf(5) for details
# CommitInterval 30
# </Database>
#</Plugin>
#<Plugin processes>
# CollectFileDescriptor true
# CollectContextSwitch true
# CollectMemoryMaps true
# CollectDelayAccounting false
# Process "name"
# ProcessMatch "name" "regex"
# <Process "collectd">
# CollectFileDescriptor false
# CollectContextSwitch false
# CollectDelayAccounting true
# </Process>
# <ProcessMatch "name" "regex">
# CollectFileDescriptor false
# CollectContextSwitch true
# </Process>
#</Plugin>
#<Plugin protocols>
# Value "/^Tcp:/"
# IgnoreSelected false
#</Plugin>
#<Plugin redis>
# <Node example>
# Host "redis.example.com"
# Port "6379"
# #Socket "/var/run/redis/redis.sock"
# Timeout 2000
# <Query "LLEN myqueue">
# #Database 0
# Type "queue_length"
# Instance "myqueue"
# <Query>
# </Node>
#</Plugin>
#<Plugin rrdcached>
# DaemonAddress "unix:/tmp/rrdcached.sock"
# DataDir "/var/lib/collectd/rrd"
# CreateFiles true
# CreateFilesAsync false
# CollectStatistics true
#</Plugin>
#<Plugin rrdtool>
# DataDir "/var/lib/collectd/rrd"
# CreateFilesAsync false
# CacheTimeout 120
# CacheFlush 900
# WritesPerSecond 50
#</Plugin>
#<Plugin sensors>
# SensorConfigFile "/etc/sensors.conf"
# Sensor "it8712-isa-0290/temperature-temp1"
# Sensor "it8712-isa-0290/fanspeed-fan3"
# Sensor "it8712-isa-0290/voltage-in8"
# IgnoreSelected false
#</Plugin>
{% if enable_smart == true and smart_disk != "" %}
<Plugin smart>
Disk "/^[hs]d[a-f][0-9]?$/"
@ -436,105 +117,6 @@ LoadPlugin write_prometheus
</Plugin>
{% endif %}
#<Plugin snmp>
# <Data "powerplus_voltge_input">
# Table false
# Type "voltage"
# TypeInstance "input_line1"
# Values "SNMPv2-SMI::enterprises.6050.5.4.1.1.2.1"
# </Data>
# <Data "hr_users">
# Table false
# Type "users"
# TypeInstance ""
# Values "HOST-RESOURCES-MIB::hrSystemNumUsers.0"
# </Data>
# <Data "std_traffic">
# Table true
# Type "if_octets"
# TypeInstanceOID "IF-MIB::ifDescr"
# #TypeInstancePrefix "port"
# Values "IF-MIB::ifInOctets" "IF-MIB::ifOutOctets"
# #FilterOID "IF-MIB::ifOperStatus"
# #FilterValues "1", "2"
# </Data>
# <Data "interface_traffic">
# Table true
# Type "if_octets"
# Plugin "interface"
# PluginInstanceOID "IF-MIB::ifDescr"
# Values "IF-MIB::ifInOctets" "IF-MIB::ifOutOctets"
# </Data>
#
# <Host "some.switch.mydomain.org">
# Address "192.168.0.2"
# Version 1
# Community "community_string"
# Collect "std_traffic"
# Interval 120
# Timeout 10
# Retries 1
# </Host>
# <Host "some.server.mydomain.org">
# Address "192.168.0.42"
# Version 2
# Community "another_string"
# Collect "std_traffic" "hr_users"
# </Host>
# <Host "some.ups.mydomain.org">
# Address "192.168.0.3"
# Version 1
# Community "more_communities"
# Collect "powerplus_voltge_input"
# Interval 300
# Timeout 5
# Retries 5
# </Host>
#</Plugin>
#<Plugin snmp_agent>
# <Data "memAvailReal">
# Plugin "memory"
# Type "memory"
# TypeInstance "free"
# OIDs "1.3.6.1.4.1.2021.4.6.0"
# </Data>
# <Table "ifTable">
# IndexOID "IF-MIB::ifIndex"
# SizeOID "IF-MIB::ifNumber"
# <Data "ifDescr">
# <IndexKey>
# Source "PluginInstance"
# </IndexKey>
# Plugin "interface"
# OIDs "IF-MIB::ifDescr"
# </Data>
# <Data "ifOctets">
# Plugin "interface"
# Type "if_octets"
# TypeInstance ""
# OIDs "IF-MIB::ifInOctets" "IF-MIB::ifOutOctets"
# </Data>
# </Table>
#</Plugin>
#<Plugin statsd>
# Host "::"
# Port "8125"
# DeleteCounters false
# DeleteTimers false
# DeleteGauges false
# DeleteSets false
# CounterSum false
# TimerPercentile 90.0
# TimerPercentile 95.0
# TimerPercentile 99.0
# TimerLower false
# TimerUpper false
# TimerSum false
# TimerCount false
#</Plugin>
{% if enable_swap == true %}
<Plugin swap>
ReportByDevice false
@ -545,41 +127,14 @@ LoadPlugin write_prometheus
</Plugin>
{% endif %}
{% if enable_prometheus == true %}
{% if prometheus_port != "" %}
<Plugin "write_prometheus">
Port "{{ prometheus_port }}"
</Plugin>
{% endif %}
#<Plugin sysevent>
# Listen "127.0.0.1" "6666"
# BufferSize 1024
# BufferLength 10
# RegexFilter "regex"
#</Plugin>
#<Plugin virt>
# Connection "xen:///"
# RefreshInterval 60
# Domain "name"
# ReportBlockDevices true
# ReportNetworkInterfaces true
# BlockDevice "name:device"
# BlockDeviceFormat target
# BlockDeviceFormatBasename false
# InterfaceDevice "name:device"
# IgnoreSelected false
# HostnameFormat name
# HostnameMetadataXPath "/instance/name/text()"
# HostnameMetadataNS "http://openstack.org/xmlns/libvirt/nova/1.0"
# InterfaceFormat name
# PluginInstanceFormat name
# Instances 1
# ExtraStats "cpu_util disk disk_err domain_state fs_info job_stats_background pcpu perf vcpu vcpupin disk_physical disk_allocation disk_capacity memory"
# PersistentNotification false
#</Plugin>
#<Plugin vmem>
# Verbose false
#</Plugin>
{% if enable_vmem == true %}
<Plugin vmem>
Verbose {{ vmem_verbose }}
</Plugin>
{% endif %}