-
Notifications
You must be signed in to change notification settings - Fork 28
/
Copy pathvmware.pp
53 lines (47 loc) · 1.86 KB
/
vmware.pp
1
2
3
4
5
6
7
8
9
10
11
12
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
48
49
50
51
52
53
# Collect VMware metrics
#
# This class manages a cron job that collects metrics from:
#
# vmware-toolbox-cmd stat
#
# This class should not be included directly.
# Include {puppet_metrics_collector::system} instead.
#
# @private
class puppet_metrics_collector::system::vmware (
String $metrics_ensure = $puppet_metrics_collector::system::system_metrics_ensure,
Integer $collection_frequency = $puppet_metrics_collector::system::collection_frequency,
Integer $retention_days = $puppet_metrics_collector::system::retention_days,
) {
$metrics_output_dir = "${puppet_metrics_collector::system::output_dir}/vmware"
$metrics_output_dir_ensure = $metrics_ensure ? {
'present' => directory,
'absent' => absent,
}
file { $metrics_output_dir:
ensure => $metrics_output_dir_ensure,
# Allow directories to be removed.
force => true,
}
$metrics_command = ["${puppet_metrics_collector::system::scripts_dir}/vmware_metrics",
'--output_dir', $metrics_output_dir,
'> /dev/null'].join(' ')
$tidy_command = "${puppet_metrics_collector::system::scripts_dir}/metrics_tidy -d ${metrics_output_dir} -r ${retention_days}"
if ($metrics_ensure == 'present') and (!$facts.dig('puppet_metrics_collector', 'have_vmware_tools')) {
notify { 'vmware_tools_warning':
message => 'VMware metrics collection requires vmware-toolbox-cmd to be on the PATH',
loglevel => warning,
}
}
puppet_metrics_collector::collect {'vmware':
metrics_command => $metrics_command,
tidy_command => $tidy_command,
metric_ensure => $metrics_ensure,
minute => String($collection_frequency),
notify => Exec['puppet_metrics_collector_system_daemon_reload'],
}
# Legacy cleanup
cron { ['vmware_metrics_tidy', 'vmware_metrics_collection']:
ensure => absent
}
}