56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
|
# File 'modules/monitoring/manifests/graphite_threshold.pp', line 56
define monitoring::graphite_threshold(
String[1] $description,
String[1] $metric,
Numeric $warning,
Numeric $critical,
Array[Monitoring::Graphite::Url] $dashboard_links,
Stdlib::HTTPUrl $notes_link,
Boolean $series = false,
Monitoring::Graphite::Period $from = '10min',
Monitoring::Graphite::Period $until = '0min',
Numeric $percentage = 1,
Boolean $under = false,
Stdlib::HTTPUrl $graphite_url = 'https://graphite.wikimedia.org',
Integer[1,60] $timeout = 10,
Stdlib::Host $host = $::hostname,
Integer[1,10] $retries = 3,
Optional[String[1]] $group = undef,
String[1] $ensure = present,
Boolean $nagios_critical = false,
Boolean $passive = false,
Integer[1] $freshness = 36000,
Integer[1] $check_interval = 1,
Integer[1] $retry_interval = 1,
String $contact_group = 'admins',
) {
# notes link always has to com first to ensure the correct icon is used in icinga
# we start with `[]` so puppet knows we want a array
$links = [] + $notes_link + $dashboard_links
$notes_urls = $links.reduce('') |$urls, $link| {
"${urls}'${link}' "
}.strip
# checkcommands.cfg's check_graphite_threshold command has
# many positional arguments that
# are passed to the check_graphite script:
# $ARG1$ -U url
# $ARG2$ -T timeout
# $ARG3$ the metric to monitor
# $ARG4$ -W warning threshold
# $ARG5$ -C critical threshold
# $ARG6$ --from start sampling date (negative relative time from now)
# $ARG7$ --until end sampling date (negative relative time from now)
# $ARG8$ --perc percentage of exceeding datapoints
# $ARG9$ --over or --under
$modifier = $under ? {
true => '--under',
default => '--over'
}
if $metric =~ /'/ {
fail("single quotes will be stripped from graphite metric ${metric}, consider using double quotes")
}
$command = $series ? {
true => 'check_graphite_series_threshold',
default => 'check_graphite_threshold'
}
monitoring::service { $title:
ensure => $ensure,
description => $description,
check_command => "${command}!${graphite_url}!${timeout}!${metric}!${warning}!${critical}!${from}!${until}!${percentage}!${modifier}",
retries => $retries,
group => $group,
critical => $nagios_critical,
passive => $passive,
freshness => $freshness,
check_interval => $check_interval,
retry_interval => $retry_interval,
contact_group => $contact_group,
notes_url => $notes_urls,
}
}
|