Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[mongo] make timeout configurable and increase the default #1823

Merged
merged 1 commit into from
Aug 12, 2015
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 3 additions & 2 deletions checks.d/mongo.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
from checks import AgentCheck
from util import get_hostname

DEFAULT_TIMEOUT = 10
DEFAULT_TIMEOUT = 30


class MongoDb(AgentCheck):
Expand Down Expand Up @@ -211,8 +211,9 @@ def check(self, instance):
self.log.debug("Mongo: cannot extract username and password from config %s" % server)
do_auth = False

timeout = float(instance.get('timeout', DEFAULT_TIMEOUT))
try:
conn = pymongo.Connection(server, network_timeout=DEFAULT_TIMEOUT,
conn = pymongo.Connection(server, network_timeout=timeout,
**ssl_params)
db = conn[db_name]
except Exception:
Expand Down
3 changes: 3 additions & 0 deletions conf.d/mongo.yaml.example
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,9 @@ init_config:
instances:
# Specify the MongoDB URI, with database to use for reporting (defaults to "admin")
- server: mongodb://localhost:27017/admin
# Time to wait on creating a MongoDB connection
# timeout: 30

# tags:
# - optional_tag1
# - optional_tag2
Expand Down