Skip to content

Commit

Permalink
Add a network timeout to the mongo connection. Fix #627
Browse files Browse the repository at this point in the history
  • Loading branch information
Remi Hakim committed Aug 27, 2013
1 parent cfd4e55 commit a0d4584
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion checks.d/mongo.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,8 @@
# http://www.mongodb.org/display/DOCS/connections6
mongo_uri_re=re.compile(r'mongodb://(?P<username>[^:@]+):(?P<password>[^:@]+)@.*')

DEFAULT_TIMEOUT = 10

class MongoDb(AgentCheck):

GAUGES = [
Expand Down Expand Up @@ -130,7 +132,7 @@ def check(self, instance):
self.log.debug("Mongo: cannot extract username and password from config %s" % instance['server'])
do_auth = False

conn = Connection(instance['server'])
conn = Connection(instance['server'], network_timeout=DEFAULT_TIMEOUT)
db = conn['admin']
if do_auth:
if not db.authenticate(username, password):
Expand Down

0 comments on commit a0d4584

Please # to comment.