-
Notifications
You must be signed in to change notification settings - Fork 28
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
(SUP-2192) Migrate from cron to systemd timers
This commit replaces cron entries with systemd services and timers. It also fixes the existing tests and adds a few to the pe_metric spec tests: * When systemd is not the init provider * Collecting and not collecting Puppet server metrics * Customizing the collection interval
- Loading branch information
Showing
29 changed files
with
263 additions
and
92 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,60 @@ | ||
# Create systemd units for collecting a given metric | ||
define puppet_metrics_collector::collect ( | ||
String $metrics_type = $title, | ||
String $metrics_command = undef, | ||
String $tidy_command = undef, | ||
String $metric_ensure = 'present', | ||
String $minute = '5', | ||
) { | ||
|
||
$service_ensure = $metric_ensure ? { | ||
'present' => running, | ||
'absent' => stopped, | ||
} | ||
|
||
$service_enable = $metric_ensure ? { | ||
'present' => true, | ||
'absent' => false, | ||
} | ||
|
||
file {"/etc/systemd/system/${metrics_type}-metrics.service": | ||
ensure => $metric_ensure, | ||
content => epp('puppet_metrics_collector/service.epp', | ||
{ 'service' => $metrics_type, 'metrics_command' => $metrics_command } | ||
), | ||
} | ||
file {"/etc/systemd/system/${metrics_type}-metrics.timer": | ||
ensure => $metric_ensure, | ||
content => epp('puppet_metrics_collector/timer.epp', | ||
{ 'service' => $metrics_type, 'minute' => $minute }, | ||
), | ||
} | ||
|
||
file {"/etc/systemd/system/${metrics_type}-tidy.service": | ||
ensure => $metric_ensure, | ||
content => epp('puppet_metrics_collector/tidy.epp', | ||
{ 'service' => $metrics_type, 'tidy_command' => $tidy_command } | ||
), | ||
} | ||
file {"/etc/systemd/system/${metrics_type}-tidy.timer": | ||
ensure => $metric_ensure, | ||
content => epp('puppet_metrics_collector/tidy_timer.epp', | ||
{ 'service' => $metrics_type } | ||
), | ||
} | ||
|
||
service { "${metrics_type}-metrics.service": | ||
} | ||
service { "${metrics_type}-metrics.timer": | ||
ensure => $service_ensure, | ||
enable => $service_enable, | ||
subscribe => File["/etc/systemd/system/${metrics_type}-metrics.timer"], | ||
} | ||
|
||
service { "${metrics_type}-tidy.service": } | ||
service { "${metrics_type}-tidy.timer": | ||
ensure => $service_ensure, | ||
enable => $service_enable, | ||
subscribe => File["/etc/systemd/system/${metrics_type}-tidy.timer"], | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.