Commit 41a061af authored by tec's avatar tec

Add MWE custom logging with node exporter collector (getent passwd count)

parent b64f8828
......@@ -4,6 +4,7 @@
become_user: root
remote_user: root
pre_tasks:
# because deb10 packages version works
- name: Have prometheus-node-exporter
apt:
name: prometheus-node-exporter
......@@ -14,3 +15,26 @@
manager: auto
roles:
- { role: cloudalchemy.node-exporter, when: "ansible_facts.packages['prometheus-node-exporter'] is not defined" }
tasks:
- name: Add getent passwd count monitor file
copy:
dest: '/usr/local/bin/getent-passwd-count.sh'
owner: root
mode: 755
content: |
#!/bin/bash
#
# Expose getent user count
#
# Usage: add this to crontab:
# */5 * * * * /usr/local/bin/getent-passwd-count.sh | sponge /var/lib/node_exporter/getent_passwd_count.prom
echo "# HELP node_getent_passwd_count number of users known"
echo "# TYPE node_getent_passwd_count gauge"
echo "node_getent_passwd_count $(getent passwd | wc -l)"
- name: Add getent passwd count monitor cron job
cron:
name: Expose getent user count
minute: "*/5"
user: root
job: "/usr/local/bin/getent-passwd-count.sh > /var/lib/node_exporter/getent_passwd_count.prom"
cron_file: getent-passwd-count
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment