diff --git a/stalker/__init__.py b/stalker/__init__.py index 3748f22..dc905b3 100644 --- a/stalker/__init__.py +++ b/stalker/__init__.py @@ -2,7 +2,7 @@ #: Version information (major, minor, revision[, 'dev']). -version_info = (0, 0, 19) +version_info = (0, 0, 21) #: Version string 'major.minor.revision'. version = __version__ = ".".join(map(str, version_info)) gettext.install('stalker') diff --git a/stalker/stalker_agent.py b/stalker/stalker_agent.py index d7e2ed1..84dcad8 100644 --- a/stalker/stalker_agent.py +++ b/stalker/stalker_agent.py @@ -1,8 +1,7 @@ import os import json -import urllib2 from eventlet import wsgi -from eventlet.green import subprocess +from eventlet.green import subprocess, urllib2 from socket import gethostname import eventlet from stalker.stalker_utils import Daemon, FileLikeLogger, readconf, get_logger diff --git a/stalker/stalker_runner.py b/stalker/stalker_runner.py index 001264c..447f300 100644 --- a/stalker/stalker_runner.py +++ b/stalker/stalker_runner.py @@ -1,12 +1,14 @@ import os import errno import signal -import urllib2 from time import time import eventlet +from eventlet.green import urllib2 + from bson import ObjectId from bson.json_util import loads + from stalker.stalker_utils import Daemon, get_logger, get_syslogger, \ TRUE_VALUES, StatsdEvent eventlet.monkey_patch() @@ -188,6 +190,8 @@ def run_check(self, payload): if previous_status is True: self._flap_incr(flapid) query = {'_id': ObjectId(check['_id'])} + if 'follow_up' not in check: #continue to work with old schema + check['follow_up'] = check['interval'] update = {"$set": {'pending': False, 'status': False, 'flapping': self.flapping(flapid), 'next': time() + check['follow_up'], @@ -216,9 +220,13 @@ def start(self): count = len(checks) self.logger.debug("Got %d checks" % count) self.statsd.counter('queue.get', count) - check_result = [x for x in self.pool.imap(self.run_check, - checks)] - self.logger.debug(check_result) + try: + check_result = [x for x in self.pool.imap(self.run_check, + checks)] + self.logger.debug(check_result) + except Exception: + self.logger.exception('Error running checks') + else: self.logger.debug('No checks, sleeping') eventlet.sleep()