diff --git a/README.md b/README.md index 6ace18b..5aeed05 100644 --- a/README.md +++ b/README.md @@ -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! diff --git a/defaults/main.yml b/defaults/main.yml index 28fe194..5f39904 100644 --- a/defaults/main.yml +++ b/defaults/main.yml @@ -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" diff --git a/molecule/default/molecule.yml b/molecule/default/molecule.yml index a72887a..7114088 100644 --- a/molecule/default/molecule.yml +++ b/molecule/default/molecule.yml @@ -37,5 +37,4 @@ verifier: lint: name: flake8 lint: | - set -e - yamllint . + yamllint -d "{extends: relaxed, rules: {line-length: {max: 200}}}" . diff --git a/templates/collectd.conf.j2 b/templates/collectd.conf.j2 index a71ccba..f4241af 100644 --- a/templates/collectd.conf.j2 +++ b/templates/collectd.conf.j2 @@ -11,42 +11,20 @@ Hostname "{{ nodename }}" AutoLoadPlugin true Interval {{ interval }} -LoadPlugin syslog -LoadPlugin cpu +#LoadPlugin syslog +#LoadPlugin cpu #LoadPlugin cpufreq {% if enable_cpufreq == true %} LoadPlugin cpusleep -{% else %} -#LoadPlugin cpusleep {% 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 @@ -59,42 +37,32 @@ LoadPlugin memory #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 +{% endif %} #LoadPlugin users #LoadPlugin virt -#LoadPlugin vmem -{% if enable_prometheus == true %} -LoadPlugin write_prometheus +{% if enable_apcups == true %} + + Host "{{ apcups_host }}" + Port "{{ apcups_port }}" + ReportSeconds {{ apcups_report_seconds }} + PersistentConnection {{ apcups_persistent_connection }} + {% endif %} -# -# Host "localhost" -# Port "3551" -# ReportSeconds true -# PersistentConnection true -# - -# -# ValuesPercentage false -# ReportDegraded false -# QueryStateFS false -# +{% if enable_battery == true %} + + ValuesPercentage {{ battery_percentage }} + ReportDegraded {{ battery_report_degraded }} + QueryStateFS false + +{% endif %} # # Host "localhost" @@ -102,9 +70,13 @@ LoadPlugin write_prometheus # Timeout "2" # -# -# Interface eth0 -# +{% if enable_connectivity == true %} + + {% for interface in connectivity_interfaces %} + Interface {{ interface }} + {% endfor %} + +{% endif %} # # CGroup "libvirt" @@ -113,16 +85,10 @@ LoadPlugin write_prometheus {% if enable_cpu == true %} - {% 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 }} {% endif %} @@ -172,10 +138,13 @@ LoadPlugin write_prometheus # # -# -# Host "127.0.0.1" -# Port "7634" -# +{% if enable_hddtemp == true %} + + Host "127.0.0.1" + Port "7634" + # TranslateDevicename true + +{% endif %} # # ReportPerNodeHP true @@ -198,10 +167,11 @@ LoadPlugin write_prometheus {% endif %} -# -# Device "/dev/md0" -# IgnoreSelected false -# +{% if enable_md == true %} + + Device "{{ md_device }}" + +{% endif %} {% if enable_memory == true %} @@ -250,7 +220,7 @@ LoadPlugin write_prometheus # IgnoreSelected false # -{% if enable_influx %} +{% if influx_host != "" %} Server "{{ influx_host }}" "{{ influx_port }}" @@ -545,11 +515,10 @@ LoadPlugin write_prometheus {% endif %} -{% if enable_prometheus == true %} +{% if prometheus_port != "" %} Port "{{ prometheus_port }}" - {% endif %} # @@ -580,6 +549,8 @@ LoadPlugin write_prometheus # PersistentNotification false # -# -# Verbose false -# +{% if enable_vmem == true %} + + Verbose {{ vmem_verbose }} + +{% endif %}