r/collectd: Enable unixsock plugin

The *unixsock* plugin for *collectd* provides a socket-based interface
that other software can use to communicate with *collectd*.  Notably,
this can be used to publish custom values, query existing values, and
flush caches.

The socket is created at `/run/collectd/socket`.  The `/run/collectd`
directory is managed by systemd; it will be created automatically when
the service starts and cleaned up when it stops.
ntfy
Dustin 2021-10-30 16:44:21 -05:00
parent 98401b3c1e
commit 32d1e0ff6f
5 changed files with 51 additions and 0 deletions

View File

@ -6,3 +6,5 @@ collectd_network_listen: []
collectd_disable_plugins: [] collectd_disable_plugins: []
collectd_df: {} collectd_df: {}
collectd_load_unixsock_plugin: true

View File

@ -0,0 +1,2 @@
[Service]
RuntimeDirectory=collectd

View File

@ -1,3 +1,8 @@
- name: reload systemd
systemd:
daemon_reload: true
changed_when: true
- name: restart collectd - name: restart collectd
service: service:
name: collectd name: collectd

View File

@ -23,6 +23,16 @@
tags: tags:
- collectd-config - collectd-config
- name: ensure collectd unixsock plugin is configured
template:
src: collectd-unixsock.conf.j2
dest: /etc/collectd.d/unixsock.conf
mode: 'u=rw,go=r'
notify: restart collectd
tags:
- collectd-config
- collectd-unixsock
- name: ensure collectd network plugin is configured - name: ensure collectd network plugin is configured
template: template:
src: collectd-network.conf.j2 src: collectd-network.conf.j2
@ -44,6 +54,20 @@
- collectd-config - collectd-config
- collectd-processes - collectd-processes
- name: ensure collectd systemd unit extension directory exists
file:
path: /etc/systemd/system/collectd.service.d
mode: 'u=rwx,go=rx'
state: directory
- name: ensure collectd.service runtime directory is configured
copy:
src: collectd-runtime-dir.conf
dest: /etc/systemd/system/collectd.service.d/runtime-dir.conf
mode: 'u=rw,go=r'
notify:
- reload systemd
- restart collectd
- name: ensure collectd starts at boot - name: ensure collectd starts at boot
service: service:
name: collectd name: collectd

View File

@ -0,0 +1,18 @@
{% if collectd_load_unixsock_plugin %}
LoadPlugin unixsock
{% endif %}
<Plugin unixsock>
SocketFile "/run/collectd/socket"
{% if collectd_unixsock_group|d %}
SocketGroup "{{ collectd_unixsock_group }}"
{% endif %}
{% if collectd_unixsock_perms|d %}
SocketPerms "{{ collectd_unixsock_perms }}"
{% endif %}
{% if collectd_unixsock_delete|d is true %}
DeleteSocket true
{% elif collectd_unix_sock_delete|d is false%}
DeleteSocket false
{% endif %}
</Plugin>