Puppet Class: nagios::check::mongodb

Defined in:
manifests/check/mongodb.pp

Overview

Parameters:

  • ensure (Any) (defaults to: undef)
  • package (Any) (defaults to: 'python-pymongo')
  • args (Any) (defaults to: '')
  • user (Any) (defaults to: undef)
  • pass (Any) (defaults to: undef)
  • database (Any) (defaults to: undef)
  • collection (Any) (defaults to: undef)
  • modes_enabled (Any) (defaults to: [])
  • modes_disabled (Any) (defaults to: [])
  • v2 (Any) (defaults to: true)
  • mmapv1 (Any) (defaults to: true)
  • replication (Any) (defaults to: true)
  • sharding (Any) (defaults to: true)
  • arbiter (Any) (defaults to: false)
  • args_asserts (Any) (defaults to: '')
  • args_chunks_balance (Any) (defaults to: '')
  • args_collection_indexes (Any) (defaults to: '')
  • args_collections (Any) (defaults to: '')
  • args_collection_size (Any) (defaults to: '')
  • args_collection_state (Any) (defaults to: '')
  • args_collection_storageSize (Any) (defaults to: '')
  • args_connect (Any) (defaults to: '')
  • args_connections (Any) (defaults to: '')
  • args_connect_primary (Any) (defaults to: '')
  • args_current_lock (Any) (defaults to: '')
  • args_database_indexes (Any) (defaults to: '')
  • args_databases (Any) (defaults to: '')
  • args_database_size (Any) (defaults to: '')
  • args_flushing (Any) (defaults to: '')
  • args_index_miss_ratio (Any) (defaults to: '')
  • args_journal_commits_in_wl (Any) (defaults to: '')
  • args_journaled (Any) (defaults to: '')
  • args_last_flush_time (Any) (defaults to: '')
  • args_lock (Any) (defaults to: '')
  • args_memory (Any) (defaults to: '')
  • args_memory_mapped (Any) (defaults to: '')
  • args_opcounters (Any) (defaults to: '')
  • args_oplog (Any) (defaults to: '')
  • args_page_faults (Any) (defaults to: '')
  • args_queries_per_second (Any) (defaults to: '')
  • args_queues (Any) (defaults to: '')
  • args_replica_primary (Any) (defaults to: '')
  • args_replication_lag (Any) (defaults to: '')
  • args_replication_lag_percent (Any) (defaults to: '')
  • args_replset_quorum (Any) (defaults to: '')
  • args_replset_state (Any) (defaults to: '')
  • args_row_count (Any) (defaults to: '')
  • args_write_data_files (Any) (defaults to: '')
  • check_title (Any) (defaults to: $::nagios::client::host_name)
  • servicegroups (Any) (defaults to: 'mongodb')
  • check_period (Any) (defaults to: $::nagios::client::service_check_period)
  • contact_groups (Any) (defaults to: $::nagios::client::service_contact_groups)
  • first_notification_delay (Any) (defaults to: $::nagios::client::service_first_notification_delay)
  • max_check_attempts (Any) (defaults to: $::nagios::client::service_max_check_attempts)
  • notification_period (Any) (defaults to: $::nagios::client::service_notification_period)
  • use (Any) (defaults to: $::nagios::client::service_use)


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
54
55
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
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
# File 'manifests/check/mongodb.pp', line 1

