Defined Type: monitoring::graphite_threshold

Defined in:
modules/monitoring/manifests/graphite_threshold.pp

Overview

Parameters:

  • description (String[1])
  • metric (String[1])
  • warning (Numeric)
  • critical (Numeric)
  • dashboard_links (Array[Monitoring::Graphite::Url])
  • notes_link (Stdlib::HTTPUrl)
  • series (Boolean) (defaults to: false)
  • from (Monitoring::Graphite::Period) (defaults to: '10min')
  • until (Monitoring::Graphite::Period) (defaults to: '0min')
  • percentage (Numeric) (defaults to: 1)
  • under (Boolean) (defaults to: false)
  • graphite_url (Stdlib::HTTPUrl) (defaults to: 'https://graphite.wikimedia.org')
  • timeout (Integer[1,60]) (defaults to: 10)
  • host (Stdlib::Host) (defaults to: $::hostname)
  • retries (Integer[1,10]) (defaults to: 3)
  • group (Optional[String[1]]) (defaults to: undef)
  • ensure (String[1]) (defaults to: present)
  • nagios_critical (Boolean) (defaults to: false)
  • passive (Boolean) (defaults to: false)
  • freshness (Integer[1]) (defaults to: 36000)
  • check_interval (Integer[1]) (defaults to: 1)
  • retry_interval (Integer[1]) (defaults to: 1)
  • contact_group (String) (defaults to: 'admins')


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,
    }
}