From ceb028ca38989af8194b772eb48bd3856a03a927 Mon Sep 17 00:00:00 2001 From: "tommaso.piccioli" Date: Wed, 16 Dec 2015 14:56:14 +0100 Subject: [PATCH] new mongodb-org 3. --- mongodb-org-3/defaults/main.yml | 25 + mongodb-org-3/files/mongodb.py | 496 ++++++++++++++++++ mongodb-org-3/handlers/main.yml | 7 + mongodb-org-3/tasks/ganglia-plugin.yml | 16 + mongodb-org-3/tasks/main.yml | 4 + mongodb-org-3/tasks/mongodb.yml | 54 ++ .../templates/mongo_log_rotate.sh.j2 | 14 + mongodb-org-3/templates/mongod-2.6.conf.j2 | 82 +++ mongodb-org-3/templates/mongod-3.0.conf.j2 | 44 ++ mongodb-org-3/templates/mongodb-2.4.conf.j2 | 87 +++ mongodb-org-3/templates/mongodb.pyconf.j2 | 109 ++++ 11 files changed, 938 insertions(+) create mode 100644 mongodb-org-3/defaults/main.yml create mode 100755 mongodb-org-3/files/mongodb.py create mode 100644 mongodb-org-3/handlers/main.yml create mode 100644 mongodb-org-3/tasks/ganglia-plugin.yml create mode 100644 mongodb-org-3/tasks/main.yml create mode 100644 mongodb-org-3/tasks/mongodb.yml create mode 100644 mongodb-org-3/templates/mongo_log_rotate.sh.j2 create mode 100644 mongodb-org-3/templates/mongod-2.6.conf.j2 create mode 100644 mongodb-org-3/templates/mongod-3.0.conf.j2 create mode 100644 mongodb-org-3/templates/mongodb-2.4.conf.j2 create mode 100644 mongodb-org-3/templates/mongodb.pyconf.j2 diff --git a/mongodb-org-3/defaults/main.yml b/mongodb-org-3/defaults/main.yml new file mode 100644 index 00000000..eed15b2b --- /dev/null +++ b/mongodb-org-3/defaults/main.yml @@ -0,0 +1,25 @@ +--- +mongodb_install_from_external_repo: True +mongodb_install_packages: True +mongodb_install_conf: True +# Set to 'latest' if you want to get the latest available package +mongodb_pkg_state: installed +mongodb_start_server: 'no' +mongodb_tcp_port: 27017 +mongodb_http_interface: False +mongodb_http_port: 28017 +mongodb_user: mongodb +mongodb_group: mongodb +mongodb_logdir: /var/log/mongodb +mongodb_log_file: mongodb.log +mongodb_logpath: '{{ mongodb_logdir }}/{{ mongodb_log_file }}' +mongodb_dbpath: /var/lib/mongodb +mongodb_log_retain_days: 7 +mongodb_directoryperdb: False +mongodb_allowed_hosts: + - 127.0.0.1/8 + - '{{ ansible_default_ipv4.address }}/32' + +mongodb_cluster_enabled: False +mongodb_replicaset: storagedev +mongodb_replica_keyfile: '{{ mongodb_dbpath }}/replica_keyfile' diff --git a/mongodb-org-3/files/mongodb.py b/mongodb-org-3/files/mongodb.py new file mode 100755 index 00000000..7ef34bed --- /dev/null +++ b/mongodb-org-3/files/mongodb.py @@ -0,0 +1,496 @@ +#!/usr/bin/env python +# -*- coding: utf-8 -*- +# +# MongoDB gmond module for Ganglia +# +# Copyright (C) 2011 by Michael T. Conigliaro . +# All rights reserved. +# +# Permission is hereby granted, free of charge, to any person obtaining a copy +# of this software and associated documentation files (the "Software"), to deal +# in the Software without restriction, including without limitation the rights +# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +# copies of the Software, and to permit persons to whom the Software is +# furnished to do so, subject to the following conditions: +# +# The above copyright notice and this permission notice shall be included in +# all copies or substantial portions of the Software. +# +# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +# THE SOFTWARE. +# + +import json +import os +import re +import socket +import string +import time +import copy + +NAME_PREFIX = 'mongodb_' +PARAMS = { + 'server_status' : '~/mongodb-osx-x86_64-1.8.1/bin/mongo --host mongodb04.example.com --port 27018 --quiet --eval "printjson(db.serverStatus())"', + 'rs_status' : '~/mongodb-osx-x86_64-1.8.1/bin/mongo --host mongodb04.example.com --port 27018 --quiet --eval "printjson(rs.status())"' +} +METRICS = { + 'time' : 0, + 'data' : {} +} +LAST_METRICS = copy.deepcopy(METRICS) +METRICS_CACHE_TTL = 3 + + +def flatten(d, pre = '', sep = '_'): + """Flatten a dict (i.e. dict['a']['b']['c'] => dict['a_b_c'])""" + + new_d = {} + for k,v in d.items(): + if type(v) == dict: + new_d.update(flatten(d[k], '%s%s%s' % (pre, k, sep))) + else: + new_d['%s%s' % (pre, k)] = v + return new_d + + +def get_metrics(): + """Return all metrics""" + + global METRICS, LAST_METRICS + + if (time.time() - METRICS['time']) > METRICS_CACHE_TTL: + + metrics = {} + for status_type in PARAMS.keys(): + + # get raw metric data + io = os.popen(PARAMS[status_type]) + + # clean up + metrics_str = ''.join(io.readlines()).strip() # convert to string + metrics_str = re.sub('\w+\((.*)\)', r"\1", metrics_str) # remove functions + + # convert to flattened dict + try: + if status_type == 'server_status': + metrics.update(flatten(json.loads(metrics_str))) + else: + metrics.update(flatten(json.loads(metrics_str), pre='%s_' % status_type)) + except ValueError: + metrics = {} + + # update cache + LAST_METRICS = copy.deepcopy(METRICS) + METRICS = { + 'time': time.time(), + 'data': metrics + } + + return [METRICS, LAST_METRICS] + + +def get_value(name): + """Return a value for the requested metric""" + + # get metrics + metrics = get_metrics()[0] + + # get value + name = name[len(NAME_PREFIX):] # remove prefix from name + try: + result = metrics['data'][name] + except StandardError: + result = 0 + + return result + + +def get_rate(name): + """Return change over time for the requested metric""" + + # get metrics + [curr_metrics, last_metrics] = get_metrics() + + # get rate + name = name[len(NAME_PREFIX):] # remove prefix from name + + try: + rate = float(curr_metrics['data'][name] - last_metrics['data'][name]) / \ + float(curr_metrics['time'] - last_metrics['time']) + if rate < 0: + rate = float(0) + except StandardError: + rate = float(0) + + return rate + + +def get_opcounter_rate(name): + """Return change over time for an opcounter metric""" + + master_rate = get_rate(name) + repl_rate = get_rate(name.replace('opcounters_', 'opcountersRepl_')) + + return master_rate + repl_rate + + +def get_globalLock_ratio(name): + """Return the global lock ratio""" + + try: + result = get_rate(NAME_PREFIX + 'globalLock_lockTime') / \ + get_rate(NAME_PREFIX + 'globalLock_totalTime') * 100 + except ZeroDivisionError: + result = 0 + + return result + + +def get_indexCounters_btree_miss_ratio(name): + """Return the btree miss ratio""" + + try: + result = get_rate(NAME_PREFIX + 'indexCounters_btree_misses') / \ + get_rate(NAME_PREFIX + 'indexCounters_btree_accesses') * 100 + except ZeroDivisionError: + result = 0 + + return result + + +def get_connections_current_ratio(name): + """Return the percentage of connections used""" + + try: + result = float(get_value(NAME_PREFIX + 'connections_current')) / \ + float(get_value(NAME_PREFIX + 'connections_available')) * 100 + except ZeroDivisionError: + result = 0 + + return result + + +def get_slave_delay(name): + """Return the replica set slave delay""" + + # get metrics + metrics = get_metrics()[0] + + # no point checking my optime if i'm not replicating + if 'rs_status_myState' not in metrics['data'] or metrics['data']['rs_status_myState'] != 2: + result = 0 + + # compare my optime with the master's + else: + master = {} + slave = {} + try: + for member in metrics['data']['rs_status_members']: + if member['state'] == 1: + master = member + if member['name'].split(':')[0] == socket.getfqdn(): + slave = member + result = max(0, master['optime']['t'] - slave['optime']['t']) / 1000 + except KeyError: + result = 0 + + return result + + +def get_asserts_total_rate(name): + """Return the total number of asserts per second""" + + return float(reduce(lambda memo,obj: memo + get_rate('%sasserts_%s' % (NAME_PREFIX, obj)), + ['regular', 'warning', 'msg', 'user', 'rollovers'], 0)) + + +def metric_init(lparams): + """Initialize metric descriptors""" + + global PARAMS + + # set parameters + for key in lparams: + PARAMS[key] = lparams[key] + + # define descriptors + time_max = 60 + groups = 'mongodb' + descriptors = [ + { + 'name': NAME_PREFIX + 'opcounters_insert', + 'call_back': get_opcounter_rate, + 'time_max': time_max, + 'value_type': 'float', + 'units': 'Inserts/Sec', + 'slope': 'both', + 'format': '%f', + 'description': 'Inserts', + 'groups': groups + }, + { + 'name': NAME_PREFIX + 'opcounters_query', + 'call_back': get_opcounter_rate, + 'time_max': time_max, + 'value_type': 'float', + 'units': 'Queries/Sec', + 'slope': 'both', + 'format': '%f', + 'description': 'Queries', + 'groups': groups + }, + { + 'name': NAME_PREFIX + 'opcounters_update', + 'call_back': get_opcounter_rate, + 'time_max': time_max, + 'value_type': 'float', + 'units': 'Updates/Sec', + 'slope': 'both', + 'format': '%f', + 'description': 'Updates', + 'groups': groups + }, + { + 'name': NAME_PREFIX + 'opcounters_delete', + 'call_back': get_opcounter_rate, + 'time_max': time_max, + 'value_type': 'float', + 'units': 'Deletes/Sec', + 'slope': 'both', + 'format': '%f', + 'description': 'Deletes', + 'groups': groups + }, + { + 'name': NAME_PREFIX + 'opcounters_getmore', + 'call_back': get_opcounter_rate, + 'time_max': time_max, + 'value_type': 'float', + 'units': 'Getmores/Sec', + 'slope': 'both', + 'format': '%f', + 'description': 'Getmores', + 'groups': groups + }, + { + 'name': NAME_PREFIX + 'opcounters_command', + 'call_back': get_opcounter_rate, + 'time_max': time_max, + 'value_type': 'float', + 'units': 'Commands/Sec', + 'slope': 'both', + 'format': '%f', + 'description': 'Commands', + 'groups': groups + }, + { + 'name': NAME_PREFIX + 'backgroundFlushing_flushes', + 'call_back': get_rate, + 'time_max': time_max, + 'value_type': 'float', + 'units': 'Flushes/Sec', + 'slope': 'both', + 'format': '%f', + 'description': 'Flushes', + 'groups': groups + }, + { + 'name': NAME_PREFIX + 'mem_mapped', + 'call_back': get_value, + 'time_max': time_max, + 'value_type': 'uint', + 'units': 'MB', + 'slope': 'both', + 'format': '%u', + 'description': 'Memory-mapped Data', + 'groups': groups + }, + { + 'name': NAME_PREFIX + 'mem_virtual', + 'call_back': get_value, + 'time_max': time_max, + 'value_type': 'uint', + 'units': 'MB', + 'slope': 'both', + 'format': '%u', + 'description': 'Process Virtual Size', + 'groups': groups + }, + { + 'name': NAME_PREFIX + 'mem_resident', + 'call_back': get_value, + 'time_max': time_max, + 'value_type': 'uint', + 'units': 'MB', + 'slope': 'both', + 'format': '%u', + 'description': 'Process Resident Size', + 'groups': groups + }, + { + 'name': NAME_PREFIX + 'extra_info_page_faults', + 'call_back': get_rate, + 'time_max': time_max, + 'value_type': 'float', + 'units': 'Faults/Sec', + 'slope': 'both', + 'format': '%f', + 'description': 'Page Faults', + 'groups': groups + }, + { + 'name': NAME_PREFIX + 'globalLock_ratio', + 'call_back': get_globalLock_ratio, + 'time_max': time_max, + 'value_type': 'float', + 'units': '%', + 'slope': 'both', + 'format': '%f', + 'description': 'Global Write Lock Ratio', + 'groups': groups + }, + { + 'name': NAME_PREFIX + 'indexCounters_btree_miss_ratio', + 'call_back': get_indexCounters_btree_miss_ratio, + 'time_max': time_max, + 'value_type': 'float', + 'units': '%', + 'slope': 'both', + 'format': '%f', + 'description': 'BTree Page Miss Ratio', + 'groups': groups + }, + { + 'name': NAME_PREFIX + 'globalLock_currentQueue_total', + 'call_back': get_value, + 'time_max': time_max, + 'value_type': 'uint', + 'units': 'Operations', + 'slope': 'both', + 'format': '%u', + 'description': 'Total Operations Waiting for Lock', + 'groups': groups + }, + { + 'name': NAME_PREFIX + 'globalLock_currentQueue_readers', + 'call_back': get_value, + 'time_max': time_max, + 'value_type': 'uint', + 'units': 'Operations', + 'slope': 'both', + 'format': '%u', + 'description': 'Readers Waiting for Lock', + 'groups': groups + }, + { + 'name': NAME_PREFIX + 'globalLock_currentQueue_writers', + 'call_back': get_value, + 'time_max': time_max, + 'value_type': 'uint', + 'units': 'Operations', + 'slope': 'both', + 'format': '%u', + 'description': 'Writers Waiting for Lock', + 'groups': groups + }, + { + 'name': NAME_PREFIX + 'globalLock_activeClients_total', + 'call_back': get_value, + 'time_max': time_max, + 'value_type': 'uint', + 'units': 'Clients', + 'slope': 'both', + 'format': '%u', + 'description': 'Total Active Clients', + 'groups': groups + }, + { + 'name': NAME_PREFIX + 'globalLock_activeClients_readers', + 'call_back': get_value, + 'time_max': time_max, + 'value_type': 'uint', + 'units': 'Clients', + 'slope': 'both', + 'format': '%u', + 'description': 'Active Readers', + 'groups': groups + }, + { + 'name': NAME_PREFIX + 'globalLock_activeClients_writers', + 'call_back': get_value, + 'time_max': time_max, + 'value_type': 'uint', + 'units': 'Clients', + 'slope': 'both', + 'format': '%u', + 'description': 'Active Writers', + 'groups': groups + }, + { + 'name': NAME_PREFIX + 'connections_current', + 'call_back': get_value, + 'time_max': time_max, + 'value_type': 'uint', + 'units': 'Connections', + 'slope': 'both', + 'format': '%u', + 'description': 'Open Connections', + 'groups': groups + }, + { + 'name': NAME_PREFIX + 'connections_current_ratio', + 'call_back': get_connections_current_ratio, + 'time_max': time_max, + 'value_type': 'float', + 'units': '%', + 'slope': 'both', + 'format': '%f', + 'description': 'Percentage of Connections Used', + 'groups': groups + }, + { + 'name': NAME_PREFIX + 'slave_delay', + 'call_back': get_slave_delay, + 'time_max': time_max, + 'value_type': 'uint', + 'units': 'Seconds', + 'slope': 'both', + 'format': '%u', + 'description': 'Replica Set Slave Delay', + 'groups': groups + }, + { + 'name': NAME_PREFIX + 'asserts_total', + 'call_back': get_asserts_total_rate, + 'time_max': time_max, + 'value_type': 'float', + 'units': 'Asserts/Sec', + 'slope': 'both', + 'format': '%f', + 'description': 'Asserts', + 'groups': groups + } + ] + + return descriptors + + +def metric_cleanup(): + """Cleanup""" + + pass + + +# the following code is for debugging and testing +if __name__ == '__main__': + descriptors = metric_init(PARAMS) + while True: + for d in descriptors: + print (('%s = %s') % (d['name'], d['format'])) % (d['call_back'](d['name'])) + print '' + time.sleep(METRICS_CACHE_TTL) diff --git a/mongodb-org-3/handlers/main.yml b/mongodb-org-3/handlers/main.yml new file mode 100644 index 00000000..fbd0ae7f --- /dev/null +++ b/mongodb-org-3/handlers/main.yml @@ -0,0 +1,7 @@ +--- +- name: Update apt cache + apt: update_cache=yes + ignore_errors: true + +- name: Restart mongod + service: name=mongod state=restarted diff --git a/mongodb-org-3/tasks/ganglia-plugin.yml b/mongodb-org-3/tasks/ganglia-plugin.yml new file mode 100644 index 00000000..ea86333f --- /dev/null +++ b/mongodb-org-3/tasks/ganglia-plugin.yml @@ -0,0 +1,16 @@ +--- +# +# The ganglia plugin comes from https://github.com/ganglia/gmond_python_modules +# +- name: Install the ganglia plugin for MongoDB + copy: src=mongodb.py dest=/usr/lib/ganglia/python_modules/mongodb.py owner=root group=root mode=0444 + when: ganglia_plugin + notify: Restart ganglia monitor + tags: [ 'ganglia', 'mongodb' ] + +- name: Distribute the ganglia (gmond) configuration for the MongoDB plugin + template: src=mongodb.pyconf.j2 dest=/etc/ganglia/conf.d/mongodb.pyconf owner=root group=root mode=0444 + when: ganglia_plugin + notify: Restart ganglia monitor + tags: [ 'ganglia', 'mongodb' ] + diff --git a/mongodb-org-3/tasks/main.yml b/mongodb-org-3/tasks/main.yml new file mode 100644 index 00000000..c3ad3de4 --- /dev/null +++ b/mongodb-org-3/tasks/main.yml @@ -0,0 +1,4 @@ +--- +- include: mongodb.yml +- include: ganglia-plugin.yml + when: ganglia_enabled diff --git a/mongodb-org-3/tasks/mongodb.yml b/mongodb-org-3/tasks/mongodb.yml new file mode 100644 index 00000000..d8809a12 --- /dev/null +++ b/mongodb-org-3/tasks/mongodb.yml @@ -0,0 +1,54 @@ +--- +- name: Install the mongodb apt key + #apt_key: id=7F0CEB10 state=present + raw: apt-key adv --keyserver hkp://keyserver.ubuntu.com:80 --recv 7F0CEB10 + when: mongodb_install_from_external_repo + tags: mongodb + +- name: Install the mongodb repository + copy: content="deb http://repo.mongodb.org/apt/ubuntu trusty/mongodb-org/3.0 multiverse" dest=/etc/apt/sources.list.d/mongodb-org-3.0.list owner=root group=root mode=044 + when: mongodb_install_from_external_repo + register: external_repo + tags: mongodb + +- name: Install the latest version of mongodb server + apt: pkg={{ item }} state={{ mongodb_pkg_state }} update_cache=yes + with_items: + - mongodb-org + - mongodb-org-mongos + - mongodb-org-server + - mongodb-org-shell + - mongodb-org-tools + when: + - mongodb_install_from_external_repo + - mongodb_install_packages + tags: mongodb + +- name: Create the mongodb log directory + file: dest={{ mongodb_logdir }} state=directory owner={{ mongodb_user }} group={{ mongodb_group }} mode=0755 + when: mongodb_install_conf + tags: mongodb + +- name: Create the mongodb db directory + file: dest={{ mongodb_dbpath }} state=directory owner={{ mongodb_user }} group={{ mongodb_group }} mode=0755 + when: mongodb_install_conf + tags: mongodb + +- name: Install the mongodb 3.0 configuration + template: src=mongod-3.0.conf.j2 dest=/etc/mongod.conf owner=root group=root mode=0444 + when: mongodb_install_conf + tags: mongodb + +- name: Install the cron job that manages log files rotation + template: src=mongo_log_rotate.sh.j2 dest=/etc/cron.daily/mongo_log_rotate owner=root group=root mode=0555 + tags: [ 'mongodb', 'mongo_logrotate' ] + +- name: Ensure mongodb is started + service: name=mongod state=started enabled=yes + when: ( mongodb_start_server is defined ) and ( mongodb_start_server == 'yes' ) and ( mongodb_install_conf ) + tags: mongodb + +- name: Ensure mongod is stopped and disabled + service: name=mongod state=stopped enabled=no + when: ( mongodb_start_server is defined ) and ( mongodb_start_server == 'no' ) and ( mongodb_install_conf ) + tags: mongodb diff --git a/mongodb-org-3/templates/mongo_log_rotate.sh.j2 b/mongodb-org-3/templates/mongo_log_rotate.sh.j2 new file mode 100644 index 00000000..7f5e494b --- /dev/null +++ b/mongodb-org-3/templates/mongo_log_rotate.sh.j2 @@ -0,0 +1,14 @@ +#!/bin/bash + +MONGO_PID_FILE={{ mongodb_dbpath }}/mongod.lock +LOG_RETAIN_DAYS={{ mongodb_log_retain_days }} +RETVAL= + +MONGO_PID=$( cat $MONGO_PID_FILE ) +# Tell mongo to rotate its log file +kill -SIGUSR1 $MONGO_PID + +RETVAL=$? + +# Remove the old log files +find {{ mongodb_logdir }} -name "{{ mongodb_log_file }}.*" -ctime +$LOG_RETAIN_DAYS -exec rm -f {} \; diff --git a/mongodb-org-3/templates/mongod-2.6.conf.j2 b/mongodb-org-3/templates/mongod-2.6.conf.j2 new file mode 100644 index 00000000..9e6d541d --- /dev/null +++ b/mongodb-org-3/templates/mongod-2.6.conf.j2 @@ -0,0 +1,82 @@ +# mongod.conf + +# Where to store the data. + +# Note: if you run mongodb as a non-root user (recommended) you may +# need to create and set permissions for this directory manually, +# e.g., if the parent directory isn't mutable by the mongodb user. +dbpath={{ mongodb_dbpath }} +directoryperdb={{ mongodb_directoryperdb }} + +#where to log +logpath={{ mongodb_logpath }} + +logappend=true + +port = {{ mongodb_tcp_port }} + +# Listen to local interface only. Comment out to listen on all interfaces. +#bind_ip = 127.0.0.1 + +# Disables write-ahead journaling +# nojournal = true + +# Enables periodic logging of CPU utilization and I/O wait +#cpu = true + +# Turn on/off security. Off is currently the default +#noauth = true +#auth = true + +# Verbose logging output. +#verbose = true + +# Inspect all client data for validity on receipt (useful for +# developing drivers) +#objcheck = true + +# Enable db quota management +#quota = true + +# Set oplogging level where n is +# 0=off (default) +# 1=W +# 2=R +# 3=both +# 7=W+some reads +#diaglog = 0 + +# Ignore query hints +#nohints = true + + +{% if not mongodb_http_interface %} +# Disable the HTTP interface (Defaults to localhost:28017). +nohttpinterface = true +{% endif %} + +# Turns off server-side scripting. This will result in greatly limited +# functionality +#noscripting = true + +# Turns off table scans. Any query that would do a table scan fails. +#notablescan = true + +# Disable data file preallocation. +#noprealloc = true + +# Specify .ns file size for new databases. +# nssize = + +{% if mongodb_cluster_enabled %} +# Replication Options + +# in replicated mongo databases, specify the replica set name here +replSet = {{ mongodb_replicaset }} +# maximum size in megabytes for replication operation log +#oplogSize=1024 +# path to a key file storing authentication info for connections +# between replica set members +keyFile=/data/mongo_home/dev-d4science-keyfile +{% endif %} + diff --git a/mongodb-org-3/templates/mongod-3.0.conf.j2 b/mongodb-org-3/templates/mongod-3.0.conf.j2 new file mode 100644 index 00000000..1149b8eb --- /dev/null +++ b/mongodb-org-3/templates/mongod-3.0.conf.j2 @@ -0,0 +1,44 @@ +# mongod.conf + +# for documentation of all options, see: +# http://docs.mongodb.org/manual/reference/configuration-options/ + +# Where and how to store data. +storage: + dbPath: {{ mongodb_dbpath }} + journal: + enabled: true + engine: wiredTiger +# mmapv1: +# wiredTiger: + +# where to write logging data. +systemLog: + destination: file + logAppend: true + path: {{ mongodb_logpath }} + +# network interfaces +net: + port: {{ mongodb_tcp_port }} +# bindIp: 127.0.0.1 + + +#processManagement: + +security: + keyFile: /data/mongo_home/dev-d4science-keyfile + +#operationProfiling: + +replication: + oplogSizeMB: 2000 + replSetName: {{ mongodb_replicaset }} + +#sharding: + +## Enterprise-Only Options: + +#auditLog: + +#snmp: diff --git a/mongodb-org-3/templates/mongodb-2.4.conf.j2 b/mongodb-org-3/templates/mongodb-2.4.conf.j2 new file mode 100644 index 00000000..47ea9f27 --- /dev/null +++ b/mongodb-org-3/templates/mongodb-2.4.conf.j2 @@ -0,0 +1,87 @@ +# Note: if you run mongodb as a non-root user (recommended) you may +# need to create and set permissions for this directory manually, +# e.g., if the parent directory isn't mutable by the mongodb user. +dbpath={{ mongodb_dbpath }} +directoryperdb={{ mongodb_directoryperdb }} + +#where to log +logpath={{ mongodb_logpath }} + +logappend=true + +port = {{ mongodb_tcp_port }} + +# Disables write-ahead journaling +# nojournal = true + +# Enables periodic logging of CPU utilization and I/O wait +#cpu = true + +# Turn on/off security. Off is currently the default +#noauth = true +#auth = true + +# Verbose logging output. +#verbose = true + +# Inspect all client data for validity on receipt (useful for +# developing drivers) +#objcheck = true + +# Enable db quota management +#quota = true + +# Set oplogging level where n is +# 0=off (default) +# 1=W +# 2=R +# 3=both +# 7=W+some reads +#diaglog = 0 +# Ignore query hints +#nohints = true + +{% if not mongodb_http_interface %} +# Disable the HTTP interface (Defaults to localhost:28017). +nohttpinterface = true +{% endif %} + +# Turns off server-side scripting. This will result in greatly limited +# functionality +#noscripting = true + +# Turns off table scans. Any query that would do a table scan fails. +#notablescan = true + +# Disable data file preallocation. +#noprealloc = true + +# Specify .ns file size for new databases. +# nssize = + +# Accout token for Mongo monitoring server. +#mms-token = + +# Server name for Mongo monitoring server. +#mms-name = + +# Ping interval for Mongo monitoring server. +#mms-interval = + +# Replication Options + +# in master/slave replicated mongo databases, specify here whether +# this is a slave or master +#slave = true +#source = master.example.com +# Slave only: specify a single database to replicate +#only = master.example.com +# or +#master = true +#source = slave.example.com + +{% if mongodb_cluster_enabled %} +# in replica set configuration, specify the name of the replica set +replSet = {{ mongodb_replicaset }} +{% endif %} + diff --git a/mongodb-org-3/templates/mongodb.pyconf.j2 b/mongodb-org-3/templates/mongodb.pyconf.j2 new file mode 100644 index 00000000..a23f9b1c --- /dev/null +++ b/mongodb-org-3/templates/mongodb.pyconf.j2 @@ -0,0 +1,109 @@ +modules { + module { + name = "mongodb" + language = "python" + param server_status { + value = "mongo --quiet --eval 'printjson(db.serverStatus())'" + } + param rs_status { + value = "mongo --quiet --eval 'printjson(rs.status())'" + } + } +} + +collection_group { + collect_every = 30 + time_threshold = 90 + metric { + name = "mongodb_opcounters_insert" + title = "Inserts" + } + metric { + name = "mongodb_opcounters_query" + title = "Queries" + } + metric { + name = "mongodb_opcounters_update" + title = "Updates" + } + metric { + name = "mongodb_opcounters_delete" + title = "Deletes" + } + metric { + name = "mongodb_opcounters_getmore" + title = "Getmores" + } + metric { + name = "mongodb_opcounters_command" + title = "Commands" + } + metric { + name = "mongodb_backgroundFlushing_flushes" + title = "Flushes" + } + metric { + name = "mongodb_mem_mapped" + title = "Memory-mapped Data" + } + metric { + name = "mongodb_mem_virtual" + title = "Process Virtual Size" + } + metric { + name = "mongodb_mem_resident" + title = "Process Resident Size" + } + metric { + name = "mongodb_extra_info_page_faults" + title = "Page Faults" + } + metric { + name = "mongodb_globalLock_ratio" + title = "Global Write Lock Ratio" + } + metric { + name = "mongodb_indexCounters_btree_miss_ratio" + title = "BTree Page Miss Ratio" + } + metric { + name = "mongodb_globalLock_currentQueue_total" + title = "Total Operations Waiting for Lock" + } + metric { + name = "mongodb_globalLock_currentQueue_readers" + title = "Readers Waiting for Lock" + } + metric { + name = "mongodb_globalLock_currentQueue_writers" + title = "Writers Waiting for Lock" + } + metric { + name = "mongodb_globalLock_activeClients_total" + title = "Total Active Clients" + } + metric { + name = "mongodb_globalLock_activeClients_readers" + title = "Active Readers" + } + metric { + name = "mongodb_globalLock_activeClients_writers" + title = "Active Writers" + } + metric { + name = "mongodb_connections_current" + title = "Open Connections" + } + metric { + name = "mongodb_connections_current_ratio" + title = "Open Connections" + } + metric { + name = "mongodb_slave_delay" + title = "Replica Set Slave Delay" + } + metric { + name = "mongodb_asserts_total" + title = "Asserts per Second" + } +}