class nagios::check::mongodb (
  $ensure                       = undef,
  $package                      = 'python-pymongo',
  # common args for all modes 'as-is' for the check script
  $args                         = '',
  # common args for all modes as individual parameters
  $user                         = undef,
  $pass                         = undef,
  $database                     = undef,
  $collection                   = undef,
  # modes selectively enabled and/or disabled
  $modes_enabled                = [],
  $modes_disabled               = [],
  # groups of modes selectively enabled or disabled
  $v2                           = true,
  $mmapv1                       = true,
  $replication                  = true,
  $sharding                     = true,
  # special, disable auth and modes
  $arbiter                      = false,
  # Modes
  $args_asserts                 = '',
  $args_chunks_balance          = '',
  $args_collection_indexes      = '',
  $args_collections             = '',
  $args_collection_size         = '',
  $args_collection_state        = '',
  $args_collection_storageSize  = '',
  $args_connect                 = '',
  $args_connections             = '',
  $args_connect_primary         = '',
  $args_current_lock            = '',
  $args_database_indexes        = '',
  $args_databases               = '',
  $args_database_size           = '',
  $args_flushing                = '',
  $args_index_miss_ratio        = '',
  $args_journal_commits_in_wl   = '',
  $args_journaled               = '',
  $args_last_flush_time         = '',
  $args_lock                    = '',
  $args_memory                  = '',
  $args_memory_mapped           = '',
  $args_opcounters              = '',
  $args_oplog                   = '',
  $args_page_faults             = '',
  $args_queries_per_second      = '',
  $args_queues                  = '',
  $args_replica_primary         = '',
  $args_replication_lag         = '',
  $args_replication_lag_percent = '',
  $args_replset_quorum          = '',
  $args_replset_state           = '',
  $args_row_count               = '',
  $args_write_data_files        = '',
  # service
  $check_title              = $::nagios::client::host_name,
  $servicegroups            = 'mongodb',
  $check_period             = $::nagios::client::service_check_period,
  $contact_groups           = $::nagios::client::service_contact_groups,
  $first_notification_delay = $::nagios::client::service_first_notification_delay,
  $max_check_attempts       = $::nagios::client::service_max_check_attempts,
  $notification_period      = $::nagios::client::service_notification_period,
  $use                      = $::nagios::client::service_use,
) {

  nagios::client::nrpe_plugin { 'check_mongodb':
    ensure  => $ensure,
    package => $package,
  }

  # Set options from parameters unless already set inside args
  if $args !~ /-u/ and $user != undef and $arbiter != true {
    $arg_u = "-u ${user} "
  } else {
    $arg_u = ''
  }
  if $args !~ /-p/ and $pass != undef and $arbiter != true {
    $arg_p = "-p ${pass} "
  } else {
    $arg_p = ''
  }
  if $args !~ /-d/ and $database != undef {
    $arg_d = "-d ${database} "
  } else {
    $arg_d = ''
  }
  if $args !~ /-c/ and $collection != undef {
    $arg_c = "-c ${collection} "
  } else {
    $arg_c = ''
  }
  $globalargs = strip("-D ${arg_u}${arg_p}${arg_d}${arg_c}${args}")

  $modes_base = [
    'asserts',
    'connect',
    'connections',
    'connect_primary',
    'current_lock',
    'memory',
    'memory_mapped',
    'opcounters',
    'page_faults',
    'queries_per_second',
    'queues',
  ]
  $modes_v2 = [
    'lock',
  ]
  $modes_mmapv1 = [
    'flushing',              # mmapv1 only
    'index_miss_ratio',      # mmapv1 only
    'journal_commits_in_wl', # mmapv1 only
    'journaled',             # mmapv1 only
    'last_flush_time',       # mmapv1 only
    'write_data_files',      # mmapv1 only
  ]
  $modes_replication = [
    'oplog',
    'replica_primary',
    'replication_lag',
    'replication_lag_percent',
    'replset_quorum',
    'replset_state',
  ]
  $modes_sharding = [
    'chunks_balance',
  ]

  # FIXME : It would make sense to be able to monitor multiple databases and
  # collections per node, though it's going to make everything more complicated
  $modes_database = [
    'database_indexes',
    'databases',
    'database_size',
  ]
  $modes_collection = [
    'collection_indexes',
    'collections',
    'collection_size',
    'collection_state',
    'collection_storageSize',
    'row_count',
  ]

  if $v2 != false {
    $modes_enabled_v2 = $modes_v2
  } else {
    $modes_enabled_v2 = []
  }
  if $mmapv1 != false {
    $modes_enabled_mmapv1 = $modes_mmapv1
  } else {
    $modes_enabled_mmapv1 = []
  }
  if $replication != false {
    $modes_enabled_replication = $modes_replication
  } else {
    $modes_enabled_replication = []
  }
  if $sharding != false {
    $modes_enabled_sharding = $modes_sharding
  } else {
    $modes_enabled_sharding = []
  }
  if $database != undef {
    $modes_enabled_database = $modes_database
  } else {
    $modes_enabled_database = []
  }
  if $collection != undef {
    $modes_enabled_collection = $modes_collection
  } else {
    $modes_enabled_collection = []
  }

  # Modes-specific definition
  $modes = $modes_base
         + $modes_enabled_v2
         + $modes_enabled_mmapv1
         + $modes_enabled_replication
         + $modes_enabled_sharding
         + $modes_enabled_database
         + $modes_enabled_collection

  # An arbiter has no data, so remove all checks which are *never* relevant
  $modes_arbiter = [
    'asserts',
    'connect',
    'connect_primary',
    'connections',
    'current_lock',
    'memory',
    'memory_mapped',
    'opcounters',
    'page_faults',
    'queues',
    'replset_quorum',
    'replset_state',
  ]
  if $arbiter == true {
    $modes_final = intersection($modes,$modes_arbiter)
  } else {
    $modes_final = $modes
  }

  nagios::check::mongodb::mode { $modes_final:
    ensure                   => $ensure,
    globalargs               => $globalargs,
    modes_enabled            => $modes_enabled,
    modes_disabled           => $modes_disabled,
    # service
    check_title              => $check_title,
    servicegroups            => $servicegroups,
    check_period             => $check_period,
    contact_groups           => $contact_groups,
    first_notification_delay => $first_notification_delay,
    max_check_attempts       => $max_check_attempts,
    notification_period      => $notification_period,
    use                      => $use,
  }

}