monitor_client.yml 1.64 KB
Newer Older
tec's avatar
tec committed
1 2 3 4 5
---
- hosts: uccservers
  become: true
  become_user: root
  remote_user: root
tec's avatar
tec committed
6
  roles:
7
      - role: cloudalchemy.node-exporter
8 9 10 11
  pre_tasks:
    - name: Ensure cron present (Debian)
      apt: name=cron state=present
      when: ansible_os_family == 'Debian'
12
  tasks:
13
    - name: Add simple logging collection scripts
14 15 16
      template:
        src: numeric_log.j2
        dest: '/usr/local/bin/ucc_node_{{ item.name }}.sh'
17
        owner: root
18
        mode: 0755
19
      loop: "{{ shell_logs }}"
20 21 22 23
    - name: Remove old collection scripts 1
      file: path='/usr/local/bin/ucc_node_current_users_gauge' state=absent
    - name: Remove old collection scripts 2
      file: path='/usr/local/bin/ucc_node_getent_passwd_count' state=absent
Alfred Burgess's avatar
Alfred Burgess committed
24
    - name: Remove old collection scripts 3
25
      file: path='/usr/local/bin/ucc_node_getent_passwd_users.sh' state=absent
Alfred Burgess's avatar
Alfred Burgess committed
26 27 28 29 30
    - name: Remove old cronjob 1
      file: path='/etc/cron.d/node_current_users' state=absent
    - name: Remove old cronjob 2
      file: path='/etc/cron.d/node_getent_passwd_users' state=absent

31
    - name: Add cron jobs for simple logging
32
      cron:
33
        name: "{{ item.description  }}"
34 35
        minute: "*/5"
        user: root
36 37 38 39 40 41 42 43 44 45 46
        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"
47