Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
tec
AnsibleMonitoring
Commits
b8014c0b
Commit
b8014c0b
authored
Jan 14, 2020
by
tec
Browse files
Switch to general model, monitor logged in user count
parent
d33ddc89
Changes
1
Hide whitespace changes
Inline
Side-by-side
monitor_client.yml
View file @
b8014c0b
...
...
@@ -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
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment