13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
|
# File 'modules/profile/manifests/analytics/client/limits.pp', line 13
class profile::analytics::client::limits {
# From the systemd docs for CPUQuota:
# 'Use values > 100% for allotting CPU time on more than one CPU'
$cpu_val = ($facts['processors']['count'] * 95)
$cpu_quota = floor($cpu_val)
# Cap the maximum amount of CPU % for all the combined total of all processes
# launched by users at 95%
systemd::override {'total-user-resources.conf':
content => template('profile/analytics/client/limits/total-user-resource-control.conf.erb'),
unit => 'user.slice'
}
systemd::override {'individual-user-resources.conf':
content => template('profile/analytics/client/limits/individual-user-resource-control.conf.erb'),
# the '-' (hyphen) on the below is significant; see
# https://www.freedesktop.org/software/systemd/man/latest/
# user@.service.html#Controlling%20resources%20for%20logged-in%20users
# for more details
unit => 'user-.slice'
}
systemd::override {'guarantee-system-resource-minimum.conf':
content => template('profile/analytics/client/limits/guarantee-system-resource-minimum.conf.erb'),
unit => 'system.slice'
}
# By default the cron.service unit runs under the system.slice.
# This means that all crontab's processes escape the limits imposed
# by the user.slice, so an explicit override is needed.
$cron_slice = 'user.slice'
systemd::unit { 'cron':
ensure => present,
content => template('profile/analytics/client/limits/cron-override.systemd.erb'),
restart => false,
override => true,
}
}
|