Commit b8014c0b authored by tec's avatar tec

Switch to general model, monitor logged in user count

parent d33ddc89
......@@ -5,26 +5,32 @@
remote_user: root
roles:
- role: cloudalchemy.node-exporter
pre_tasks:
- name: Ensure cron present (Debian)
apt: name=cron state=present
when: ansible_os_family == 'Debian'
tasks:
- name: Add getent passwd count monitor file
copy:
dest: '/usr/local/bin/getent-passwd-count.sh'
- name: Add simple logging files
template:
src: numeric_log.j2
dest: '/usr/local/bin/ucc_node_{{ item.name }}.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
loop: "{{ shell_logs }}"
- name: Add cron jobs for simple logging
cron:
name: Expose getent user count
name: "{{ item.description }}"
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
job: "/usr/local/bin/ucc_node_{{item.name}}.sh > /var/lib/node_exporter/{{item.name}}.prom"
cron_file: "node_{{item.name}}"
loop: "{{ shell_logs }}"
vars:
shell_logs:
- name: getent_passwd_count
description: Expose getent user count
cmd: "getent passwd | wc -l"
- name: current_users_gauge
description: Expose total (unique) users currently logged in
cmd: "users | sed 's/ /\\n/g' | uniq | wc -l"
\ No newline at end of file
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